From 5d05da30caa33c36d04f346a2bbe6897ec8cdd03 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Sat, 30 Nov 2024 09:39:12 +0100 Subject: [PATCH] no cache handler added --- src/components/AuthPages/AuthLayout2.jsx | 2 +- src/components/AuthPages/SignUp/index2.jsx | 11 ++-- src/components/Home/FamilyDash.jsx | 31 +++++----- src/components/Home/index.jsx | 2 - src/components/Partials/Default.jsx | 12 ++-- src/middleware/AuthRoute.jsx | 23 ++++--- src/views/SignupPageTwo.jsx | 71 +++++++++++++++++++++- 7 files changed, 111 insertions(+), 41 deletions(-) diff --git a/src/components/AuthPages/AuthLayout2.jsx b/src/components/AuthPages/AuthLayout2.jsx index 62815de..b9e5440 100644 --- a/src/components/AuthPages/AuthLayout2.jsx +++ b/src/components/AuthPages/AuthLayout2.jsx @@ -5,7 +5,7 @@ import WrenchBoard from "../../assets/images/wrenchboard-logo-text.png"; import DarkModeContext from "../Contexts/DarkModeContext"; -export default function LoginLayout({ slogan, children }) { +export default function AuthLayout2({ slogan, children }) { // const bgImg = localImgLoad("images/left-wrenchboard.jpg"); const bgImgNig = localImgLoad("images/wrench-home-back-nigeria.jpg"); const bgImgCom = localImgLoad("images/wrench-home-back-common.jpg"); diff --git a/src/components/AuthPages/SignUp/index2.jsx b/src/components/AuthPages/SignUp/index2.jsx index 0c408b2..a15a891 100644 --- a/src/components/AuthPages/SignUp/index2.jsx +++ b/src/components/AuthPages/SignUp/index2.jsx @@ -8,7 +8,7 @@ import AuthLayout from "../AuthLayout2"; import GoogleDownload from '../../../assets/images/download/andriod.jpg' import IOSDownload from '../../../assets/images/download/apple.jpg' -export default function SignUp() { +export default function SignUp({details}) { const location = useLocation(); // eslint-disable-next-line no-restricted-globals @@ -28,9 +28,9 @@ export default function SignUp() { const [formData, setFormData] = useState({ country: country ? country : "", - first_name: "", - last_name: "", - email: "", + first_name: details ? details.first_name : "", + last_name: details ? details.last_name : "", + email: details ? details.email : "", password: "", }); @@ -202,6 +202,7 @@ export default function SignUp() { type="text" value={formData.first_name} inputHandler={handleInputChange} + disable={details.first_name} />
@@ -213,6 +214,7 @@ export default function SignUp() { type="text" value={formData.last_name} inputHandler={handleInputChange} + disable={details.last_name} />
@@ -225,6 +227,7 @@ export default function SignUp() { type="email" value={formData.email} inputHandler={handleInputChange} + disable={details.email} />
diff --git a/src/components/Home/FamilyDash.jsx b/src/components/Home/FamilyDash.jsx index 98181b5..7da6a3e 100644 --- a/src/components/Home/FamilyDash.jsx +++ b/src/components/Home/FamilyDash.jsx @@ -8,16 +8,13 @@ import { tableReload } from "../../store/TableReloads"; import LoadingSpinner from "../Spinners/LoadingSpinner"; import HomeModal from "./HomeModal"; -export default function FamilyDash({ MyActiveJobList=[], serverImg }) { - // console.log("PROPS IN FAMILY DASH->", familyOffers?.result_list); +export default function FamilyDash() { const dispatch = useDispatch(); const [firstTimeModal, setFirstTimeModal] = useState(true) const userApi = new usersService(); - - // const trending = MyActiveJobList; const { familyBannersList } = useSelector((state) => state.familyBannersList); @@ -25,21 +22,21 @@ export default function FamilyDash({ MyActiveJobList=[], serverImg }) { const { userDetails } = useSelector((state) => state?.userDetails); - let [reloadBanner, setReloadBanner] = useState(0) + // let [reloadBanner, setReloadBanner] = useState(0) - useEffect(()=>{ - if(reloadBanner >= 2){ - dispatch(tableReload({ type: "FAMILYBANNERSLIST" })); // RELOAD FAMILY BANNERS LIST EVERY 10 MINS - setReloadBanner(0) - } - const timer = setInterval(()=>{ - setReloadBanner(prev => prev+1) - },300000) + // useEffect(()=>{ + // if(reloadBanner >= 2){ + // dispatch(tableReload({ type: "FAMILYBANNERSLIST" })); // RELOAD FAMILY BANNERS LIST EVERY 10 MINS + // setReloadBanner(0) + // } + // const timer = setInterval(()=>{ + // setReloadBanner(prev => prev+1) + // },300000) - return ()=>{ - clearInterval(timer) - } - },[reloadBanner]) + // return ()=>{ + // clearInterval(timer) + // } + // },[reloadBanner]) return ( <> diff --git a/src/components/Home/index.jsx b/src/components/Home/index.jsx index 38ccd87..22daa93 100644 --- a/src/components/Home/index.jsx +++ b/src/components/Home/index.jsx @@ -28,8 +28,6 @@ export default function Home(props) { {userDetails && userDetails?.account_type == "FAMILY" ? ( ) : userDetails && userDetails?.account_type == "FULL" ? ( <> diff --git a/src/components/Partials/Default.jsx b/src/components/Partials/Default.jsx index bfd5223..4a829db 100644 --- a/src/components/Partials/Default.jsx +++ b/src/components/Partials/Default.jsx @@ -6,6 +6,8 @@ import axios from 'axios' function Default({ children }) { const location = useLocation() + const [nocache, setNoCache] = useState(false) // holds cache/nocache value + // dark mode setup const [theme, setTheme] = useState(null); @@ -16,6 +18,10 @@ function Default({ children }) { const queryParams = new URLSearchParams(location?.search); const country = queryParams.get("cnt")?.toUpperCase(); + const handleThemeSwitch = () => { + setTheme(theme === "dark" ? "light" : "dark"); + }; + const getLocation = () => { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( @@ -58,10 +64,6 @@ function Default({ children }) { } }, [theme]); - const handleThemeSwitch = () => { - setTheme(theme === "dark" ? "light" : "dark"); - }; - useEffect(()=>{ if(country){ setCountryMode(country) @@ -75,7 +77,7 @@ function Default({ children }) { return ( <> - + {children && children} diff --git a/src/middleware/AuthRoute.jsx b/src/middleware/AuthRoute.jsx index 8176f2a..9baf084 100644 --- a/src/middleware/AuthRoute.jsx +++ b/src/middleware/AuthRoute.jsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useState, useContext } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Navigate, Outlet, useNavigate } from "react-router-dom"; import LoadingSpinner from "../components/Spinners/LoadingSpinner"; @@ -15,12 +15,15 @@ import { familyBannersList } from "../store/FamilyBannerList"; import { familyResources } from "../store/FamilyResources"; import {familyWalletRedeemOptList} from '../store/FamilyWalletRedeemOpt' import { SocketValues } from "../components/Contexts/SocketIOContext"; +import DarkModeContext from '../components/Contexts/DarkModeContext' const AuthRoute = ({ redirectPath = "/login", children }) => { let {joinRoom} = SocketValues() // destructures 'SEND MESSAGE' and 'JOIN ROOM' FUNCTIONS FROM SOCKET - const [nocache, setNoCache] = useState(false) // holds cache/nocache value + // const [nocache, setNoCache] = useState(false) // holds cache/nocache value + + const {nocache, setNoCache} = useContext(DarkModeContext); // Destructures nocache and set nocache from context API const apiCall = useMemo(() => new usersService(), []); const dispatch = useDispatch(); @@ -108,7 +111,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { //FUNCTION TO GET COMMON HEAD DATA useEffect(() => { - if((!loggedIn && !isLogin.status) || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY + if((!loggedIn && !isLogin.status) || isLogin.loading || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY return } dispatch(commonHeadBanner({loading:true, data:{}})); @@ -186,7 +189,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { }, []); useEffect(() => { - if((!loggedIn && !isLogin.status) || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY + if((!loggedIn && !isLogin.status) || isLogin.loading || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY return } const getMyJobList = async () => { @@ -207,7 +210,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { //FUNCTION TO GET FULL USER WALLETS useEffect(() => { - if((!loggedIn && !isLogin.status) || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY + if((!loggedIn && !isLogin.status) || isLogin.loading || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY return } const getMyWalletList = async () => { @@ -229,7 +232,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { // FUNCTION TO GET MARKET JOB LIST useEffect(() => { - if((!loggedIn && !isLogin.status) || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY + if((!loggedIn && !isLogin.status) || isLogin.loading || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY return } // Getting market data @@ -248,7 +251,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { //FUNCTION TO GET COMMON HEAD DATA // useEffect(() => { - // if((!loggedIn && !isLogin.status) || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY + // if((!loggedIn && !isLogin.status) || isLogin.loading || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY // return // } // apiCall @@ -268,7 +271,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { //FUNCTION TO GET FAMILY BANNERS useEffect(() => { - if((!loggedIn && !isLogin.status) || account_type == 'FULL'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FULL + if((!loggedIn && !isLogin.status) || isLogin.loading || isLogin.loading || account_type == 'FULL'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FULL return } const getFamilyBanners = async () => { // FUNCTION TO GET FAMILY BANNERS @@ -289,7 +292,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { //FUNCTION TO GET FAMILY RESOURCES useEffect(() => { - if((!loggedIn && !isLogin.status) || account_type == 'FULL'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FULL + if((!loggedIn && !isLogin.status) || isLogin.loading || account_type == 'FULL'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FULL return } const getFamilyResourcesList = async () => { // FUNCTION TO GET FAMILY BANNERS @@ -307,7 +310,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { //FUNCTION TO GET FAMILY WALLET REDEEM OPTIONS useEffect(() => { - if((!loggedIn && !isLogin.status) || account_type == 'FULL'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FULL + if((!loggedIn && !isLogin.status) || isLogin.loading || account_type == 'FULL'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FULL return } const familyWalletRedeemOptions = async () => { // FUNCTION TO GET FAMILY WALLET REDDEM OPTIONS diff --git a/src/views/SignupPageTwo.jsx b/src/views/SignupPageTwo.jsx index f5543d3..1103da7 100644 --- a/src/views/SignupPageTwo.jsx +++ b/src/views/SignupPageTwo.jsx @@ -1,12 +1,79 @@ -import React from "react"; +import React, {useState, useEffect} from "react"; +import { useLocation } from "react-router-dom"; +import usersService from '../services/UsersService' + import SignUp from "../components/AuthPages/SignUp/index2"; +import LoadingSpinner from '../components/Spinners/LoadingSpinner' +import AuthLayout from '../components/AuthPages/AuthLayout2' function SignupPageTwo() { + const api = new usersService() + + const location = useLocation(); + + const queryParams = new URLSearchParams(location?.search); + const refer_link = queryParams.get("refer_link")?.toUpperCase(); + + const [reload, setReload] = useState(false) + + let [details, setDetails] = useState({loading:true, error:false, data:{}}) + + useEffect(()=>{ + setDetails({loading:true, error:false, data:{}}) + if(refer_link){ + // const timer = setTimeout(()=>{ + // setDetails({loading:false, data:{ + // first_name: 'Emeka', + // last_name: 'John', + // email: 'example@example.com' + // }}) + // },[1000]) + api.verifyEmail(refer_link).then(res => { + setDetails({loading:false, error:false, data:{}}) + console.log('RES', rres) + }).catch(err => { + setDetails({loading:false, error:true, data:{}}) + }) + }else{ + setDetails({loading:false, error:false, data:{}}) + } + },[reload]) return ( <> - + {details.loading ? + + : details.error ? + + setReload(prev => !prev)} /> + + : + + } ); } export default SignupPageTwo; + + +const ErrorComponent = ({ onClick }) => ( +
+
+

+ This error occurs because you have already verified this link or the + link has expired. Try login or reset password. If none worked, try to + create the account from the start. +

+
+ +
+ +
+
+); -- 2.34.1