{props.errors.category &&
props.touched.category &&
diff --git a/src/components/AuthPages/AuthRedirect/Redirect.jsx b/src/components/AuthPages/AuthRedirect/Redirect.jsx
index 4789bb7..607cd60 100644
--- a/src/components/AuthPages/AuthRedirect/Redirect.jsx
+++ b/src/components/AuthPages/AuthRedirect/Redirect.jsx
@@ -1,26 +1,26 @@
-import React, { useEffect } from 'react';
-import { useLocation, useNavigate } from 'react-router-dom';
-import usersService from '../../../services/UsersService';
-import {updateUserDetails} from "../../../store/UserDetails";
+import React, { useEffect } from "react";
import { useDispatch } from "react-redux";
+import { useLocation, useNavigate } from "react-router-dom";
+import usersService from "../../../services/UsersService";
+import { updateUserDetails } from "../../../store/UserDetails";
import AuthLayout from "../AuthLayout";
function Redirect() {
- const location = useLocation();
- const navigate = useNavigate();
- const userApi = new usersService();
- const dispatch = useDispatch()
+ const location = useLocation();
+ const navigate = useNavigate();
+ const userApi = new usersService();
+ const dispatch = useDispatch();
- const queryParams = new URLSearchParams(location?.search);
- const codeResponse = queryParams.get("code");
+ const queryParams = new URLSearchParams(location?.search);
+ const codeResponse = queryParams.get("code");
- useEffect(()=>{
- if(!codeResponse){
- navigate('/login', {state: {error: true}})
- return
- }
- console.log(codeResponse);
- /*
+ useEffect(() => {
+ if (!codeResponse) {
+ navigate("/login", { state: { error: true } });
+ return;
+ }
+ console.log(codeResponse);
+ /*
POST /token HTTP/1.1
Host: oauth2.googleapis.com
Content-Type: application/x-www-form-urlencoded
@@ -31,34 +31,40 @@ function Redirect() {
redirect_uri=https%3A//oauth2.example.com/code&
grant_type=authorization_code
*/
- var reqData = {
- auth_type: "GOOGLE",
- code: codeResponse,
- redirect_uri: process.env.REACT_APP_GOOGLE_REDIRECT_URL,
- };
- userApi
- .authStart(reqData)
- .then((res) => {
- if (res.status == 200 && res.data.internal_return >= 0 && res.data.member_id && res.data.uid && res.data.session) {
- localStorage.setItem("member_id", `${res.data.member_id}`);
- localStorage.setItem("uid", `${res.data.uid}`);
- localStorage.setItem("session_token", `${res.data.session}`);
- dispatch(updateUserDetails({...res.data}));
- navigate('/', {replace: true})
- return
- }
- navigate('/login', {state: {error: true}})
- })
- .catch((error) => {
- navigate('/login', {state: {error: true}})
- console.log(error);
- });
- },[])
+ var reqData = {
+ auth_type: "GOOGLE",
+ code: codeResponse,
+ redirect_uri: process.env.REACT_APP_GOOGLE_REDIRECT_URL,
+ };
+ userApi
+ .authStart(reqData)
+ .then((res) => {
+ if (
+ res.status == 200 &&
+ res.data.internal_return >= 0 &&
+ res.data.member_id &&
+ res.data.uid &&
+ res.data.session
+ ) {
+ localStorage.setItem("member_id", `${res.data.member_id}`);
+ localStorage.setItem("uid", `${res.data.uid}`);
+ localStorage.setItem("session_token", `${res.data.session}`);
+ dispatch(updateUserDetails({ ...res.data }));
+ navigate("/", { replace: true });
+ return;
+ }
+ navigate("/login", { state: { error: true } });
+ })
+ .catch((error) => {
+ navigate("/login", { state: { error: true } });
+ console.log(error);
+ });
+ }, []);
return (
- Redirecting ...
-
- )
+ Redirecting ...
+
+ );
}
-export default Redirect
+export default Redirect;
diff --git a/src/components/MyWallet/Wallet.jsx b/src/components/MyWallet/Wallet.jsx
index a4b1042..4b63383 100644
--- a/src/components/MyWallet/Wallet.jsx
+++ b/src/components/MyWallet/Wallet.jsx
@@ -1,11 +1,4 @@
-import React, {
- Suspense,
- lazy,
- useCallback,
- useEffect,
- useMemo,
- useState,
-} from "react";
+import React, { Suspense, lazy, useEffect, useState } from "react";
import { useSelector } from "react-redux";
import usersService from "../../services/UsersService";
import Layout from "../Partials/Layout";
@@ -38,7 +31,7 @@ const WalletRoutes = () => {
.catch(() => {
setWalletList({ loading: false, data: [] });
});
- }
+ };
const getPaymentHistory = () => {
apiCall
@@ -53,7 +46,7 @@ const WalletRoutes = () => {
.catch(() => {
setPaymentHistory({ loading: false, data: [] });
});
- }
+ };
useEffect(() => {
// const fetchData = async () => {
@@ -63,8 +56,8 @@ const WalletRoutes = () => {
// if (walletList.loading) {
// fetchData();
// }
- getWalletList()
- getPaymentHistory()
+ getWalletList();
+ getPaymentHistory();
}, [walletTable]);
return (
diff --git a/src/components/Partials/Header.jsx b/src/components/Partials/Header.jsx
index 1f5cf83..a489441 100644
--- a/src/components/Partials/Header.jsx
+++ b/src/components/Partials/Header.jsx
@@ -15,6 +15,7 @@ import WalletHeader from "../MyWallet/WalletHeader";
import { useDispatch, useSelector } from "react-redux";
import Flag from "../../assets/images/united-states.svg";
import siteLogo from "../../assets/images/wrenchboard-logo-text.png";
+import { viewWalletDetails } from "../../store/walletDetails";
import TimeDifference from "../Helpers/TimeDifference";
const DEFAULT_PROFILE_IMAGE = require("../../assets/images/profile.jpg");
@@ -38,6 +39,7 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
try {
const res = await api.getUserWallets(null);
console.log("wallet - > ", res.data);
+ dispatch(viewWalletDetails({ ...res.data }));
setMyWalletList(res.data);
} catch (error) {
console.log("Error getting mode");
@@ -104,7 +106,6 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
let userEmail = email?.split("@")[0];
const userProfileImage = profile_pic_url || DEFAULT_PROFILE_IMAGE;
-
return (
<>
diff --git a/src/store/UserDetails.js b/src/store/UserDetails.js
index 2738fab..8cb2677 100644
--- a/src/store/UserDetails.js
+++ b/src/store/UserDetails.js
@@ -1,15 +1,15 @@
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
- userDetails: {}
+ userDetails: {},
};
export const userSlice = createSlice({
name: "userDetails",
initialState,
reducers: {
- updateUserDetails: (state,action) => {
- state.userDetails = {...action.payload}
+ updateUserDetails: (state, action) => {
+ state.userDetails = { ...action.payload };
},
},
});
@@ -17,4 +17,4 @@ export const userSlice = createSlice({
// Action creators are generated for each case reducer function
export const { updateUserDetails } = userSlice.actions;
-export default userSlice.reducer;
\ No newline at end of file
+export default userSlice.reducer;
diff --git a/src/store/store.js b/src/store/store.js
index 3f563b6..a6c5cc5 100644
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -7,6 +7,7 @@ import userDetailReducer from "./UserDetails";
import jobReducer from "./jobLists";
import notificationsReducer from "./notifications";
import userJobListReducer from "./userJobList";
+import walletDetails from "./walletDetails";
export default configureStore({
reducer: {
@@ -17,5 +18,6 @@ export default configureStore({
userJobList: userJobListReducer,
commonHeadBanner: commonHeadBannerReducer,
notifications: notificationsReducer,
+ walletDetails: walletDetails
},
});
diff --git a/src/store/walletDetails.js b/src/store/walletDetails.js
new file mode 100644
index 0000000..a6bc68c
--- /dev/null
+++ b/src/store/walletDetails.js
@@ -0,0 +1,18 @@
+import { createSlice } from "@reduxjs/toolkit";
+
+const initialState = {
+ walletDetails: {},
+};
+
+export const walletSlice = createSlice({
+ name: "walletDetails",
+ initialState,
+ reducers: {
+ viewWalletDetails: (state, action) => {
+ state.walletDetails = { ...action.payload };
+ },
+ },
+});
+
+export const { viewWalletDetails } = walletSlice.actions;
+export default walletSlice.reducer;