Skip to content

Commit 05649ca

Browse files
committed
add share link option
1 parent a556e5b commit 05649ca

File tree

5 files changed

+256
-32
lines changed

5 files changed

+256
-32
lines changed

src/components/TagList.jsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Button } from 'flowbite-react';
12
import { useState } from 'react';
23

34
const TagList = () => {
@@ -22,32 +23,35 @@ const TagList = () => {
2223
};
2324

2425
return (
25-
<div className="flex flex-wrap gap-2 w-1/4">
26+
<div className="flex flex-col gap-2 w-[100%] px-[30px]">
2627

27-
<input
28-
type="text"
29-
value={inputValue}
30-
onChange={handleInputChange}
31-
onKeyDown={handleInputKeyDown}
32-
placeholder='Enter the input tag'
33-
className="block w-full rounded-md border-0 py-1.5 pl-4 pr-20 text-gray-900 ring-1 ring-inset ring-gray-300"
34-
/>
35-
{tags.map((tag, index) => (
36-
<div
37-
key={index}
38-
className="flex items-center px-3 py-1 bg-slate-500 text-white rounded-md cursor-pointer"
39-
>
40-
<span className="mr-2">{tag}</span>
41-
<button
42-
className="text-sm font-bold text-white rounded-full "
43-
onClick={() => handleRemoveTag(index)}
44-
>
45-
&times;
46-
</button>
47-
</div>
48-
))}
28+
<div className='flex flex-row gap-x-[10px] items-center py-[10px]'>
29+
<input
30+
type="text"
31+
value={inputValue}
32+
onChange={handleInputChange}
33+
onKeyDown={handleInputKeyDown}
34+
placeholder='Enter the input tag'
35+
className="block rounded-md text-gray-900 border-[1px] border-[#DCE3EE] dark:border-[#232830] flex-grow"
36+
/>
37+
<Button className='ml-auto'>Share</Button>
38+
</div>
39+
40+
<div className='w-full h-auto flex flex-col flex-grow gap-y-[10px] pb-[20px]'>
41+
{tags.map((tag, index) => {
42+
return (
43+
<div className='flex flex-row items-center'>
44+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-5 h-5 mr-[8px]">
45+
<path strokeLinecap="round" strokeLinejoin="round" d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z" />
46+
</svg>
47+
<div>{tag}</div>
48+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-5 h-5 ml-auto">
49+
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
50+
</svg>
51+
</div>
52+
)})}
53+
</div>
4954
</div>
50-
);
51-
};
55+
)}
5256

5357
export default TagList;

src/components/otpVerificationSingleEmployee.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import React, { useState } from 'react'
22
import { Button } from 'flowbite-react'
33
import OtpInput from 'react-otp-input';
44

