Commit ca21c454 by Jyotsna
2 parents 0a9aece7 7cbeb538
...@@ -2,11 +2,15 @@ import { getSession, signOut } from "next-auth/react"; ...@@ -2,11 +2,15 @@ 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(() => {
...@@ -17,15 +21,15 @@ const Header = () => { ...@@ -17,15 +21,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 +58,33 @@ const Header = () => { ...@@ -54,12 +58,33 @@ const Header = () => {
</Button> </Button>
</div> </div>
</Form> </Form>
{/* {console.log(user.id)} */}
{user && user.id ? (
<div>
<div>
<p>Brand Logo</p>
</div>
<p>{user.phone}</p>
<Button
onClick={() => {
signOut({ redirect: false });
}}
className="me-3"
variant="primary"
>
Log out
</Button>
</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>
......
import React from "react"; import React, { useEffect } from "react";
import Head from "next/head"; import Head from "next/head";
import Header from "./Header"; import Header from "./Header";
import Footer from "./Footer"; import Footer from "./Footer";
import { ToastContainer } from "react-toastify"; import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css"; import "react-toastify/dist/ReactToastify.css";
import { loadUser } from "../../redux/actions/userActions";
import { useDispatch } from "react-redux";
const Layout = ({ children, title = "Zango", description = "" }) => { const Layout = ({ children, title = "Zango", description = "" }) => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(loadUser());
}, []);
return ( return (
<div> <div>
<Head> <Head>
......
...@@ -39,7 +39,7 @@ const ListingInner = () => { ...@@ -39,7 +39,7 @@ const ListingInner = () => {
return ( return (
<> <>
<section className="listing-inner-session"> <section className="listing-inner-session">
<div className="container"> <div className="container-fluid">
<div className="row"> <div className="row">
<div className="col-12"> <div className="col-12">
<div className="filter-dd"> <div className="filter-dd">
......
import React, { useState } from 'react'; import React, { useState } from "react";
import { Formik } from "formik"; import { Formik } from "formik";
import Image from "next/image"; import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
...@@ -6,20 +6,25 @@ import { Fragment } from "react"; ...@@ -6,20 +6,25 @@ import { Fragment } 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 { renderImage } from "../../services/imageHandling"; import { renderImage } from "../../services/imageHandling";
import { useRouter } from "next/router";
import { signIn } from "next-auth/react";
import { toast } from "react-toastify";
import { Loader } from "react-bootstrap-typeahead";
const Login = (props) => { const Login = props => {
const [loading, setLoading] = useState(false);
const loginValidationSchema = Yup.object().shape({ const loginValidationSchema = Yup.object().shape({
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")
}); });
const router = useRouter();
return ( return (
<Fragment> <Fragment>
<div className="contaier-fluid login-banner-image"> <div className="contaier-fluid login-banner-image">
<div className="row"> <div className="row">
<div className="col-11 col-lg-4 login-div"> <div className="col-11 col-lg-4 login-div">
<div className=""> <div className="">
<h2>{props.type=="vendor" ? "Vendor Login" : "Login to Experience"}</h2> <h2>{props.type == "vendor" ? "Vendor Login" : "Login to Experience"}</h2>
<div className="form-container"> <div className="form-container">
<Formik <Formik
initialValues={{ initialValues={{
...@@ -28,8 +33,25 @@ const Login = (props) => { ...@@ -28,8 +33,25 @@ const Login = (props) => {
}} }}
validationSchema={loginValidationSchema} validationSchema={loginValidationSchema}
// enableReinitialize={true} // enableReinitialize={true}
onSubmit={values => { onSubmit={async values => {
console.log("login values",values) setLoading(true);
console.log("login values", values);
const signInResponse = await signIn("credentials", {
email: values.email,
password: values.password,
redirect: false
});
console.log("signInResponse", signInResponse);
if (!signInResponse.ok) {
toast.error(signInResponse.error);
setLoading(false);
return;
}
if (signInResponse.ok) {
setLoading(false);
router.push("/vendor/business-details");
}
// router.push("")
}} }}
> >
{({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => ( {({ values, errors, touched, handleChange, handleBlur, handleSubmit }) => (
...@@ -41,38 +63,29 @@ const Login = (props) => { ...@@ -41,38 +63,29 @@ const Login = (props) => {
> >
<div className="input-group"> <div className="input-group">
<label>Email Id</label> <label>Email Id</label>
<input <input type="text" name="email" onChange={handleChange} onBlur={handleBlur} value={values.email} placeholder="yourname@example.com" />
type="text" {errors.email && touched.email && <span className="form-error">{errors.email}</span>}
name="email"
onChange={handleChange}
onBlur={handleBlur}
value={values.email}
placeholder="yourname@example.com"
/>
{errors.email && touched.email && (<span className="form-error">{errors.email}</span>)}
</div> </div>
<div className="input-group"> <div className="input-group">
<label>Password</label> <label>Password</label>
<input <input type="password" name="password" onChange={handleChange} onBlur={handleBlur} value={values.password} placeholder="#@$!%@#" />
type="text" {errors.password && touched.password && <span className="form-error">{errors.password}</span>}
name="password"
onChange={handleChange}
onBlur={handleBlur}
value={values.password}
placeholder="#@$!%@#"
/>
{errors.password && touched.password && (<span className="form-error">{errors.password}</span>)}
</div> </div>
<div className="input-group"> <div className="input-group">
<Button type="submit" className="btn btn-primary btn-submit"> <Button type="submit" className="btn btn-primary btn-submit" disabled={loading}>
Login {loading ? <Loader /> : "Login"}
</Button> </Button>
</div> </div>
</Form> </Form>
)} )}
</Formik> </Formik>
<div className="input-group justify-content-center"> <div className="input-group justify-content-center">
<p className="text-center mb-0">or <Link href={`../signup/${props.type}`}><span style={{textDecoration:"underline",cursor:"pointer"}}>Create a new account</span></Link></p> <p className="text-center mb-0">
or{" "}
<Link href={`../signup/${props.type}`}>
<span style={{ textDecoration: "underline", cursor: "pointer" }}>Create a new account</span>
</Link>
</p>
</div> </div>
{props && props.type == "user" && ( {props && props.type == "user" && (
<> <>
...@@ -108,7 +121,7 @@ const Login = (props) => { ...@@ -108,7 +121,7 @@ const Login = (props) => {
</div> </div>
</div> </div>
</Fragment> </Fragment>
) );
} };
export default Login; export default Login;
...@@ -13,6 +13,8 @@ import { registerUser } from "../../redux/actions/userActions"; ...@@ -13,6 +13,8 @@ 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";
import { Loader } from "react-bootstrap-typeahead";
const Signup = props => { const Signup = props => {
console.log(props.type); console.log(props.type);
...@@ -35,7 +37,7 @@ const Signup = props => { ...@@ -35,7 +37,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 +76,8 @@ const Signup = props => { ...@@ -74,6 +76,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">
...@@ -124,20 +128,33 @@ const Signup = props => { ...@@ -124,20 +128,33 @@ const Signup = props => {
return; return;
} }
setOtpSent(true); setOtpSent(true);
setLoading(false);
} else { } else {
e.preventDefault(); e.preventDefault();
const oneTimePassword = otp.join(""); const oneTimePassword = otp.join("");
setLoading(false);
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
});
setLoading(false);
console.log("result", result);
router.push("/vendor/business-details");
// toast.success("User registered successflly");
} else if (!otpRes.data.ok) {
setLoading(false);
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>
...@@ -234,8 +251,8 @@ const Signup = props => { ...@@ -234,8 +251,8 @@ const Signup = props => {
</> </>
)} )}
<div className="input-group mb-0"> <div className="input-group mb-0">
<Button type="submit" className="btn btn-primary btn-submit" disabled={!values.termsConditions && !isValid}> <Button type="submit" className="btn btn-primary btn-submit" disabled={(!values.termsConditions && !isValid) || loading}>
{isOtpSent ? "Verify OTP" : "Sign Up Now"} {loading ? <Loader/> : `${isOtpSent ? "Verify OTP" : "Sign Up Now"}`}
</Button> </Button>
</div> </div>
</Form> </Form>
......
...@@ -16,7 +16,7 @@ const nextConfig = { ...@@ -16,7 +16,7 @@ const nextConfig = {
stripePublishableKey: "pk_test_51LeAqWSD8iV80gmAKccLEZAm1mYnjlzkL1cJxWJKFaHEMPzArGRRECPOG64e8GX2Hd112zBq3vQ3xSVb5IZQCRmh00N3DRtRse" stripePublishableKey: "pk_test_51LeAqWSD8iV80gmAKccLEZAm1mYnjlzkL1cJxWJKFaHEMPzArGRRECPOG64e8GX2Hd112zBq3vQ3xSVb5IZQCRmh00N3DRtRse"
}, },
images: { images: {
domains: ["localhost"] domains: ["localhost", "apizango.logicloop.io"]
} }
}; };
......
...@@ -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);
...@@ -87,8 +85,11 @@ export default NextAuth({ ...@@ -87,8 +85,11 @@ export default NextAuth({
} }
}) })
], ],
secret: process.env.NEXTAUTH_SECRET,
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 +99,9 @@ export default NextAuth({ ...@@ -98,6 +99,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;
......
import Home from "../components/home/Home"; import Home from "../components/home/Home";
import Layout from "../components/layout/Layout"; import Layout from "../components/layout/Layout";
import { loadUser } from "../redux/actions/userActions";
import { wrapper } from "../redux/store"; import { wrapper } from "../redux/store";
export default function IndexPage() { export default function IndexPage() {
...@@ -24,7 +25,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r ...@@ -24,7 +25,7 @@ export const getServerSideProps = wrapper.getServerSideProps(store => async ({ r
// Get the menu data. // Get the menu data.
// get the locations data. // get the locations data.
// await store.dispatch(loadUser())
return { return {
props: {}, props: {},
......
import React from "react"; import React, { useEffect } from "react";
import { useDispatch } from "react-redux";
import Layout from "../../../components/layout/Layout"; import Layout from "../../../components/layout/Layout";
import BusinessDetails from "../../../components/vendor/BusinessDetails"; import BusinessDetails from "../../../components/vendor/BusinessDetails";
import { loadUser } from "../../../redux/actions/userActions";
import { getVendorDetails } from "../../../redux/actions/vendorActions";
import { wrapper } from "../../../redux/store";
// import { loadUser } from "../redux/actions/userActions";
// import { wrapper } from "../redux/store";
export default function BusinessDetailsPage () { export default function BusinessDetailsPage () {
const dispatch = useDispatch()
useEffect(() => {
dispatch(getVendorDetails())
}, [])
return ( return (
<Layout> <Layout>
...@@ -10,3 +20,18 @@ export default function BusinessDetailsPage () { ...@@ -10,3 +20,18 @@ export default function BusinessDetailsPage () {
</Layout> </Layout>
); );
}; };
/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// Get the menu data.
// get the locations data.
// await store.dispatch(getVendorDetails())
return {
props: {},
};
});
\ No newline at end of file \ No newline at end of file
...@@ -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,
GET_VENDOR_DETAILS_FAIL,
GET_VENDOR_DETAILS_REQUEST,
GET_VENDOR_DETAILS_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 +22,159 @@ export const finishVendorOtpVerification = async verificationData => { ...@@ -9,3 +22,159 @@ 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}`,
{
data: businessDetails
},
config
);
dispatch({
type: UPDATE_VENDOR_DETAILS_SUCCESS
});
return response.data;
} 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: {
id: { $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.data[0]);
dispatch({
type: GET_LOGGED_IN_VENDOR_SUCCESS
});
return response.data.data[0];
} catch (error) {
dispatch({
type: GET_LOGGED_IN_VENDOR_FAIL
});
}
};
export const getVendorDetails = () => async dispatch => {
const session = await getSession();
try {
dispatch({
type: GET_VENDOR_DETAILS_REQUEST
});
console.log("here 1", session);
const config = {
headers: {
"Content-Type": "Application/json",
Authorization: `Bearer ${session.jwt}`
}
};
console.log("here 2");
if (!session) {
return;
}
const query = {
filters: {
user: {
id: {
$eq: session.id
}
}
},
populate: ["user"]
};
console.log("here 3", query);
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
console.log("session", session, session.id);
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${queryString}`, config);
console.log("response", response);
dispatch({
type: GET_VENDOR_DETAILS_SUCCESS,
payload: response.data.data[0]
});
return response.data.data[0];
} catch (error) {
dispatch({
type: GET_VENDOR_DETAILS_FAIL,
payload: error.response.data
});
}
};
// 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 GET_VENDOR_DETAILS_REQUEST = "GET_VENDOR_DETAILS_REQUEST"
export const GET_VENDOR_DETAILS_SUCCESS = "GET_VENDOR_DETAILS_SUCCESS"
export const GET_VENDOR_DETAILS_FAIL = "GET_VENDOR_DETAILS_FAIL"
export const CLEAR_ERRORS = "CLEAR_ERRORS";
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ import { townshipReducer, townshipsReducer } from "./townshipsReducer"; ...@@ -4,6 +4,7 @@ import { townshipReducer, townshipsReducer } from "./townshipsReducer";
import { authReducer, forgotPasswordReducer, loadedUserReducer, resetPasswordReducer, userReducer } from "./userReducers"; import { authReducer, forgotPasswordReducer, loadedUserReducer, resetPasswordReducer, userReducer } from "./userReducers";
import { enquiryReducer } from "./enquiryReducer"; import { enquiryReducer } from "./enquiryReducer";
import { displayEnquireNowReducer } from "./enquireNowModalReducer"; import { displayEnquireNowReducer } from "./enquireNowModalReducer";
import { getVendorDetailsReducer, loggedInVendorReducer, updateVendorReducer } from "./vendorReducers";
const reducers = combineReducers({ const reducers = combineReducers({
townships: townshipsReducer, townships: townshipsReducer,
...@@ -17,7 +18,10 @@ const reducers = combineReducers({ ...@@ -17,7 +18,10 @@ const reducers = combineReducers({
resetPassword: resetPasswordReducer, resetPassword: resetPasswordReducer,
similarProjects: similarProjectsReducer, similarProjects: similarProjectsReducer,
enquiry: enquiryReducer, enquiry: enquiryReducer,
displayEnquireNow:displayEnquireNowReducer displayEnquireNow:displayEnquireNowReducer,
loggedInVendor: loggedInVendorReducer,
updatedVendorData: updateVendorReducer,
vendorDetails: getVendorDetailsReducer,
}); });
export default reducers; export default reducers;
import { UPDATE_VENDOR_DETAILS_FAIL, UPDATE_VENDOR_DETAILS_REQUEST, UPDATE_VENDOR_DETAILS_SUCCESS, CLEAR_ERRORS, GET_LOGGED_IN_VENDOR_REQUEST, GET_LOGGED_IN_VENDOR_SUCCESS, GET_LOGGED_IN_VENDOR_FAIL, GET_VENDOR_DETAILS_FAIL, GET_VENDOR_DETAILS_SUCCESS, GET_VENDOR_DETAILS_REQUEST } from "../constants/vendorConstants";
// Load user reducer
export const loggedInVendorReducer = (state = { loading: true, success: false, loggedInVendor: null }, action) => {
switch (action.type) {
case GET_LOGGED_IN_VENDOR_REQUEST:
return {
loading: true,
isAuthenticated: false
};
case GET_LOGGED_IN_VENDOR_SUCCESS:
return {
loading: false,
isAuthenticated: true,
loggedInVendor: action.payload
};
case GET_LOGGED_IN_VENDOR_FAIL:
return {
loading: false,
isAuthenticated: true,
error: action.payload.error.message
};
case CLEAR_ERRORS:
return {
...state,
error: null
};
default:
return state;
}
};
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;
}
};
export const getVendorDetailsReducer = (state = { loading: true, success: false, vendorDetails: null }, action) => {
switch (action.type) {
case GET_VENDOR_DETAILS_REQUEST:
return {
loading: true,
isAuthenticated: false
};
case GET_VENDOR_DETAILS_SUCCESS:
return {
loading: false,
isAuthenticated: true,
vendorDetails: action.payload
};
case GET_VENDOR_DETAILS_FAIL:
return {
loading: false,
isAuthenticated: true,
error: action.payload.error.message
};
case CLEAR_ERRORS:
return {
...state,
error: null
};
default:
return state;
}
};
\ No newline at end of file \ No newline at end of file
...@@ -1788,6 +1788,7 @@ footer .subscribe input { ...@@ -1788,6 +1788,7 @@ footer .subscribe input {
padding: 0.6rem; padding: 0.6rem;
color: #fff; color: #fff;
margin-right: 0.5rem; margin-right: 0.5rem;
width: 62%;
} }
footer hr { footer hr {
...@@ -2360,6 +2361,11 @@ footer hr { ...@@ -2360,6 +2361,11 @@ footer hr {
.faqs-session { .faqs-session {
padding: 5rem 0; padding: 5rem 0;
} }
.subscribe label .btn {
font-size: 16px;
padding-left: 1rem;
padding-right: 1rem;
}
......
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!