Commit 9576e68a by jay

vendor sign in, otp, business details

1 parent edc08403
...@@ -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 { useDispatch, useSelector } 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,52 +25,63 @@ const Header = () => { ...@@ -17,52 +25,63 @@ 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="#">
<span className="image-container"> <span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/Zango-logo.svg" /> <Image layout="fill" alt="" className="image img-fluid" src="/images/Zango-logo.svg" />
</span> </span>
</Navbar.Brand> </Navbar.Brand>
<Navbar.Toggle aria-controls="navbarScroll" /> <Navbar.Toggle aria-controls="navbarScroll" />
<Navbar.Collapse id="navbarScroll"> <Navbar.Collapse id="navbarScroll">
<Nav className=" my-2 my-lg-0" style={{ maxHeight: "100px" }} navbarScroll> <Nav className=" my-2 my-lg-0" style={{ maxHeight: "100px" }} navbarScroll>
<Nav.Link href="#action1">Blogs</Nav.Link> <Nav.Link href="#action1">Blogs</Nav.Link>
<Nav.Link href="#action2" className="gift-card"> <Nav.Link href="#action2" className="gift-card">
Gift Card Gift Card
<span className="image-container">
<Image layout="fill" className="image img-fluid" src="/images/icons/gift-card-icon.svg" alt="" />
</span>
</Nav.Link>
</Nav>
<Form className="d-flex me-3">
<div className="header-search">
<Form.Control type="search" placeholder="Search" className="me-2" aria-label="Search" />
<Button className="search-icon" variant="outline-success">
<span className="image-container"> <span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/search-icon.svg" /> <Image layout="fill" className="image img-fluid" src="/images/icons/gift-card-icon.svg" alt="" />
</span> </span>
</Button> </Nav.Link>
</div> </Nav>
</Form> <Form className="d-flex me-3">
<Button className="me-3" variant="primary"> <div className="header-search">
Sign Up <Form.Control type="search" placeholder="Search" className="me-2" aria-label="Search" />
</Button> <Button className="search-icon" variant="outline-success">
<Button className="" variant="primary"> <span className="image-container">
Log In <Image layout="fill" alt="" className="image img-fluid" src="/images/icons/search-icon.svg" />
</Button> </span>
</Navbar.Collapse> </Button>
</Container> </div>
</Navbar> </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">
Sign Up
</Button>
<Button className="" variant="primary">
Log In
</Button>
</div>
)}
</Navbar.Collapse>
</Container>
</Navbar>
</header> </header>
); );
}; };
......
...@@ -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("Fullname is Required"), fullname: Yup.string().required("Full name is required"),
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>Fullname</label> <label>Full Name</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>
......
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 businessDetailsValidationSchema = Yup.object().shape({ const [session, setSession] = useState(null);
panNumber: Yup.string() const dispatch = useDispatch()
.required("Pan Number is Required"), // const [pincodeData, setPinCodeData] = useState()
panFile: Yup.mixed() // const ref = useRef(null);
.required("Pan Image is Required"),
gstNumber: Yup.string()
.required("GST Number is Required"),
gstCertificateFile: Yup.mixed()
.required("GST Certificate is Required"),
businessName: Yup.string()
.required("Business Name is Required"),
brandLogoFile: Yup.mixed()
.required("Brand Logo 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"),
});
return ( useEffect(() => {
<Fragment> const fetchSession = async () => {
<div className="container p-5"> setSession(await getSession());
<div className="row"> };
<div className="col-12 col-lg-8"> fetchSession();
<div className="content-div business-details"> }, []);
<h2>Tell us about your business</h2> console.log("session", session);
<p>Please have the following ready before you begin</p> const businessDetailsValidationSchema = Yup.object().shape({
<p><FaArrowRight /> Your bank account details for receiving payments from ZanGO</p> panNumber: Yup.string().required("Pan Number is Required"),
<p className="mb-4"><FaArrowRight /> Tax (GST/PAN) details of your business.</p> panFile: Yup.mixed().required("Pan Image is Required"),
<hr /> gstNumber: Yup.string().required("GST Number is Required"),
<div className="form-container mt-4"> gstCertificateFile: Yup.mixed().required("GST Certificate is Required"),
<Formik businessName: Yup.string().required("Business Name is Required"),
initialValues={{ brandLogoFile: Yup.mixed().required("Brand Logo is Required"),
panNumber: "", pincode: Yup.string().required("Pincode is Required"),
panFile: "", country: Yup.string().required("Country is Required"),
gstNumber: "", state: Yup.string().required("State is Required"),
gstCertificateFile: "", city: Yup.string().required("City is Required"),
businessName: "", addressLine1: Yup.string().required("Address Line 1 is Required"),
brandLogoFile: "", addressLine2: Yup.string().required("Address Line 2 is Required")
pincode: "", });
country: "",
state: "", // const handleSearch = async pin => {
city: "", // let pincodeDataSet = await pincodeSearchByFilter(pin);
addressLine1: "", // console.log("pincodeData", pincodeDataSet.data.data);
addressLine2: "" // setPinCodeData(pincodeDataSet.data.data)
}} // };
validationSchema={businessDetailsValidationSchema} return (
// enableReinitialize={true} <Fragment>
onSubmit={values => { <div className="container p-5">
console.log("business details values", values) <div className="row">
<div className="col-12 col-lg-8">
<div className="content-div business-details">
<h2>Tell us about your business</h2>
<p>Please have the following ready before you begin</p>
<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 />
<div className="form-container mt-4">
<Formik
initialValues={{
panNumber: "",
panFile: "",
gstNumber: "",
gstCertificateFile: "",
businessName: "",
brandLogoFile: "",
pincode: "",
country: "",
state: "",
city: "",
addressLine1: "",
addressLine2: ""
}}
validationSchema={businessDetailsValidationSchema}
// enableReinitialize={true}
onSubmit={async 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 }) => (
<Form
onSubmit={e => {
e.preventDefault();
handleSubmit();
}}
>
<h4>Vendor Business Information</h4>
<div className="mt-3">
<p className="textH">Business documents</p>
<div className="row">
<div className="col-12 col-lg-5">
<div className="input-group">
<label>Enter Business PAN No.</label>
<input type="text" name="panNumber" onChange={handleChange} onBlur={handleBlur} value={values.panNumber} />
{errors.panNumber && touched.panNumber && <span className="form-error">{errors.panNumber}</span>}
</div>
</div>
<div className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>Upload PAN</label>
<div className="custom-file">
<input
type="file"
className="custom-file-input"
id="panFile"
name="panFile"
onChange={event => {
if (event) {
const file = event.currentTarget.files[0];
setFieldValue("panFile", file);
}
}}
onBlur={handleBlur}
// value={values.panFile}
onClick={event => {
const { target = {} } = event || {};
target.value = "";
}}
/>
<label className="custom-file-label" htmlFor="panFile">
Upload
</label>
</div>
<p className="textS">Upload in .PNG or .JPG/JPEG format</p>
{errors.panFile && touched.panFile && <span className="form-error">{errors.panFile}</span>}
{values.panFile && (
<div className="d-flex align-items-center justify-content-between p-1" style={{ width: "100%" }}>
<p className="textS m-0">{values.panFile.name}</p>
<FaTimes
style={{ cursor: "pointer" }}
onClick={() => {
setFieldValue("panFile", "");
}} }}
> />
{({ values, errors, touched, handleChange, handleBlur, handleSubmit, setFieldValue }) => ( </div>
<Form )}
onSubmit={e => { </div>
e.preventDefault(); </div>
handleSubmit(); </div>
}} <div className="row">
> <div className="col-12 col-lg-5">
<h4>Vendor Business Information</h4> <div className="input-group">
<div className="mt-3"> <label>GST Number</label>
<p className="textH">Business documents</p> <input type="text" name="gstNumber" onChange={handleChange} onBlur={handleBlur} value={values.gstNumber} />
<div className="row"> {errors.gstNumber && touched.gstNumber && <span className="form-error">{errors.gstNumber}</span>}
<div className="col-12 col-lg-5"> </div>
<div className="input-group"> </div>
<label>Enter Business PAN No.</label> <div className="col-12 offset-lg-1 col-lg-5">
<input <div className="input-group">
type="text" <label>GST Certificate</label>
name="panNumber" <div className="custom-file">
onChange={handleChange} <input
onBlur={handleBlur} type="file"
value={values.panNumber} className="custom-file-input"
/> id="gstCertificateFile"
{errors.panNumber && touched.panNumber && (<span className="form-error">{errors.panNumber}</span>)} name="gstCertificateFile"
</div> onChange={handleChange}
</div> onBlur={handleBlur}
<div className="col-12 offset-lg-1 col-lg-5"> value={values.gstCertificateFile}
<div className="input-group"> />
<label>Upload PAN</label> <label className="custom-file-label" htmlFor="gstCertificateFile">
<div className="custom-file"> Upload
<input </label>
type="file" </div>
className="custom-file-input" <p className="textS">Upload in .PNG or .JPG/JPEG format</p>
id="panFile" {errors.gstCertificateFile && touched.gstCertificateFile && <span className="form-error">{errors.gstCertificateFile}</span>}
name="panFile" </div>
onChange={(event) => { </div>
if (event) { </div>
const file = event.currentTarget.files[0] <div className="row">
setFieldValue("panFile", file) <div className="col-12 col-lg-5">
} <div className="input-group">
}} <label>Business Name</label>
onBlur={handleBlur} <input type="text" name="businessName" onChange={handleChange} onBlur={handleBlur} value={values.businessName} />
// value={values.panFile} {errors.businessName && touched.businessName && <span className="form-error">{errors.businessName}</span>}
onClick={event => { </div>
const { target = {} } = event || {}; </div>
target.value = ""; <div className="col-12 offset-lg-1 col-lg-5">
}} <div className="input-group">
/> <label>Brand Logo</label>
<label className="custom-file-label" htmlFor="panFile"> <div className="custom-file">
Upload <input
</label> type="file"
</div> className="custom-file-input"
<p className="textS">Upload in .PNG or .JPG/JPEG format</p> id="brandLogoFile"
{errors.panFile && touched.panFile && (<span className="form-error">{errors.panFile}</span>)} name="brandLogoFile"
{values.panFile && ( onChange={handleChange}
<div className="d-flex align-items-center justify-content-between p-1" style={{ width: "100%" }}> onBlur={handleBlur}
<p className="textS m-0">{values.panFile.name}</p> value={values.brandLogoFile}
<FaTimes style={{ cursor: "pointer" }} onClick={() => { />
setFieldValue("panFile", "") <label className="custom-file-label" htmlFor="brandLogoFile">
}} /> Upload
</div> </label>
)} </div>
</div> <p className="textS">Upload in .PNG or .JPG/JPEG format</p>
</div> {errors.brandLogoFile && touched.brandLogoFile && <span className="form-error">{errors.brandLogoFile}</span>}
</div>
<div className="row">
<div className="col-12 col-lg-5">
<div className="input-group">
<label>GST Number</label>
<input
type="text"
name="gstNumber"
onChange={handleChange}
onBlur={handleBlur}
value={values.gstNumber}
/>
{errors.gstNumber && touched.gstNumber && (<span className="form-error">{errors.gstNumber}</span>)}
</div>
</div>
<div className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>GST Certificate</label>
<div className="custom-file">
<input
type="file"
className="custom-file-input"
id="gstCertificateFile"
name="gstCertificateFile"
onChange={handleChange}
onBlur={handleBlur}
value={values.gstCertificateFile}
/>
<label className="custom-file-label" htmlFor="gstCertificateFile">
Upload
</label>
</div>
<p className="textS">Upload in .PNG or .JPG/JPEG format</p>
{errors.gstCertificateFile && touched.gstCertificateFile && (<span className="form-error">{errors.gstCertificateFile}</span>)}
</div>
</div>
</div>
<div className="row">
<div className="col-12 col-lg-5">
<div className="input-group">
<label>Business Name</label>
<input
type="text"
name="businessName"
onChange={handleChange}
onBlur={handleBlur}
value={values.businessName}
/>
{errors.businessName && touched.businessName && (<span className="form-error">{errors.businessName}</span>)}
</div>
</div>
<div className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>Brand Logo</label>
<div className="custom-file">
<input
type="file"
className="custom-file-input"
id="brandLogoFile"
name="brandLogoFile"
onChange={handleChange}
onBlur={handleBlur}
value={values.brandLogoFile}
/>
<label className="custom-file-label" htmlFor="brandLogoFile">
Upload
</label>
</div>
<p className="textS">Upload in .PNG or .JPG/JPEG format</p>
{errors.brandLogoFile && touched.brandLogoFile && (<span className="form-error">{errors.brandLogoFile}</span>)}
</div>
</div>
</div>
</div>
<hr />
<div className="mt-4">
<p className="textH">Business Address</p>
<div className="row">
<div className="col-12 col-lg-5">
<div className="input-group">
<label>Pincode</label>
<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 className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>Country</label>
<select
id="country"
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 className="row">
<div className="col-12 col-lg-5">
<div className="input-group">
<label>State</label>
<select
id="state"
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 className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>City</label>
<select
id="city"
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 className="row">
<div className="col-12 col-lg-5">
<div className="input-group">
<label>Address Line 1</label>
<input
type="text"
name="addressLine1"
onChange={handleChange}
onBlur={handleBlur}
value={values.addressLine1}
/>
{errors.addressLine1 && touched.addressLine1 && (<span className="form-error">{errors.addressLine1}</span>)}
</div>
</div>
<div className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>Address Line 2</label>
<input
type="text"
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 className="row mt-3 mb-1">
<div className="col-12 col-lg-5">
<div className="input-group">
<Button type="submit" className="btn btn-primary btn-submit" disabled>
Send for Approval
</Button>
</div>
</div>
</div>
</Form>
)}
</Formik>
</div> </div>
</div>
</div> </div>
</div> </div>
<div className="col-12 col-lg-4"> <hr />
<div className="content-div help-center"> <div className="mt-4">
<h2>Help Center</h2> <p className="textH">Business Address</p>
<ul className="helplist"> <div className="row">
<li> <div className="col-12 col-lg-5">
<Image alt="" src="/images/vendor/question.svg" width="22" height="22" /> <div className="input-group">
<p>Lorem Ipsum Dolor Sit?</p> <label>Pincode</label>
</li> {/* <AsyncTypeahead
<li> onSearch={handleSearch}
<Image alt="" src="/images/vendor/question.svg" width="22" height="22" /> minLength={3}
<p>Lorem Ipsum Dolor Sit?</p> value={values.pincode}
</li> id="basic-behaviors-example"
<li> labelKey="name"
<Image alt="" src="/images/vendor/question.svg" width="22" height="22" /> options={pincodeData && pincodeData.length>0 && pincodeData.map(item=>{
<p>Lorem Ipsum Dolor Sit?</p> return {name: item.attributes.name, id: item.id}
</li> })}
<li> placeholder="Choose a state..."
<Image alt="" src="/images/vendor/question.svg" width="22" height="22" /> ref={ref}
<p>Lorem Ipsum Dolor Sit?</p> onBlur={() => {
</li> console.log(ref.current);
<li> if (!ref.current.state.selected.length > 0) {
<Image alt="" src="/images/vendor/call.svg" width="32" height="32" /> ref.current?.clear();
<p>+1 (407) 8798 789</p> }
</li> }}
</ul> 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 className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>Country</label>
<input type="text" name="country" onChange={handleChange} onBlur={handleBlur} value={values.country} />
{errors.country && touched.country && <span className="form-error">{errors.country}</span>}
</div>
</div>
</div>
<div className="row">
<div className="col-12 col-lg-5">
<div className="input-group">
<label>State</label>
<input type="text" name="state" onChange={handleChange} onBlur={handleBlur} value={values.state} />
{errors.state && touched.state && <span className="form-error">{errors.state}</span>}
</div>
</div>
<div className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>City</label>
<input type="text" name="city" onChange={handleChange} onBlur={handleBlur} value={values.city} />
{errors.city && touched.city && <span className="form-error">{errors.city}</span>}
</div>
</div>
</div> </div>
</div> <div className="row">
</div> <div className="col-12 col-lg-5">
<div className="input-group">
<label>Address Line 1</label>
<input type="text" name="addressLine1" onChange={handleChange} onBlur={handleBlur} value={values.addressLine1} />
{errors.addressLine1 && touched.addressLine1 && <span className="form-error">{errors.addressLine1}</span>}
</div>
</div>
<div className="col-12 offset-lg-1 col-lg-5">
<div className="input-group">
<label>Address Line 2</label>
<input type="text" 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 className="row mt-3 mb-1">
<div className="col-12 col-lg-5">
<div className="input-group">
<Button type="submit" className="btn btn-primary btn-submit">
Send for Approval
</Button>
</div>
</div>
</div>
</Form>
)}
</Formik>
</div>
</div>
</div>
<div className="col-12 col-lg-4">
<div className="content-div help-center">
<h2>Help Center</h2>
<ul className="helplist">
<li>
<Image alt="" src="/images/vendor/question.svg" width="22" height="22" />
<p>Lorem Ipsum Dolor Sit?</p>
</li>
<li>
<Image alt="" src="/images/vendor/question.svg" width="22" height="22" />
<p>Lorem Ipsum Dolor Sit?</p>
</li>
<li>
<Image alt="" src="/images/vendor/question.svg" width="22" height="22" />
<p>Lorem Ipsum Dolor Sit?</p>
</li>
<li>
<Image alt="" src="/images/vendor/question.svg" width="22" height="22" />
<p>Lorem Ipsum Dolor Sit?</p>
</li>
<li>
<Image alt="" src="/images/vendor/call.svg" width="32" height="32" />
<p>+1 (407) 8798 789</p>
</li>
</ul>
</div> </div>
</Fragment > </div>
) </div>
} </div>
</Fragment>
);
};
export default BusinessDetails;
\ No newline at end of file \ No newline at end of file
export default BusinessDetails;
...@@ -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",
......
...@@ -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 { ...userResponse.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;
......
...@@ -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:`);
......
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
});
}
};
// 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
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;
}
};
This diff could not be displayed because it is too large.
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!