5-
const OTPVerificationSingleEmployee = ({otp, setOtp, verifyOTPHandler}) => {
5+
const OTPVerificationSingleEmployee = ({otp, setOtp, verifyOTPHandler, mobileNumber}) => {
6+
7+
console.log(otp, setOtp, mobileNumber)
68

79
return (
810
<div className='flex flex-col mt-[40px]'>
911
<div>
1012
<span className='text-[20px]'>We have sent you an OTP on</span><br/>
11-
<span className='text-gray-600 dark:text-gray-200 mt-[10px]'>+91 9137357003</span>
13+
<span className='text-gray-600 dark:text-gray-200 mt-[10px]'>+91 {mobileNumber}</span>
1214
</div>
1315

1416
<div className='flex flex-col justify-center items-center'>

src/pages/byLink.jsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
1+
import TagList from '@/components/TagList'
2+
import { useAuth } from '@/context/AuthContext'
3+
import { Button } from 'flowbite-react'
14
import React from 'react'
25

36
const ByLink = () => {
7+
const { profile } = useAuth()
8+
console.log(profile)
49
return (
5-
<div>
6-
Verify By Link
10+
<div className='w-[70%] dark:text-white dark:bg-dark2 text-dark3'>
11+
<div className='flex flex-col justify-center text-[26px] font-medium h-[80px] pl-[40px] border-b-[1px] dark:border-[#232830] border-[#DCE3EE]'>
12+
<span></span>Verify by link
13+
<div className='text-[14px] font-normal'>send the intrested employee this link to verify their identity and background check</div>
14+
</div>
15+
16+
<div className='flex flex-row items-center w-[70%] mx-auto h-[70px] mt-[30px] rounded-lg border-[1px] border-[#DCE3EE] dark:border-[#232830]'>
17+
<div className='flex justify-center items-center w-[10%] h-full border-r-[1px] border-[#DCE3EE] dark:border-[#232830]'>
18+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="#A9A9A9" className="w-7 h-7">
19+
<path strokeLinecap="round" strokeLinejoin="round" d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244" />
20+
</svg>
21+
</div>
22+
<div className='flex flex-row items-center text-[16px] font-medium px-[20px] text-[#090D11] dark:text-[#D9D9D9]'>
23+
https://localhost:3000/verifyByLink/{profile.gstin}
24+
</div>
25+
<Button className='ml-auto mr-[25px]'>
26+
Copy Link
27+
</Button>
28+
</div>
29+
30+
<div className='flex flex-col w-[50%] max-h-[400px] mt-[40px] rounded-lg border-[1px] border-[#DCE3EE] dark:border-[#232830] mx-auto pb-20px box-border'>
31+
<div className='py-[15px] px-[30px] border-b-[1px] border-[#DCE3EE] dark:border-[#232830] '>
32+
<div className='text-[16px] font-medium'>Share this link Via Gmail</div>
33+
<div className='text-[12px]'>enter your friends' email address to send them link</div>
34+
</div>
35+
<div className='overflow-scroll'>
36+
<TagList/>
37+
</div>
38+
</div>
739
</div>
840
)
941
}

src/pages/singleEmployee.jsx

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,56 @@
11
import EmployeeVerificationForm from '@/components/employeeVerificationForm'
22
import ImageVerificationSingleEmployee from '@/components/imageVerificationSingleEmployee'
33
import OTPVerificationSingleEmployee from '@/components/otpVerificationSingleEmployee'
4+
import { SERVER_URL } from '@/constants/config'
5+
import axios from 'axios'
46
import React, { useState } from 'react'
7+
import { toast } from 'react-toastify'
58

69
const SingleEmployee = () => {
710
const [stage, setStage] = useState('details') //details || verifyOTP || verifyImage
811
const [employeeData, setEmployeeData] = useState({})
12+
// const [employeeData, setEmployeeData] = useState({name: 'rupesh', gender: 'male', phone: '9137357003'})
913
const [otp, setOtp] = useState('');
14+
const [mobileNumber, setMobileNumber] = useState(null)
1015

11-
const onProceedHandler = (formData) => {
16+
const onProceedHandler = async (formData) => {
1217
setEmployeeData(formData)
13-
setStage('verifyOTP')
18+
const mob = await getMobileNumberFromCardNumber(formData.cardNumber)
19+
setMobileNumber(mob)
20+
// sendOTP(mob)
21+
sendOTP(9137357003)
22+
// setStage('verifyOTP')
23+
}
24+
25+
const getMobileNumberFromCardNumber = async (cardNumber) => {
26+
// setMobileNumber(8383238282)
27+
return 8383238282
28+
}
29+
30+
const sendOTP = async (phoneNumber) => {
31+
axios
32+
.post(`${SERVER_URL}/apis/sendOTP`, { phone: phoneNumber })
33+
.then(() => setStage("verifyOTP"))
34+
.catch((err) => {
35+
console.error(err);
36+
toast.error("Some error sending OTP")
37+
});
1438
}
1539

1640
const verifyOTPHandler = () => {
1741
console.log(otp)
42+
43+
const phone = 9137357003
44+
axios
45+
.post(`${SERVER_URL}/apis/verifyOTP`, { phone: phone, code: otp })
46+
.then((res) => {
47+
if(res.data.success){
48+
toast.success("Verified OTP successfuly !");
49+
// props.postVerification();
50+
} else {
51+
toast.error("Invalid OTP !");
52+
}
53+
})
1854

1955
setStage('verifyImage')
2056
}
@@ -104,7 +140,7 @@ const SingleEmployee = () => {
104140

105141
<div className='w-[60%] mx-auto'>
106142
{stage == 'details' && <EmployeeVerificationForm onProceedHandler={onProceedHandler}/>}
107-
{stage == 'verifyOTP' && <OTPVerificationSingleEmployee otp={otp} setOtp={setOtp} verifyOTPHandler={verifyOTPHandler}/>}
143+
{stage == 'verifyOTP' && <OTPVerificationSingleEmployee otp={otp} setOtp={setOtp} verifyOTPHandler={verifyOTPHandler} mobileNumber={mobileNumber}/>}
108144
{stage == 'verifyImage' && <ImageVerificationSingleEmployee/>}
109145
</div>
110146
</div>

src/pages/verifyByLink/[gstin].jsx

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import EmployeeVerificationForm from '@/components/employeeVerificationForm'
2+
import ImageVerificationSingleEmployee from '@/components/imageVerificationSingleEmployee'
3+
import OTPVerificationSingleEmployee from '@/components/otpVerificationSingleEmployee'
4+
import { SERVER_URL } from '@/constants/config'
5+
import axios from 'axios'
6+
import React, { useState } from 'react'
7+
import { toast } from 'react-toastify'
8+
9+
const VerifyByLink = () => {
10+
const [stage, setStage] = useState('details') //details || verifyOTP || verifyImage
11+
const [employeeData, setEmployeeData] = useState({})
12+
// const [employeeData, setEmployeeData] = useState({name: 'rupesh', gender: 'male', phone: '9137357003'})
13+
const [otp, setOtp] = useState('');
14+
const [mobileNumber, setMobileNumber] = useState(null)
15+
16+
const onProceedHandler = async (formData) => {
17+
setEmployeeData(formData)
18+
const mob = await getMobileNumberFromCardNumber(formData.cardNumber)
19+
setMobileNumber(mob)
20+
// sendOTP(mob)
21+
sendOTP(9137357003)
22+
// setStage('verifyOTP')
23+
}
24+
25+
const getMobileNumberFromCardNumber = async (cardNumber) => {
26+
// setMobileNumber(8383238282)
27+
return 8383238282
28+
}
29+
30+
const sendOTP = async (phoneNumber) => {
31+
axios
32+
.post(`${SERVER_URL}/apis/sendOTP`, { phone: phoneNumber })
33+
.then(() => setStage("verifyOTP"))
34+
.catch((err) => {
35+
console.error(err);
36+
toast.error("Some error sending OTP")
37+
});
38+
}
39+
40+
const verifyOTPHandler = () => {
41+
console.log(otp)
42+
43+
const phone = 9137357003
44+
axios
45+
.post(`${SERVER_URL}/apis/verifyOTP`, { phone: phone, code: otp })
46+
.then((res) => {
47+
if(res.data.success){
48+
toast.success("Verified OTP successfuly !");
49+
// props.postVerification();
50+
} else {
51+
toast.error("Invalid OTP !");
52+
}
53+
})
54+
55+
setStage('verifyImage')
56+
}
57+
58+
return (
59+
<div className='w-[100%] dark:text-white dark:bg-dark2 text-dark3'>
60+
<div className='flex flex-row items-center text-[26px] font-medium h-[70px] pl-[40px] border-b-[1px] dark:border-[#232830] border-[#DCE3EE] bg-'>
61+
Verify Employee
62+
</div>
63+
64+
<div className="flex flex-row w-[40%] mt-[20px] mx-auto items-center justify-between text-[14px] font-[12px]">
65+
<div className="flex flex-row items-center text-blue-600 dark:text-blue-500">
66+
<svg
67+
aria-hidden="true"
68+
className="w-4 h-4 mr-2"
69+
fill="currentColor"
70+
viewBox="0 0 20 20"
71+
xmlns="http://www.w3.org/2000/svg"
72+
>
73+
<path
74+
fillRule="evenodd"
75+
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
76+
clipRule="evenodd"
77+
></path>
78+
</svg>
79+
Employee Details
80+
</div>
81+
<div
82+
className={`h-[1px] w-[30px] sm:w-[30px] ${
83+
stage == "verifyOTP" || stage == "verifyImage"
84+
? "bg-blue-600 dark:bg-blue-500"
85+
: "bg-gray-500 dark:bg-gray-200"
86+
}`}
87+
></div>
88+
<div
89+
className={`flex flex-row items-center ${
90+
stage == "verifyOTP" || stage == "verifyImage"
91+
? "text-blue-600 dark:text-blue-500"
92+
: "text-gray-500"
93+
}`}
94+
>
95+
<svg
96+
aria-hidden="true"
97+
className="w-4 h-4 mr-2"
98+
fill="currentColor"
99+
viewBox="0 0 20 20"
100+
xmlns="http://www.w3.org/2000/svg"
101+
>
102+
<path
103+
fillRule="evenodd"
104+
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
105+
clipRule="evenodd"
106+
></path>
107+
</svg>
108+
OTP Verification
109+
</div>
110+
<div
111+
className={`h-[1px] w-[30px] sm:w-[30px] ${
112+
stage == "verifyImage"
113+
? "bg-blue-600 dark:bg-blue-500"
114+
: "bg-gray-500 dark:bg-gray-200"
115+
}`}
116+
></div>
117+
<div
118+
className={`flex flex-row items-center ${
119+
stage == "verifyImage"
120+
? "text-blue-600 dark:text-blue-500"
121+
: "text-gray-500"
122+
}`}
123+
>
124+
<svg
125+
aria-hidden="true"
126+
className="w-4 h-4 mr-2"
127+
fill="currentColor"
128+
viewBox="0 0 20 20"
129+
xmlns="http://www.w3.org/2000/svg"
130+
>
131+
<path
132+
fillRule="evenodd"
133+
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
134+
clipRule="evenodd"
135+
></path>
136+
</svg>
137+
Image Verification
138+
</div>
139+
</div>
140+
141+
<div className='w-[50%] mx-auto'>
142+
{stage == 'details' && <EmployeeVerificationForm onProceedHandler={onProceedHandler}/>}
143+
{stage == 'verifyOTP' && <OTPVerificationSingleEmployee otp={otp} setOtp={setOtp} verifyOTPHandler={verifyOTPHandler} mobileNumber={mobileNumber}/>}
144+
{stage == 'verifyImage' && <ImageVerificationSingleEmployee/>}
145+
</div>
146+
</div>
147+
)
148+
}
149+
150+
export default VerifyByLink

0 commit comments

Comments
 (0)