Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 9576e68a
authored
2024-03-13 16:44:12 +0530
by
jay
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
vendor sign in, otp, business details
1 parent
edc08403
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
312 additions
and
139 deletions
components/layout/Header.js
components/signup/Signup.js
components/vendor/BusinessDetails.js
package.json
pages/api/auth/[...nextauth].js
redux/actions/userActions.js
redux/actions/vendorActions.js
redux/constants/vendorConstants.js
redux/reducers/vendorReducers.js
yarn.lock
components/layout/Header.js
View file @
9576e68
...
@@ -2,14 +2,22 @@ import { getSession, signOut } from "next-auth/react";
...
@@ -2,14 +2,22 @@ import { getSession, signOut } from "next-auth/react";
import
Image
from
"next/image"
;
import
Image
from
"next/image"
;
import
Link
from
"next/link"
;
import
Link
from
"next/link"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
useSelector
}
from
"react-redux"
;
import
{
use
Dispatch
,
use
Selector
}
from
"react-redux"
;
import
{
cleanImage
}
from
"../../services/imageHandling"
;
import
{
cleanImage
}
from
"../../services/imageHandling"
;
import
{
Button
,
Container
,
Form
,
Nav
,
Navbar
}
from
"react-bootstrap"
;
import
{
Button
,
Container
,
Form
,
Nav
,
Navbar
}
from
"react-bootstrap"
;
import
{
loadUser
}
from
"../../redux/actions/userActions"
;
const
Header
=
()
=>
{
const
Header
=
()
=>
{
const
{
user
,
error
}
=
useSelector
(
state
=>
state
.
loadedUser
);
const
dispatch
=
useDispatch
();
console
.
log
(
"user"
,
user
);
const
[
isSticky
,
setIsSticky
]
=
useState
(
false
);
const
[
isSticky
,
setIsSticky
]
=
useState
(
false
);
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
loadUser
());
},
[]);
useEffect
(()
=>
{
const
handleScroll
=
()
=>
{
const
handleScroll
=
()
=>
{
// Check if the scroll position is greater than a certain threshold
// Check if the scroll position is greater than a certain threshold
const
scrollY
=
window
.
scrollY
||
window
.
pageYOffset
;
const
scrollY
=
window
.
scrollY
||
window
.
pageYOffset
;
...
@@ -17,15 +25,15 @@ const Header = () => {
...
@@ -17,15 +25,15 @@ const Header = () => {
};
};
// Attach the scroll event listener when the component mounts
// Attach the scroll event listener when the component mounts
window
.
addEventListener
(
'scroll'
,
handleScroll
);
window
.
addEventListener
(
"scroll"
,
handleScroll
);
// Clean up the event listener when the component unmounts
// Clean up the event listener when the component unmounts
return
()
=>
{
return
()
=>
{
window
.
removeEventListener
(
'scroll'
,
handleScroll
);
window
.
removeEventListener
(
"scroll"
,
handleScroll
);
};
};
},
[]);
},
[]);
return
(
return
(
<
header
className
=
{
`header_wrap
${
isSticky
?
'stick'
:
''
}
`
}
>
<
header
className
=
{
`header_wrap
${
isSticky
?
"stick"
:
""
}
`
}
>
<
Navbar
expand
=
"lg"
className
=
"bg-body-tertiary"
>
<
Navbar
expand
=
"lg"
className
=
"bg-body-tertiary"
>
<
Container
fluid
>
<
Container
fluid
>
<
Navbar
.
Brand
href
=
"#"
>
<
Navbar
.
Brand
href
=
"#"
>
...
@@ -54,12 +62,23 @@ const Header = () => {
...
@@ -54,12 +62,23 @@ const Header = () => {
<
/Button
>
<
/Button
>
<
/div
>
<
/div
>
<
/Form
>
<
/Form
>
{
/* {console.log(user.id)} */
}
{(
user
&&
user
.
id
)
?
(
<
div
>
{
console
.
log
(
"here"
)}
<
div
><
p
>
Brand
Logo
<
/p></
div
>
<
p
>
{
user
.
phone
}
<
/p
>
<
/div
>
)
:
(
<
div
>
<
Button
className
=
"me-3"
variant
=
"primary"
>
<
Button
className
=
"me-3"
variant
=
"primary"
>
Sign
Up
Sign
Up
<
/Button
>
<
/Button
>
<
Button
className
=
""
variant
=
"primary"
>
<
Button
className
=
""
variant
=
"primary"
>
Log
In
Log
In
<
/Button
>
<
/Button
>
<
/div
>
)}
<
/Navbar.Collapse
>
<
/Navbar.Collapse
>
<
/Container
>
<
/Container
>
<
/Navbar
>
<
/Navbar
>
...
...
components/signup/Signup.js
View file @
9576e68
...
@@ -13,6 +13,7 @@ import { registerUser } from "../../redux/actions/userActions";
...
@@ -13,6 +13,7 @@ import { registerUser } from "../../redux/actions/userActions";
import
{
toast
}
from
"react-toastify"
;
import
{
toast
}
from
"react-toastify"
;
import
OTPInput
from
"../common-components/OTPInput"
;
import
OTPInput
from
"../common-components/OTPInput"
;
import
{
finishVendorOtpVerification
}
from
"../../redux/actions/vendorActions"
;
import
{
finishVendorOtpVerification
}
from
"../../redux/actions/vendorActions"
;
import
{
signIn
}
from
"next-auth/react"
;
const
Signup
=
props
=>
{
const
Signup
=
props
=>
{
console
.
log
(
props
.
type
);
console
.
log
(
props
.
type
);
...
@@ -35,7 +36,7 @@ const Signup = props => {
...
@@ -35,7 +36,7 @@ const Signup = props => {
};
};
const
signupValidationSchema
=
Yup
.
object
().
shape
({
const
signupValidationSchema
=
Yup
.
object
().
shape
({
fullname
:
Yup
.
string
().
required
(
"Full
name is R
equired"
),
fullname
:
Yup
.
string
().
required
(
"Full
name is r
equired"
),
email
:
Yup
.
string
().
required
(
"Email Id is Required"
).
email
(
"Please Enter An Valid Email Id"
),
email
:
Yup
.
string
().
required
(
"Email Id is Required"
).
email
(
"Please Enter An Valid Email Id"
),
password
:
Yup
.
string
().
required
(
"Password is Required"
).
min
(
6
,
"Password must be minimum 6 characters"
),
password
:
Yup
.
string
().
required
(
"Password is Required"
).
min
(
6
,
"Password must be minimum 6 characters"
),
confirmPassword
:
Yup
.
string
()
confirmPassword
:
Yup
.
string
()
...
@@ -74,6 +75,8 @@ const Signup = props => {
...
@@ -74,6 +75,8 @@ const Signup = props => {
}
}
};
};
// console.log("otp", otp);
return
(
return
(
<
Fragment
>
<
Fragment
>
<
div
className
=
"contaier-fluid login-banner-image"
>
<
div
className
=
"contaier-fluid login-banner-image"
>
...
@@ -130,14 +133,23 @@ const Signup = props => {
...
@@ -130,14 +133,23 @@ const Signup = props => {
const
otpRes
=
await
finishVendorOtpVerification
({
email
:
values
.
email
,
oneTimePassword
});
const
otpRes
=
await
finishVendorOtpVerification
({
email
:
values
.
email
,
oneTimePassword
});
console
.
log
(
"otpRes"
,
otpRes
);
console
.
log
(
"otpRes"
,
otpRes
);
if
(
otpRes
.
data
.
ok
)
{
if
(
otpRes
.
data
.
ok
)
{
// router.push("/thank-you")
const
result
=
await
signIn
(
"credentials"
,
{
toast
.
success
(
"User registered successflly"
);
email
:
values
.
email
,
password
:
values
.
password
,
redirect
:
false
});
console
.
log
(
"result"
,
result
);
router
.
push
(
"/vendor/business-details"
);
// toast.success("User registered successflly");
}
else
if
(
!
otpRes
.
data
.
ok
)
{
setOtp
(
new
Array
(
4
).
fill
(
""
));
toast
.
error
(
"Invalid OTP, please try again."
);
}
}
}
}
}}
}}
>
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
Full
n
ame
<
/label
>
<
label
>
Full
N
ame
<
/label
>
<
input
type
=
"text"
name
=
"fullname"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
fullname
}
placeholder
=
"Your name"
/>
<
input
type
=
"text"
name
=
"fullname"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
fullname
}
placeholder
=
"Your name"
/>
{
errors
.
fullname
&&
touched
.
fullname
&&
<
span
className
=
"form-error"
>
{
errors
.
fullname
}
<
/span>
}
{
errors
.
fullname
&&
touched
.
fullname
&&
<
span
className
=
"form-error"
>
{
errors
.
fullname
}
<
/span>
}
<
/div
>
<
/div
>
...
...
components/vendor/BusinessDetails.js
View file @
9576e68
import
{
Formik
}
from
"formik"
;
import
{
Formik
}
from
"formik"
;
import
{
Fragment
}
from
"react"
;
import
{
Fragment
,
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
Button
,
Form
}
from
"react-bootstrap"
;
import
{
Button
,
Form
}
from
"react-bootstrap"
;
import
*
as
Yup
from
"yup"
;
import
*
as
Yup
from
"yup"
;
import
{
FaArrowRight
,
FaTimes
}
from
"react-icons/fa"
;
import
{
FaArrowRight
,
FaTimes
}
from
"react-icons/fa"
;
import
Image
from
"next/image"
;
import
Image
from
"next/image"
;
import
{
getSession
}
from
"next-auth/react"
;
import
"react-bootstrap-typeahead/css/Typeahead.css"
;
import
{
useDispatch
}
from
"react-redux"
;
import
{
getLoggedInVendor
}
from
"../../redux/actions/vendorActions"
;
const
BusinessDetails
=
()
=>
{
const
BusinessDetails
=
()
=>
{
const
[
session
,
setSession
]
=
useState
(
null
);
const
dispatch
=
useDispatch
()
// const [pincodeData, setPinCodeData] = useState()
// const ref = useRef(null);
useEffect
(()
=>
{
const
fetchSession
=
async
()
=>
{
setSession
(
await
getSession
());
};
fetchSession
();
},
[]);
console
.
log
(
"session"
,
session
);
const
businessDetailsValidationSchema
=
Yup
.
object
().
shape
({
const
businessDetailsValidationSchema
=
Yup
.
object
().
shape
({
panNumber
:
Yup
.
string
()
panNumber
:
Yup
.
string
().
required
(
"Pan Number is Required"
),
.
required
(
"Pan Number is Required"
),
panFile
:
Yup
.
mixed
().
required
(
"Pan Image is Required"
),
panFile
:
Yup
.
mixed
()
gstNumber
:
Yup
.
string
().
required
(
"GST Number is Required"
),
.
required
(
"Pan Image is Required"
),
gstCertificateFile
:
Yup
.
mixed
().
required
(
"GST Certificate is Required"
),
gstNumber
:
Yup
.
string
()
businessName
:
Yup
.
string
().
required
(
"Business Name is Required"
),
.
required
(
"GST Number is Required"
),
brandLogoFile
:
Yup
.
mixed
().
required
(
"Brand Logo is Required"
),
gstCertificateFile
:
Yup
.
mixed
()
pincode
:
Yup
.
string
().
required
(
"Pincode is Required"
),
.
required
(
"GST Certificate is Required"
),
country
:
Yup
.
string
().
required
(
"Country is Required"
),
businessName
:
Yup
.
string
()
state
:
Yup
.
string
().
required
(
"State is Required"
),
.
required
(
"Business Name is Required"
),
city
:
Yup
.
string
().
required
(
"City is Required"
),
brandLogoFile
:
Yup
.
mixed
()
addressLine1
:
Yup
.
string
().
required
(
"Address Line 1 is Required"
),
.
required
(
"Brand Logo is Required"
),
addressLine2
:
Yup
.
string
().
required
(
"Address Line 2 is Required"
)
pincode
:
Yup
.
string
()
.
required
(
"Pincode is Required"
),
country
:
Yup
.
string
()
.
required
(
"Country is Required"
),
state
:
Yup
.
string
()
.
required
(
"State is Required"
),
city
:
Yup
.
string
()
.
required
(
"City is Required"
),
addressLine1
:
Yup
.
string
()
.
required
(
"Address Line 1 is Required"
),
addressLine2
:
Yup
.
string
()
.
required
(
"Address Line 2 is Required"
),
});
});
// const handleSearch = async pin => {
// let pincodeDataSet = await pincodeSearchByFilter(pin);
// console.log("pincodeData", pincodeDataSet.data.data);
// setPinCodeData(pincodeDataSet.data.data)
// };
return
(
return
(
<
Fragment
>
<
Fragment
>
<
div
className
=
"container p-5"
>
<
div
className
=
"container p-5"
>
...
@@ -41,8 +50,12 @@ const BusinessDetails = () => {
...
@@ -41,8 +50,12 @@ const BusinessDetails = () => {
<
div
className
=
"content-div business-details"
>
<
div
className
=
"content-div business-details"
>
<
h2
>
Tell
us
about
your
business
<
/h2
>
<
h2
>
Tell
us
about
your
business
<
/h2
>
<
p
>
Please
have
the
following
ready
before
you
begin
<
/p
>
<
p
>
Please
have
the
following
ready
before
you
begin
<
/p
>
<
p
><
FaArrowRight
/>
Your
bank
account
details
for
receiving
payments
from
ZanGO
<
/p
>
<
p
>
<
p
className
=
"mb-4"
><
FaArrowRight
/>
Tax
(
GST
/
PAN
)
details
of
your
business
.
<
/p
>
<
FaArrowRight
/>
Your
bank
account
details
for
receiving
payments
from
ZanGO
<
/p
>
<
p
className
=
"mb-4"
>
<
FaArrowRight
/>
Tax
(
GST
/
PAN
)
details
of
your
business
.
<
/p
>
<
hr
/>
<
hr
/>
<
div
className
=
"form-container mt-4"
>
<
div
className
=
"form-container mt-4"
>
<
Formik
<
Formik
...
@@ -62,8 +75,20 @@ const BusinessDetails = () => {
...
@@ -62,8 +75,20 @@ const BusinessDetails = () => {
}}
}}
validationSchema
=
{
businessDetailsValidationSchema
}
validationSchema
=
{
businessDetailsValidationSchema
}
// enableReinitialize={true}
// enableReinitialize={true}
onSubmit
=
{
values
=>
{
onSubmit
=
{
async
values
=>
{
console
.
log
(
"business details values"
,
values
)
console
.
log
(
"business details values"
,
values
);
const
businessDetails
=
{
pan
:
values
.
panNumber
,
gst
:
values
.
gstNumber
,
businessName
:
values
.
businessName
,
state
:
values
.
state
,
city
:
values
.
city
,
pincode
:
values
.
pincode
,
country
:
values
.
country
};
// await dispatch(updateVendorBusinessDetails({businessDetails, }))
dispatch
(
getLoggedInVendor
())
}}
}}
>
>
{({
values
,
errors
,
touched
,
handleChange
,
handleBlur
,
handleSubmit
,
setFieldValue
})
=>
(
{({
values
,
errors
,
touched
,
handleChange
,
handleBlur
,
handleSubmit
,
setFieldValue
})
=>
(
...
@@ -80,14 +105,8 @@ const BusinessDetails = () => {
...
@@ -80,14 +105,8 @@ const BusinessDetails = () => {
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
Enter
Business
PAN
No
.
<
/label
>
<
label
>
Enter
Business
PAN
No
.
<
/label
>
<
input
<
input
type
=
"text"
name
=
"panNumber"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
panNumber
}
/
>
type
=
"text"
{
errors
.
panNumber
&&
touched
.
panNumber
&&
<
span
className
=
"form-error"
>
{
errors
.
panNumber
}
<
/span>
}
name
=
"panNumber"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
panNumber
}
/
>
{
errors
.
panNumber
&&
touched
.
panNumber
&&
(
<
span
className
=
"form-error"
>
{
errors
.
panNumber
}
<
/span>
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
...
@@ -99,10 +118,10 @@ const BusinessDetails = () => {
...
@@ -99,10 +118,10 @@ const BusinessDetails = () => {
className
=
"custom-file-input"
className
=
"custom-file-input"
id
=
"panFile"
id
=
"panFile"
name
=
"panFile"
name
=
"panFile"
onChange
=
{(
event
)
=>
{
onChange
=
{
event
=>
{
if
(
event
)
{
if
(
event
)
{
const
file
=
event
.
currentTarget
.
files
[
0
]
const
file
=
event
.
currentTarget
.
files
[
0
];
setFieldValue
(
"panFile"
,
file
)
setFieldValue
(
"panFile"
,
file
);
}
}
}}
}}
onBlur
=
{
handleBlur
}
onBlur
=
{
handleBlur
}
...
@@ -117,13 +136,16 @@ const BusinessDetails = () => {
...
@@ -117,13 +136,16 @@ const BusinessDetails = () => {
<
/label
>
<
/label
>
<
/div
>
<
/div
>
<
p
className
=
"textS"
>
Upload
in
.
PNG
or
.
JPG
/
JPEG
format
<
/p
>
<
p
className
=
"textS"
>
Upload
in
.
PNG
or
.
JPG
/
JPEG
format
<
/p
>
{
errors
.
panFile
&&
touched
.
panFile
&&
(
<
span
className
=
"form-error"
>
{
errors
.
panFile
}
<
/span>
)
}
{
errors
.
panFile
&&
touched
.
panFile
&&
<
span
className
=
"form-error"
>
{
errors
.
panFile
}
<
/span>
}
{
values
.
panFile
&&
(
{
values
.
panFile
&&
(
<
div
className
=
"d-flex align-items-center justify-content-between p-1"
style
=
{{
width
:
"100%"
}}
>
<
div
className
=
"d-flex align-items-center justify-content-between p-1"
style
=
{{
width
:
"100%"
}}
>
<
p
className
=
"textS m-0"
>
{
values
.
panFile
.
name
}
<
/p
>
<
p
className
=
"textS m-0"
>
{
values
.
panFile
.
name
}
<
/p
>
<
FaTimes
style
=
{{
cursor
:
"pointer"
}}
onClick
=
{()
=>
{
<
FaTimes
setFieldValue
(
"panFile"
,
""
)
style
=
{{
cursor
:
"pointer"
}}
}}
/
>
onClick
=
{()
=>
{
setFieldValue
(
"panFile"
,
""
);
}}
/
>
<
/div
>
<
/div
>
)}
)}
<
/div
>
<
/div
>
...
@@ -133,14 +155,8 @@ const BusinessDetails = () => {
...
@@ -133,14 +155,8 @@ const BusinessDetails = () => {
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
GST
Number
<
/label
>
<
label
>
GST
Number
<
/label
>
<
input
<
input
type
=
"text"
name
=
"gstNumber"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
gstNumber
}
/
>
type
=
"text"
{
errors
.
gstNumber
&&
touched
.
gstNumber
&&
<
span
className
=
"form-error"
>
{
errors
.
gstNumber
}
<
/span>
}
name
=
"gstNumber"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
gstNumber
}
/
>
{
errors
.
gstNumber
&&
touched
.
gstNumber
&&
(
<
span
className
=
"form-error"
>
{
errors
.
gstNumber
}
<
/span>
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
...
@@ -161,7 +177,7 @@ const BusinessDetails = () => {
...
@@ -161,7 +177,7 @@ const BusinessDetails = () => {
<
/label
>
<
/label
>
<
/div
>
<
/div
>
<
p
className
=
"textS"
>
Upload
in
.
PNG
or
.
JPG
/
JPEG
format
<
/p
>
<
p
className
=
"textS"
>
Upload
in
.
PNG
or
.
JPG
/
JPEG
format
<
/p
>
{
errors
.
gstCertificateFile
&&
touched
.
gstCertificateFile
&&
(
<
span
className
=
"form-error"
>
{
errors
.
gstCertificateFile
}
<
/span>
)
}
{
errors
.
gstCertificateFile
&&
touched
.
gstCertificateFile
&&
<
span
className
=
"form-error"
>
{
errors
.
gstCertificateFile
}
<
/span>
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -169,14 +185,8 @@ const BusinessDetails = () => {
...
@@ -169,14 +185,8 @@ const BusinessDetails = () => {
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
Business
Name
<
/label
>
<
label
>
Business
Name
<
/label
>
<
input
<
input
type
=
"text"
name
=
"businessName"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
businessName
}
/
>
type
=
"text"
{
errors
.
businessName
&&
touched
.
businessName
&&
<
span
className
=
"form-error"
>
{
errors
.
businessName
}
<
/span>
}
name
=
"businessName"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
businessName
}
/
>
{
errors
.
businessName
&&
touched
.
businessName
&&
(
<
span
className
=
"form-error"
>
{
errors
.
businessName
}
<
/span>
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
...
@@ -197,7 +207,7 @@ const BusinessDetails = () => {
...
@@ -197,7 +207,7 @@ const BusinessDetails = () => {
<
/label
>
<
/label
>
<
/div
>
<
/div
>
<
p
className
=
"textS"
>
Upload
in
.
PNG
or
.
JPG
/
JPEG
format
<
/p
>
<
p
className
=
"textS"
>
Upload
in
.
PNG
or
.
JPG
/
JPEG
format
<
/p
>
{
errors
.
brandLogoFile
&&
touched
.
brandLogoFile
&&
(
<
span
className
=
"form-error"
>
{
errors
.
brandLogoFile
}
<
/span>
)
}
{
errors
.
brandLogoFile
&&
touched
.
brandLogoFile
&&
<
span
className
=
"form-error"
>
{
errors
.
brandLogoFile
}
<
/span>
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -209,29 +219,36 @@ const BusinessDetails = () => {
...
@@ -209,29 +219,36 @@ const BusinessDetails = () => {
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
Pincode
<
/label
>
<
label
>
Pincode
<
/label
>
<
input
{
/* <AsyncTypeahead
type
=
"text"
onSearch={handleSearch}
name
=
"pincode"
minLength={3}
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value={values.pincode}
value={values.pincode}
/
>
id="basic-behaviors-example"
{
errors
.
pincode
&&
touched
.
pincode
&&
(
<
span
className
=
"form-error"
>
{
errors
.
pincode
}
<
/span>
)
}
labelKey="name"
options={pincodeData && pincodeData.length>0 && pincodeData.map(item=>{
return {name: item.attributes.name, id: item.id}
})}
placeholder="Choose a state..."
ref={ref}
onBlur={() => {
console.log(ref.current);
if (!ref.current.state.selected.length > 0) {
ref.current?.clear();
}
}}
onChange={(e) => {
console.log("input change", e);
}}
/> */
}
<
input
type
=
"text"
name
=
"pincode"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
pincode
}
/
>
{
errors
.
pincode
&&
touched
.
pincode
&&
<
span
className
=
"form-error"
>
{
errors
.
pincode
}
<
/span>
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
Country
<
/label
>
<
label
>
Country
<
/label
>
<
select
<
input
type
=
"text"
name
=
"country"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
country
}
/
>
id
=
"country"
{
errors
.
country
&&
touched
.
country
&&
<
span
className
=
"form-error"
>
{
errors
.
country
}
<
/span>
}
name
=
"country"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
>
<
option
value
=
"India"
>
India
<
/option
>
<
option
value
=
"America"
>
America
<
/option
>
<
/select
>
{
errors
.
country
&&
touched
.
country
&&
(
<
span
className
=
"form-error"
>
{
errors
.
country
}
<
/span>
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -239,31 +256,15 @@ const BusinessDetails = () => {
...
@@ -239,31 +256,15 @@ const BusinessDetails = () => {
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
State
<
/label
>
<
label
>
State
<
/label
>
<
select
<
input
type
=
"text"
name
=
"state"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
state
}
/
>
id
=
"state"
{
errors
.
state
&&
touched
.
state
&&
<
span
className
=
"form-error"
>
{
errors
.
state
}
<
/span>
}
name
=
"state"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
>
<
option
value
=
"India"
>
India
<
/option
>
<
option
value
=
"America"
>
America
<
/option
>
<
/select
>
{
errors
.
state
&&
touched
.
state
&&
(
<
span
className
=
"form-error"
>
{
errors
.
state
}
<
/span>
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
City
<
/label
>
<
label
>
City
<
/label
>
<
select
<
input
type
=
"text"
name
=
"city"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
city
}
/
>
id
=
"city"
{
errors
.
city
&&
touched
.
city
&&
<
span
className
=
"form-error"
>
{
errors
.
city
}
<
/span>
}
name
=
"city"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
>
<
option
value
=
"India"
>
India
<
/option
>
<
option
value
=
"America"
>
America
<
/option
>
<
/select
>
{
errors
.
city
&&
touched
.
city
&&
(
<
span
className
=
"form-error"
>
{
errors
.
city
}
<
/span>
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -271,27 +272,15 @@ const BusinessDetails = () => {
...
@@ -271,27 +272,15 @@ const BusinessDetails = () => {
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
Address
Line
1
<
/label
>
<
label
>
Address
Line
1
<
/label
>
<
input
<
input
type
=
"text"
name
=
"addressLine1"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
addressLine1
}
/
>
type
=
"text"
{
errors
.
addressLine1
&&
touched
.
addressLine1
&&
<
span
className
=
"form-error"
>
{
errors
.
addressLine1
}
<
/span>
}
name
=
"addressLine1"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
addressLine1
}
/
>
{
errors
.
addressLine1
&&
touched
.
addressLine1
&&
(
<
span
className
=
"form-error"
>
{
errors
.
addressLine1
}
<
/span>
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"col-12 offset-lg-1 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
label
>
Address
Line
2
<
/label
>
<
label
>
Address
Line
2
<
/label
>
<
input
<
input
type
=
"text"
name
=
"addressLine2"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
addressLine2
}
/
>
type
=
"text"
{
errors
.
addressLine2
&&
touched
.
addressLine2
&&
<
span
className
=
"form-error"
>
{
errors
.
addressLine2
}
<
/span>
}
name
=
"addressLine2"
onChange
=
{
handleChange
}
onBlur
=
{
handleBlur
}
value
=
{
values
.
addressLine2
}
/
>
{
errors
.
addressLine2
&&
touched
.
addressLine2
&&
(
<
span
className
=
"form-error"
>
{
errors
.
addressLine2
}
<
/span>
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
...
@@ -299,7 +288,7 @@ const BusinessDetails = () => {
...
@@ -299,7 +288,7 @@ const BusinessDetails = () => {
<
div
className
=
"row mt-3 mb-1"
>
<
div
className
=
"row mt-3 mb-1"
>
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"col-12 col-lg-5"
>
<
div
className
=
"input-group"
>
<
div
className
=
"input-group"
>
<
Button
type
=
"submit"
className
=
"btn btn-primary btn-submit"
disabled
>
<
Button
type
=
"submit"
className
=
"btn btn-primary btn-submit"
>
Send
for
Approval
Send
for
Approval
<
/Button
>
<
/Button
>
<
/div
>
<
/div
>
...
@@ -340,8 +329,8 @@ const BusinessDetails = () => {
...
@@ -340,8 +329,8 @@ const BusinessDetails = () => {
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/Fragment
>
<
/Fragment
>
)
);
}
}
;
export
default
BusinessDetails
;
export
default
BusinessDetails
;
package.json
View file @
9576e68
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
"qs"
:
"^6.11.0"
,
"qs"
:
"^6.11.0"
,
"react"
:
"18.2.0"
,
"react"
:
"18.2.0"
,
"react-bootstrap"
:
"^2.5.0"
,
"react-bootstrap"
:
"^2.5.0"
,
"react-bootstrap-typeahead"
:
"^6.
0.0
"
,
"react-bootstrap-typeahead"
:
"^6.
3.2
"
,
"react-datepicker"
:
"^4.8.0"
,
"react-datepicker"
:
"^4.8.0"
,
"react-dom"
:
"18.2.0"
,
"react-dom"
:
"18.2.0"
,
"react-icons"
:
"^5.0.1"
,
"react-icons"
:
"^5.0.1"
,
...
...
pages/api/auth/[...nextauth].js
View file @
9576e68
...
@@ -37,15 +37,13 @@ export default NextAuth({
...
@@ -37,15 +37,13 @@ export default NextAuth({
* We can expect it contains two properties: `email` and `password`
* We can expect it contains two properties: `email` and `password`
*/
*/
try
{
try
{
const
{
const
userResponse
=
await
axios
.
post
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/auth/local`
,
{
data
:
{
user
,
jwt
}
}
=
await
axios
.
post
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/auth/local`
,
{
identifier
:
email
,
identifier
:
email
,
password
:
password
password
:
password
});
});
// console.log("Axios login returned with data:");
// console.log("Axios login returned with data:");
// console.log(user
);
console
.
log
(
"userResponse"
,
userResponse
.
data
);
// console.log(jwt);
// console.log(jwt);
// Response from the above call can be
// Response from the above call can be
...
@@ -75,7 +73,7 @@ export default NextAuth({
...
@@ -75,7 +73,7 @@ export default NextAuth({
// }
// }
// }
// }
return
{
...
user
,
name
:
user
.
username
,
jwt
};
return
{
...
user
Response
.
data
.
user
,
name
:
userResponse
.
data
.
user
.
email
,
jwt
:
userResponse
.
data
.
jwt
,
email
:
userResponse
.
data
.
user
.
email
,
user
:
userResponse
.
data
.
user
};
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
"Error while fetching credentials:"
);
console
.
log
(
"Error while fetching credentials:"
);
console
.
log
(
error
.
response
.
data
);
console
.
log
(
error
.
response
.
data
);
...
@@ -89,6 +87,8 @@ export default NextAuth({
...
@@ -89,6 +87,8 @@ export default NextAuth({
],
],
callbacks
:
{
callbacks
:
{
session
:
async
({
session
,
token
})
=>
{
session
:
async
({
session
,
token
})
=>
{
console
.
log
(
"session 1"
,
session
);
console
.
log
(
"session 2"
,
token
);
session
.
id
=
token
.
id
;
session
.
id
=
token
.
id
;
session
.
jwt
=
token
.
jwt
;
session
.
jwt
=
token
.
jwt
;
...
@@ -98,6 +98,9 @@ export default NextAuth({
...
@@ -98,6 +98,9 @@ export default NextAuth({
return
Promise
.
resolve
(
session
);
return
Promise
.
resolve
(
session
);
},
},
jwt
:
async
({
token
,
user
})
=>
{
jwt
:
async
({
token
,
user
})
=>
{
console
.
log
(
"user 1"
,
user
);
console
.
log
(
"token 1"
,
token
);
const
isSignIn
=
user
?
true
:
false
;
const
isSignIn
=
user
?
true
:
false
;
if
(
isSignIn
)
{
if
(
isSignIn
)
{
token
.
id
=
user
.
id
;
token
.
id
=
user
.
id
;
...
...
redux/actions/userActions.js
View file @
9576e68
...
@@ -35,11 +35,12 @@ export const registerUser = userData => async dispatch => {
...
@@ -35,11 +35,12 @@ export const registerUser = userData => async dispatch => {
};
};
const
userFormData
=
new
FormData
();
const
userFormData
=
new
FormData
();
userFormData
.
append
(
"username"
,
userData
.
mobile
);
userFormData
.
append
(
"username"
,
`
${
userData
.
mobile
}
-
${
userData
.
email
}
`
);
userFormData
.
append
(
"email"
,
userData
.
email
);
userFormData
.
append
(
"email"
,
userData
.
email
);
userFormData
.
append
(
"password"
,
userData
.
password
);
userFormData
.
append
(
"password"
,
userData
.
password
);
userFormData
.
append
(
"role"
,
userData
.
role
);
userFormData
.
append
(
"role"
,
userData
.
role
);
userFormData
.
append
(
"phone"
,
userData
.
mobile
);
console
.
log
(
"userFormData"
,
userFormData
);
const
response
=
await
axios
.
post
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/auth/local/register`
,
userFormData
,
config
);
const
response
=
await
axios
.
post
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/auth/local/register`
,
userFormData
,
config
);
console
.
log
(
`Register user done:`
);
console
.
log
(
`Register user done:`
);
...
...
redux/actions/vendorActions.js
View file @
9576e68
import
axios
from
"axios"
;
import
axios
from
"axios"
;
import
{
getSession
}
from
"next-auth/react"
;
import
qs
from
"qs"
;
import
{
GET_LOGGED_IN_VENDOR_FAIL
,
GET_LOGGED_IN_VENDOR_REQUEST
,
GET_LOGGED_IN_VENDOR_SUCCESS
,
UPDATE_VENDOR_DETAILS_FAIL
,
UPDATE_VENDOR_DETAILS_REQUEST
,
UPDATE_VENDOR_DETAILS_SUCCESS
}
from
"../constants/vendorConstants"
;
export
const
finishVendorOtpVerification
=
async
verificationData
=>
{
export
const
finishVendorOtpVerification
=
async
verificationData
=>
{
const
config
=
{
const
config
=
{
...
@@ -9,3 +19,109 @@ export const finishVendorOtpVerification = async verificationData => {
...
@@ -9,3 +19,109 @@ export const finishVendorOtpVerification = async verificationData => {
return
await
axios
.
post
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/vendor/finish-otp-verification`
,
verificationData
,
config
);
return
await
axios
.
post
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/vendor/finish-otp-verification`
,
verificationData
,
config
);
};
};
export
const
pincodeSearchByFilter
=
async
code
=>
{
const
config
=
{
headers
:
{
"Content-Type"
:
"application/json"
}
};
const
query
=
{
filters
:
{
name
:
{
$contains
:
code
}
},
populate
:
[
"masterCity"
]
};
const
queryString
=
qs
.
stringify
(
query
,
{
encodeValuesOnly
:
true
});
return
await
axios
.
get
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/master-pincodes?
${
queryString
}
`
,
config
);
};
export
const
updateVendorBusinessDetails
=
({
businessDetails
,
vendorId
})
=>
async
dispatch
=>
{
const
session
=
await
getSession
();
if
(
!
session
)
{
throw
new
Error
(
"You are not authenticated. Please log in."
);
}
try
{
dispatch
({
type
:
UPDATE_VENDOR_DETAILS_REQUEST
});
const
config
=
{
headers
:
{
"Content-Type"
:
"application/json"
,
Authorization
:
`Bearer
${
session
.
jwt
}
`
}
};
const
response
=
await
axios
.
put
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/vendors/
${
vendorId
}
`
,
{
businessDetails
},
config
);
dispatch
({
type
:
UPDATE_VENDOR_DETAILS_SUCCESS
});
}
catch
(
error
)
{
dispatch
({
type
:
UPDATE_VENDOR_DETAILS_FAIL
});
}
};
export
const
getLoggedInVendor
=
()
=>
async
dispatch
=>
{
const
session
=
await
getSession
();
console
.
log
(
"session"
,
session
);
if
(
!
session
)
{
throw
new
Error
(
"You are not authenticated. Please log in."
);
}
try
{
dispatch
({
type
:
GET_LOGGED_IN_VENDOR_REQUEST
});
const
config
=
{
headers
:
{
"Content-Type"
:
"application/json"
,
Authorization
:
`Bearer
${
session
.
jwt
}
`
}
};
const
query
=
{
filters
:
{
user
:
{
$eq
:
session
.
id
}
}
};
const
queryString
=
qs
.
stringify
(
query
,
{
encodeValuesOnly
:
true
});
const
response
=
await
axios
.
get
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/vendors/
${
queryString
}
`
,
config
);
console
.
log
(
"response"
,
response
.
data
);
dispatch
({
type
:
GET_LOGGED_IN_VENDOR_SUCCESS
});
}
catch
(
error
)
{
dispatch
({
type
:
GET_LOGGED_IN_VENDOR_FAIL
});
}
};
redux/constants/vendorConstants.js
View file @
9576e68
// export const FETCH_OTP_VERIFY_REQUEST = "FETCH_OTP_VERIFY
_REQUEST"
export
const
GET_LOGGED_IN_VENDOR_REQUEST
=
"GET_LOGGED_IN_VENDOR
_REQUEST"
// export const FETCH_OTP_VERIFY_SUCCESS = "FETCH_OTP_VERIFY
_SUCCESS"
export
const
GET_LOGGED_IN_VENDOR_SUCCESS
=
"GET_LOGGED_IN_VENDOR
_SUCCESS"
// export const FETCH_OTP_VERIFY_FAIL = "FETCH_OTP_VERIFY
_FAIL"
export
const
GET_LOGGED_IN_VENDOR_FAIL
=
"GET_LOGGED_IN_VENDOR
_FAIL"
// export const CLEAR_ERRORS = "CLEAR_ERRORS";
\ No newline at end of file
\ No newline at end of file
export
const
UPDATE_VENDOR_DETAILS_REQUEST
=
"UPDATE_VENDOR_DETAILS_REQUEST"
export
const
UPDATE_VENDOR_DETAILS_SUCCESS
=
"UPDATE_VENDOR_DETAILS_SUCCESS"
export
const
UPDATE_VENDOR_DETAILS_FAIL
=
"UPDATE_VENDOR_DETAILS_FAIL"
export
const
CLEAR_ERRORS
=
"CLEAR_ERRORS"
;
\ No newline at end of file
\ No newline at end of file
redux/reducers/vendorReducers.js
View file @
9576e68
import
{
UPDATE_VENDOR_DETAILS_FAIL
,
UPDATE_VENDOR_DETAILS_REQUEST
,
UPDATE_VENDOR_DETAILS_SUCCESS
,
CLEAR_ERRORS
}
from
"../constants/vendorConstants"
;
export
const
updateVendorReducer
=
(
state
=
{},
action
)
=>
{
switch
(
action
.
type
)
{
case
UPDATE_VENDOR_DETAILS_REQUEST
:
return
{
loading
:
true
};
case
UPDATE_VENDOR_DETAILS_SUCCESS
:
return
{
loading
:
false
,
updatedVendorData
:
action
.
payload
};
case
UPDATE_VENDOR_DETAILS_FAIL
:
return
{
loading
:
false
,
error
:
action
.
payload
.
error
.
message
};
case
CLEAR_ERRORS
:
return
{
...
state
,
error
:
null
};
default
:
return
state
;
}
};
yarn.lock
View file @
9576e68
This diff could not be displayed because it is too large.
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment