This commit is contained in:
2024-10-10 17:41:41 +05:30
parent 48e53ea176
commit e47db6c840
5 changed files with 34 additions and 29 deletions

View File

@@ -74,6 +74,9 @@ import SplashScreen from "../Pages/SplashScreen";
import CutomBreadcrumb from "../Components/CutomBreadcrumb";
import CustomBreadcrumb from "../Components/CutomBreadcrumb";
import { getCountdownTimer } from "../Constants/Constants";
import { useLogoutMutation } from "../Services/token.serivce";
const DashboardLayout = ({ isOnline }) => {
const navigate = useNavigate();
@@ -129,12 +132,20 @@ const DashboardLayout = ({ isOnline }) => {
setOpenDrawerClick(!openDrawerClick);
};
const logOutHandler = () => {
const [ logout ] = useLogoutMutation()
const logOutHandler = async () => {
// dispach(loginUser(false));
setIsAuthenticate(false);
Cookies.remove("isAuthenticated");
localStorage.clear();
navigate("/login");
try {
await logout()
localStorage.clear();
navigate("/login");
} catch (error) {
}
};
// // Function to get the title based on the route

View File

@@ -52,8 +52,9 @@ const Login = () => {
const [login] = useLoginMutation()
useEffect(() => {
if (isAuthenticate) {
navigate("/sponser");
navigate("/");
}
}, [navigate, isAuthenticate]);

View File

@@ -103,30 +103,11 @@ export const nav = [
title: "INVESTORS REQUEST",
type: "title",
},
localStorage.getItem("role") === "Maker"
? {
{
title: "Fawateer Deposit",
submenu: [
{
title: "Create Request",
path: "/fawateer",
icon: RiMoneyDollarBoxLine,
},
{
title: "View History",
path: "/fawateer-history",
icon: RiExchangeBoxLine,
},
],
type: "accordion",
Icon: HiOutlineBanknotes,
}
: {
title: "Fawateer Deposit",
submenu: [
{
title: "Pending Request",
title: localStorage.getItem("role") === "Maker"? "Create Request":"Aprover Request",
path: "/fawateer",
icon: RiMoneyDollarBoxLine,
},

View File

@@ -41,7 +41,8 @@ import FawateerRequest from "../Pages/Fawateer/FawateerRequest";
import CreateRequest from "../Pages/Fawateer/CreateRequest";
import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveRequest";
import ApproveHistory from "../Pages/FawateerChecker/ApproveHistory/ApproveHistory";
export const getUserRole = () => localStorage.getItem('role');
console.log(getUserRole());
export const RouteLink = [
// =============[ Tanami ]================
// ===============[ Management]===============
@@ -119,8 +120,8 @@ export const RouteLink = [
// ===============[ fawateer ]===============
{ path: "/fawateer", Component: localStorage.getItem("role") === "Maker"? CreateRequest:ApproveRequest },
{ path: "/fawateer-history", Component: localStorage.getItem("role") === "Maker"?ApproveRequest: ApproveHistory },
{ path: "/fawateer", Component: getUserRole() === "Maker"? CreateRequest:ApproveRequest },
{ path: "/fawateer-history", Component: getUserRole() === "Maker"?ApproveRequest: ApproveHistory },
// { path: "/fawateer-approver", Component: ApproveRequest },

View File

@@ -113,7 +113,18 @@ export const apiSlice = createApi({
body: { refreshToken },
}),
}),
logout: builder.mutation({
query: () => ({
url: "/auth/admin/logout",
method: "POST",
}),
}),
}),
});
export const { useLoginMutation, useRefreshTokenMutation } = apiSlice;
export const { useLoginMutation, useRefreshTokenMutation, useLogoutMutation } = apiSlice;