2024-06-25 19:16:55 +05:30
|
|
|
import React, { useContext, useEffect, useState } from "react";
|
2024-11-06 11:49:34 +05:30
|
|
|
import { CgProfile } from "react-icons/cg";
|
2024-12-11 20:30:52 +05:30
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
|
import logoMiniDark from "../assets/favicon.png";
|
|
|
|
|
import logoMini from "../assets/logo-min.png";
|
|
|
|
|
import logoDark from "../assets/logo.png";
|
|
|
|
|
import logo from "../assets/logo2.png";
|
2024-11-06 11:49:34 +05:30
|
|
|
|
2024-12-09 20:10:47 +05:30
|
|
|
import {
|
|
|
|
|
ArrowBackIcon,
|
|
|
|
|
ArrowLeftIcon,
|
|
|
|
|
ArrowRightIcon,
|
|
|
|
|
AtSignIcon,
|
|
|
|
|
} from "@chakra-ui/icons";
|
2024-06-20 12:09:48 +05:30
|
|
|
import {
|
2024-06-24 12:08:21 +05:30
|
|
|
Accordion,
|
|
|
|
|
AccordionButton,
|
|
|
|
|
AccordionIcon,
|
2024-12-11 20:30:52 +05:30
|
|
|
AccordionItem,
|
2024-06-24 12:08:21 +05:30
|
|
|
AccordionPanel,
|
2024-07-11 11:46:48 +05:30
|
|
|
Alert,
|
|
|
|
|
AlertIcon,
|
2024-12-11 20:30:52 +05:30
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
Image,
|
|
|
|
|
Text,
|
|
|
|
|
Tooltip
|
2024-06-20 12:09:48 +05:30
|
|
|
} from "@chakra-ui/react";
|
|
|
|
|
import Cookies from "js-cookie"; // Import the Cookies library
|
2024-12-11 20:30:52 +05:30
|
|
|
import { GrManual } from "react-icons/gr";
|
|
|
|
|
import { HiOutlineChartSquareBar } from "react-icons/hi";
|
|
|
|
|
import { LuContact } from "react-icons/lu";
|
|
|
|
|
import { MdNotificationsNone, MdOutlineAddChart } from "react-icons/md";
|
2024-06-25 12:05:39 +05:30
|
|
|
import {
|
|
|
|
|
RiBankLine,
|
|
|
|
|
RiExchangeBoxLine,
|
|
|
|
|
RiFileUserLine,
|
|
|
|
|
RiMoneyDollarBoxLine,
|
|
|
|
|
} from "react-icons/ri";
|
2024-12-11 20:30:52 +05:30
|
|
|
import {
|
|
|
|
|
TbListDetails,
|
|
|
|
|
TbReportMoney,
|
|
|
|
|
TbTransactionDollar
|
|
|
|
|
} from "react-icons/tb";
|
2024-06-25 12:05:39 +05:30
|
|
|
import { VscSymbolClass } from "react-icons/vsc";
|
2024-12-11 20:30:52 +05:30
|
|
|
import {
|
|
|
|
|
Link,
|
|
|
|
|
NavLink,
|
|
|
|
|
Route,
|
|
|
|
|
Routes,
|
|
|
|
|
useLocation,
|
|
|
|
|
useNavigate,
|
|
|
|
|
} from "react-router-dom";
|
|
|
|
|
import HeaderMain from "../Components/HeaderMain";
|
|
|
|
|
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
2024-10-11 14:52:17 +05:30
|
|
|
import CreateRequest from "../Pages/Fawateer/CreateRequest";
|
|
|
|
|
import ApproveHistory from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryChecker";
|
2024-12-11 20:30:52 +05:30
|
|
|
import ApproveHistoryMaker from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryMaker";
|
|
|
|
|
import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveRequest";
|
|
|
|
|
import NotFound from "../Pages/NotFound";
|
|
|
|
|
import SplashScreen from "../Pages/SplashScreen";
|
|
|
|
|
import { nav } from "../Routes/Nav";
|
|
|
|
|
import { RouteLink } from "../Routes/Routes";
|
2024-10-11 17:26:27 +05:30
|
|
|
import { useProfileQuery } from "../Services/io.service";
|
2024-12-11 20:30:52 +05:30
|
|
|
import { useLogoutMutation } from "../Services/token.serivce";
|
2024-10-11 17:26:27 +05:30
|
|
|
|
2024-07-11 11:46:48 +05:30
|
|
|
const DashboardLayout = ({ isOnline }) => {
|
2024-06-20 12:09:48 +05:30
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
const path = location.pathname;
|
|
|
|
|
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
|
|
|
|
const [openDrawerClick, setOpenDrawerClick] = useState(true);
|
2024-07-01 12:53:57 +05:30
|
|
|
const {
|
|
|
|
|
setIsAuthenticate,
|
|
|
|
|
colorMode,
|
|
|
|
|
toggleColorMode,
|
|
|
|
|
setSlideFormRight,
|
|
|
|
|
slideFromRight,
|
|
|
|
|
} = useContext(GlobalStateContext);
|
2024-06-25 19:16:55 +05:30
|
|
|
const [isSplashVisible, setSplashVisible] = useState(true);
|
2024-07-01 12:53:57 +05:30
|
|
|
const [openIndex, setOpenIndex] = useState(null);
|
2024-06-25 19:16:55 +05:30
|
|
|
|
2024-10-11 17:32:36 +05:30
|
|
|
const { data, refetch } = useProfileQuery();
|
2024-10-11 17:26:27 +05:30
|
|
|
|
2024-12-06 20:25:12 +05:30
|
|
|
// useEffect(() => {
|
|
|
|
|
// if (
|
|
|
|
|
// !localStorage.getItem("accessToken") &&
|
|
|
|
|
// !localStorage.getItem("refreshToken")
|
|
|
|
|
// ) {
|
|
|
|
|
// logOutHandler();
|
|
|
|
|
// return navigate("/login");
|
|
|
|
|
// }
|
|
|
|
|
// }, []);
|
2024-10-02 14:01:31 +05:30
|
|
|
|
2024-07-01 12:53:57 +05:30
|
|
|
useEffect(() => {
|
|
|
|
|
const savedIndex = localStorage.getItem("openAccordionIndex");
|
|
|
|
|
if (savedIndex !== null) {
|
|
|
|
|
setOpenIndex(parseInt(savedIndex));
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const handleAccordionChange = (index) => {
|
|
|
|
|
const newIndex = openIndex === index ? null : index;
|
|
|
|
|
setOpenIndex(newIndex);
|
|
|
|
|
localStorage.setItem("openAccordionIndex", newIndex);
|
|
|
|
|
};
|
2024-06-25 19:16:55 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// Set a timer to hide the splash screen after 3 seconds
|
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
|
setSplashVisible(false);
|
2024-10-11 14:52:17 +05:30
|
|
|
}, 1000); // 3000ms = 3 seconds
|
2024-10-11 17:32:36 +05:30
|
|
|
refetch();
|
2024-06-25 19:16:55 +05:30
|
|
|
// Cleanup the timer
|
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
|
}, []);
|
2024-06-20 12:09:48 +05:30
|
|
|
|
|
|
|
|
const openDrawerOnClick = () => {
|
|
|
|
|
setOpenDrawerClick(!openDrawerClick);
|
|
|
|
|
};
|
|
|
|
|
|
2024-10-11 14:52:17 +05:30
|
|
|
const [logout] = useLogoutMutation();
|
2024-10-10 17:41:41 +05:30
|
|
|
|
|
|
|
|
const logOutHandler = async () => {
|
2024-06-20 12:09:48 +05:30
|
|
|
// dispach(loginUser(false));
|
|
|
|
|
setIsAuthenticate(false);
|
|
|
|
|
Cookies.remove("isAuthenticated");
|
2024-10-10 17:41:41 +05:30
|
|
|
try {
|
2024-10-11 14:52:17 +05:30
|
|
|
await logout();
|
2024-10-10 17:41:41 +05:30
|
|
|
localStorage.clear();
|
|
|
|
|
navigate("/login");
|
2024-12-11 18:47:43 +05:30
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
2024-06-20 12:09:48 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// // Function to get the title based on the route
|
|
|
|
|
const getTitle = () => {
|
2024-06-25 19:16:55 +05:30
|
|
|
switch (true) {
|
2024-06-20 12:09:48 +05:30
|
|
|
case "/":
|
|
|
|
|
return "👋🏻 Hi, Admin";
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/sponser"):
|
2024-06-24 12:08:21 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
2024-08-14 18:48:25 +05:30
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0" /> Sponsor
|
2024-06-24 12:08:21 +05:30
|
|
|
</span>
|
|
|
|
|
);
|
2024-12-09 20:10:47 +05:30
|
|
|
case path.startsWith("/email"):
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
2025-01-08 20:31:58 +05:30
|
|
|
<AtSignIcon className="h4 m-0" /> Email Notification
|
2024-12-09 20:10:47 +05:30
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/investment-type"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<VscSymbolClass className="h4 m-0" /> Investment Type
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-12-09 20:10:47 +05:30
|
|
|
case path.startsWith("/profile"):
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<CgProfile className="h4 m-0" /> Profile
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/exchange-rate"):
|
2024-06-24 12:08:21 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
2024-06-25 12:05:39 +05:30
|
|
|
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
2025-01-08 13:16:44 +05:30
|
|
|
Exchange rate
|
2024-06-25 12:05:39 +05:30
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/create-io"):
|
2024-07-11 11:46:48 +05:30
|
|
|
if (/^\/create-io\/[A-Za-z0-9_-]+$/.test(path)) {
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<MdOutlineAddChart className="h4 m-0 fw-normal" />
|
|
|
|
|
Edit IO
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<MdOutlineAddChart className="h4 m-0 fw-normal" />
|
|
|
|
|
Create IO
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/view-io"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<HiOutlineChartSquareBar className="h4 m-0 fw-normal" />
|
|
|
|
|
View IO
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/investor-details"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<TbListDetails className="h4 m-0 fw-normal" />
|
|
|
|
|
Investor Details
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/investor-transactions"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<TbTransactionDollar className="h4 m-0 fw-normal" />
|
|
|
|
|
Investor Transactions
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-08-16 15:02:02 +05:30
|
|
|
|
|
|
|
|
case path.startsWith("/deposit-request"):
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
2024-12-02 12:23:27 +05:30
|
|
|
Deposit Pending Request
|
2024-08-16 15:02:02 +05:30
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
case path.startsWith("/deposit-history"):
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
2024-12-02 12:23:27 +05:30
|
|
|
Deposite Request
|
2024-08-16 15:02:02 +05:30
|
|
|
</span>
|
|
|
|
|
);
|
2024-12-09 20:10:47 +05:30
|
|
|
|
2024-10-11 20:16:36 +05:30
|
|
|
case path.startsWith("/fawateer"):
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Fawateer Deposit
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-12-09 20:10:47 +05:30
|
|
|
case path.startsWith("/fawateer-history"):
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Fawateer Deposit
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-08-16 15:02:02 +05:30
|
|
|
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/withdraw-request"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Withdrawal pending request
|
2024-06-24 12:08:21 +05:30
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/withdraw-history"):
|
2024-06-20 12:09:48 +05:30
|
|
|
return (
|
2024-06-25 12:05:39 +05:30
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Withdrawal request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/investor-request"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Investor pending request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/investor-history"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Investor request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/deletion-request"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Deletion pending request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/deletion-history"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Deletion request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/bank-investor"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<TbReportMoney className="h4 m-0 fw-normal" />
|
|
|
|
|
Ban / Unban Investor
|
|
|
|
|
</span>
|
2024-06-20 12:09:48 +05:30
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/academy"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<GrManual className="h4 m-0 fw-normal" />
|
|
|
|
|
Academy
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/notification"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<MdNotificationsNone className="h4 m-0 fw-normal" />
|
2025-01-08 20:57:53 +05:30
|
|
|
Push Notification
|
2024-06-25 12:05:39 +05:30
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/contact"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<LuContact className="h4 m-0 fw-normal" />
|
|
|
|
|
Contact Details
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/users"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiFileUserLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Users
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/bank-details"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiBankLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Bank Details
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/deletion-request"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Deletion pending request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/deletion-history"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Deletion request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/deletion-request"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Deletion pending request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 19:16:55 +05:30
|
|
|
case path.startsWith("/deletion-history"):
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Deletion request
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-12-12 13:20:12 +05:30
|
|
|
case path.startsWith("/subadmin"):
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-end gap-2">
|
|
|
|
|
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
|
|
|
|
Manage SubAdmin
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2024-06-25 12:05:39 +05:30
|
|
|
|
2024-06-20 12:09:48 +05:30
|
|
|
default:
|
|
|
|
|
if (path.startsWith("/community/view/")) {
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-center">
|
|
|
|
|
<Link to={"/community/"}>
|
2024-06-24 12:08:21 +05:30
|
|
|
<ArrowBackIcon className="me-2 fs-3 link p-1 rounded-1" />
|
2024-06-20 12:09:48 +05:30
|
|
|
</Link>
|
|
|
|
|
Community
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
} else if (path.startsWith("/community/edit/")) {
|
|
|
|
|
return (
|
|
|
|
|
<span className="d-flex align-items-center">
|
|
|
|
|
<Link to={"/community/"}>
|
|
|
|
|
<ArrowBackIcon className="me-2 fs-3 link p-1 rounded-1" />
|
|
|
|
|
</Link>
|
|
|
|
|
Community
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return "Tanami";
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-25 19:16:55 +05:30
|
|
|
if (isSplashVisible) {
|
|
|
|
|
return <SplashScreen />;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-09 20:10:47 +05:30
|
|
|
const filteredNav = nav.map((item) => {
|
|
|
|
|
if (item.submenu) {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
submenu: item.submenu.filter(
|
|
|
|
|
(submenuItem) =>
|
|
|
|
|
!(!data?.data?.superAdmin && submenuItem.title === "Sub Admin")
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return item;
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-20 12:09:48 +05:30
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
style={{
|
|
|
|
|
height: "100vh",
|
|
|
|
|
width: "100vw",
|
|
|
|
|
position: "relative",
|
|
|
|
|
overflow: "hidden",
|
|
|
|
|
}}
|
|
|
|
|
className="d-flex"
|
|
|
|
|
pe={0.5}
|
|
|
|
|
>
|
2024-07-11 11:46:48 +05:30
|
|
|
<Alert
|
|
|
|
|
transition={"0.5s"}
|
|
|
|
|
h={53}
|
|
|
|
|
transform={isOnline ? "translateY(-100px)" : "translateY(0px)"}
|
|
|
|
|
position={"absolute"}
|
|
|
|
|
zIndex={999}
|
|
|
|
|
status="info"
|
|
|
|
|
variant="solid"
|
|
|
|
|
bgGradient="linear(to-r, red.500, yellow.500, red.500)"
|
|
|
|
|
// bgGradient='linear(to-r, #1EBCA3, #22CAB3)'
|
|
|
|
|
color={"white"}
|
|
|
|
|
fontWeight={600}
|
|
|
|
|
fontSize={"md"}
|
|
|
|
|
>
|
|
|
|
|
<AlertIcon color={"white"} />
|
|
|
|
|
No Internet !
|
|
|
|
|
</Alert>
|
|
|
|
|
|
2024-09-24 18:43:51 +05:30
|
|
|
{/* <Box
|
2024-06-24 12:08:21 +05:30
|
|
|
bottom={4}
|
|
|
|
|
right={!slideFromRight ? 4 : "auto"}
|
|
|
|
|
left={slideFromRight ? 4 : "auto"}
|
2024-09-24 18:43:51 +05:30
|
|
|
backgroundColor={"#000"}
|
2024-06-24 12:08:21 +05:30
|
|
|
rounded={"full"}
|
|
|
|
|
p={2}
|
|
|
|
|
w={8}
|
|
|
|
|
h={8}
|
|
|
|
|
display={"flex"}
|
|
|
|
|
justifyContent={"center"}
|
|
|
|
|
alignItems={"center"}
|
|
|
|
|
color={"#004118"}
|
|
|
|
|
fontWeight={"800"}
|
|
|
|
|
cursor={"pointer"}
|
|
|
|
|
position={"absolute"}
|
|
|
|
|
transition={"0.5s"}
|
|
|
|
|
boxShadow={"md"}
|
|
|
|
|
onClick={() => setSlideFormRight(!slideFromRight)}
|
|
|
|
|
_hover={{
|
|
|
|
|
opacity: 1,
|
2024-06-20 12:09:48 +05:30
|
|
|
}}
|
2024-06-24 12:08:21 +05:30
|
|
|
zIndex={999}
|
2024-06-20 12:09:48 +05:30
|
|
|
>
|
2024-06-24 12:08:21 +05:30
|
|
|
<IoMdSwap />
|
2024-09-24 18:43:51 +05:30
|
|
|
</Box> */}
|
2024-06-20 12:09:48 +05:30
|
|
|
|
2024-06-24 12:08:21 +05:30
|
|
|
{slideFromRight ? null : (
|
|
|
|
|
<aside
|
2024-09-24 18:43:51 +05:30
|
|
|
className="h-100 position-relative sideBar"
|
2024-06-24 12:08:21 +05:30
|
|
|
// onMouseOver={() => setIsDrawerOpen(true)}
|
|
|
|
|
// onMouseLeave={() => setIsDrawerOpen(false)}
|
2024-06-20 12:09:48 +05:30
|
|
|
style={{
|
2024-08-12 16:19:47 +05:30
|
|
|
width: isDrawerOpen || openDrawerClick ? 230 : 74,
|
2024-06-24 12:08:21 +05:30
|
|
|
transition: "width 0.3s ease-in-out", // Smooth transition for width change
|
2024-06-25 18:41:41 +05:30
|
|
|
// overflow: "hidden",
|
2024-06-24 12:08:21 +05:30
|
|
|
backgroundColor: "#0041180A",
|
|
|
|
|
position: "relative",
|
|
|
|
|
// backgroundColor: "#002F0F",
|
2024-06-20 12:09:48 +05:30
|
|
|
}}
|
|
|
|
|
>
|
2024-06-24 12:08:21 +05:30
|
|
|
<div
|
|
|
|
|
className={`d-flex ${
|
|
|
|
|
isDrawerOpen || openDrawerClick
|
|
|
|
|
? "justify-content-start"
|
|
|
|
|
: "justify-content-center"
|
2024-08-09 12:24:18 +05:30
|
|
|
} p-3 pt-3 pb-3 position-relative `}
|
2024-06-24 12:08:21 +05:30
|
|
|
height={"10%"}
|
|
|
|
|
>
|
|
|
|
|
{isDrawerOpen || openDrawerClick ? (
|
2024-06-25 19:16:55 +05:30
|
|
|
<Image
|
2024-06-24 12:08:21 +05:30
|
|
|
style={{
|
2024-08-09 12:24:18 +05:30
|
|
|
width: 110,
|
2024-06-24 12:08:21 +05:30
|
|
|
}}
|
2024-07-01 12:53:57 +05:30
|
|
|
src={colorMode === "light" ? logo : logoDark}
|
2024-06-24 12:08:21 +05:30
|
|
|
alt="Logo"
|
2024-10-11 14:52:17 +05:30
|
|
|
onClick={() => navigate("/")}
|
2024-08-09 12:24:18 +05:30
|
|
|
cursor={"pointer"}
|
2024-06-24 12:08:21 +05:30
|
|
|
/>
|
|
|
|
|
) : (
|
2024-06-25 19:16:55 +05:30
|
|
|
<Image
|
2024-06-24 12:08:21 +05:30
|
|
|
style={{
|
|
|
|
|
width: 30,
|
|
|
|
|
}}
|
2024-07-01 12:53:57 +05:30
|
|
|
src={colorMode === "light" ? logoMini : logoMiniDark}
|
2024-06-24 12:08:21 +05:30
|
|
|
alt="Logo"
|
2024-10-11 14:52:17 +05:30
|
|
|
onClick={() => navigate("/")}
|
2024-08-09 12:24:18 +05:30
|
|
|
cursor={"pointer"}
|
2024-06-24 12:08:21 +05:30
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Box
|
2024-08-09 12:24:18 +05:30
|
|
|
className="ps-2 scroll-bar pe-1 pt-3"
|
2024-07-01 12:53:57 +05:30
|
|
|
style={{
|
|
|
|
|
height: "90%",
|
|
|
|
|
overflowY: "scroll",
|
|
|
|
|
overflowX: "hidden",
|
|
|
|
|
paddingBottom: "5rem",
|
|
|
|
|
}}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
2024-07-01 12:53:57 +05:30
|
|
|
<Accordion
|
|
|
|
|
m={0}
|
|
|
|
|
allowToggle
|
|
|
|
|
defaultIndex={[0]}
|
|
|
|
|
index={openIndex}
|
|
|
|
|
onChange={handleAccordionChange}
|
|
|
|
|
>
|
2024-12-09 20:10:47 +05:30
|
|
|
{filteredNav.map(({ title, type, Icon, submenu, path }, index) => {
|
2024-06-24 12:08:21 +05:30
|
|
|
if (type === "accordion") {
|
|
|
|
|
return (
|
|
|
|
|
<AccordionItem key={index} border={"none"}>
|
2024-10-11 14:52:17 +05:30
|
|
|
<Tooltip
|
|
|
|
|
isDisabled={isDrawerOpen || openDrawerClick}
|
|
|
|
|
hasArrow
|
|
|
|
|
bg={"#fff"}
|
|
|
|
|
fontSize={"xs"}
|
|
|
|
|
label={title}
|
|
|
|
|
placement="top-start"
|
|
|
|
|
color={"blue.800"}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
2024-10-11 14:52:17 +05:30
|
|
|
<AccordionButton
|
|
|
|
|
style={{ height: "auto" }}
|
|
|
|
|
className={`${
|
|
|
|
|
isDrawerOpen || openDrawerClick
|
|
|
|
|
? "p-2 web-text-medium ps-3 justify-content-between"
|
|
|
|
|
: "p-2 ps-1 web-text-xlarge justify-content-center"
|
|
|
|
|
} rounded-1 link d-flex align-items-center gap-2 w-100 mb-1`}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
2024-10-11 14:52:17 +05:30
|
|
|
<Box
|
|
|
|
|
as="span"
|
|
|
|
|
display={"flex"}
|
|
|
|
|
gap={2}
|
|
|
|
|
alignItems={"center"}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
2024-10-11 14:52:17 +05:30
|
|
|
{/* {Icon && title === "Admin" ? <Image w={15} src={shield} /> : <Icon className={`web-text-large`} />} */}
|
|
|
|
|
{Icon && (
|
|
|
|
|
<Icon
|
|
|
|
|
fontSize={title === "Admin" ? "18px" : "15px"}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<Text
|
|
|
|
|
as={"span"}
|
|
|
|
|
display={
|
|
|
|
|
isDrawerOpen || openDrawerClick
|
|
|
|
|
? "flex"
|
|
|
|
|
: "none"
|
|
|
|
|
}
|
|
|
|
|
alignItems="center"
|
|
|
|
|
overflow="hidden"
|
|
|
|
|
textAlign={"left"}
|
|
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
<AccordionIcon />
|
|
|
|
|
</AccordionButton>
|
2024-08-26 18:58:58 +05:30
|
|
|
</Tooltip>
|
2024-06-24 12:08:21 +05:30
|
|
|
<AccordionPanel
|
|
|
|
|
p={0}
|
|
|
|
|
pb={1}
|
|
|
|
|
display={"flex"}
|
|
|
|
|
flexDirection={"column"}
|
|
|
|
|
gap={1}
|
|
|
|
|
>
|
|
|
|
|
{submenu?.map(
|
|
|
|
|
(
|
|
|
|
|
{ title: subMenuTitle, path: link, icon: SubIcon },
|
|
|
|
|
i
|
|
|
|
|
) => (
|
2024-10-11 14:52:17 +05:30
|
|
|
<Tooltip
|
|
|
|
|
isDisabled={isDrawerOpen || openDrawerClick}
|
|
|
|
|
hasArrow
|
|
|
|
|
bg={"#fff"}
|
|
|
|
|
fontSize={"xs"}
|
|
|
|
|
label={subMenuTitle}
|
|
|
|
|
placement="right"
|
|
|
|
|
color={"blue.800"}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
|
|
|
|
<Box
|
2024-10-11 14:52:17 +05:30
|
|
|
key={i}
|
|
|
|
|
style={{ height: "auto", position: "relative" }}
|
2024-06-24 12:08:21 +05:30
|
|
|
className={`${
|
|
|
|
|
isDrawerOpen || openDrawerClick
|
2024-10-11 14:52:17 +05:30
|
|
|
? " web-text-medium ps-4"
|
|
|
|
|
: " web-text-xlarge justify-content-center"
|
|
|
|
|
} d-flex align-items-center p-0`}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
2024-10-11 14:52:17 +05:30
|
|
|
<Box
|
|
|
|
|
backgroundColor={"gray.300"}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
top: 0,
|
|
|
|
|
width: 2,
|
|
|
|
|
left: 22,
|
|
|
|
|
height:
|
|
|
|
|
i === submenu?.length - 1
|
|
|
|
|
? "55%"
|
|
|
|
|
: "120%",
|
|
|
|
|
borderRadius: "0 0 10px 10px",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Box
|
|
|
|
|
backgroundColor={"gray.300"}
|
|
|
|
|
style={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
width: 10,
|
|
|
|
|
left: 22,
|
|
|
|
|
height: 2,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<NavLink
|
|
|
|
|
className={`${
|
2024-06-24 12:08:21 +05:30
|
|
|
isDrawerOpen || openDrawerClick
|
2024-10-11 14:52:17 +05:30
|
|
|
? "p-2 ps-1 ms-2 web-text-medium "
|
|
|
|
|
: "p-2 ps-0 ms-0 zindex-3 ms-4 web-text-xlarge justify-content-center"
|
|
|
|
|
} rounded-1 link d-flex align-items-center gap-2 w-100 `}
|
|
|
|
|
to={link}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
2024-10-11 14:52:17 +05:30
|
|
|
{SubIcon && (
|
|
|
|
|
<SubIcon
|
|
|
|
|
className="web-text-large ms-2"
|
|
|
|
|
style={{ zIndex: 111 }}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<Text
|
|
|
|
|
as={"span"}
|
|
|
|
|
display={
|
|
|
|
|
isDrawerOpen || openDrawerClick
|
|
|
|
|
? "flex"
|
|
|
|
|
: "none"
|
|
|
|
|
}
|
|
|
|
|
alignItems="center"
|
|
|
|
|
overflow="hidden"
|
|
|
|
|
>
|
2024-10-11 17:32:36 +05:30
|
|
|
{subMenuTitle === "Aprover Request"
|
|
|
|
|
? data?.data?.role === "Maker"
|
|
|
|
|
? "Create Request"
|
|
|
|
|
: "Aprover Request"
|
|
|
|
|
: subMenuTitle}
|
2024-10-11 14:52:17 +05:30
|
|
|
</Text>
|
|
|
|
|
</NavLink>
|
|
|
|
|
</Box>
|
2024-08-26 18:58:58 +05:30
|
|
|
</Tooltip>
|
2024-06-24 12:08:21 +05:30
|
|
|
)
|
|
|
|
|
)}
|
|
|
|
|
</AccordionPanel>
|
|
|
|
|
</AccordionItem>
|
|
|
|
|
);
|
|
|
|
|
} else if (type === "title") {
|
|
|
|
|
return (
|
|
|
|
|
<Text
|
|
|
|
|
as={"span"}
|
|
|
|
|
key={index}
|
2024-06-24 17:48:39 +05:30
|
|
|
className="web-text-xxsmall fw-600 text-secondary fw-bold"
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</Text>
|
|
|
|
|
);
|
|
|
|
|
} else if (type === "single") {
|
|
|
|
|
return (
|
2024-10-11 14:52:17 +05:30
|
|
|
<Tooltip
|
|
|
|
|
hasArrow
|
|
|
|
|
bg={"#fff"}
|
|
|
|
|
fontSize={"xs"}
|
|
|
|
|
label={title}
|
|
|
|
|
placement="top-start"
|
|
|
|
|
color={"blue.800"}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
2024-10-11 14:52:17 +05:30
|
|
|
<NavLink
|
|
|
|
|
key={index}
|
|
|
|
|
style={{ height: "auto", position: "relative" }}
|
|
|
|
|
className={`${
|
|
|
|
|
isDrawerOpen || openDrawerClick
|
|
|
|
|
? "p-2 web-text-medium"
|
|
|
|
|
: "p-2 ps-0 web-text-xlarge justify-content-start"
|
|
|
|
|
} rounded-1 link d-flex align-items-center gap-2 w-100`}
|
|
|
|
|
to={path}
|
2024-06-24 12:08:21 +05:30
|
|
|
>
|
2024-10-11 14:52:17 +05:30
|
|
|
{Icon && <Icon className="web-text-large ms-2" />}
|
|
|
|
|
<Text
|
|
|
|
|
as={"span"}
|
|
|
|
|
display={
|
|
|
|
|
isDrawerOpen || openDrawerClick ? "flex" : "none"
|
|
|
|
|
}
|
|
|
|
|
alignItems="center"
|
|
|
|
|
overflow="hidden"
|
|
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</Text>
|
|
|
|
|
</NavLink>
|
2024-08-26 18:58:58 +05:30
|
|
|
</Tooltip>
|
2024-06-24 12:08:21 +05:30
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
})}
|
|
|
|
|
</Accordion>
|
|
|
|
|
</Box>
|
|
|
|
|
|
2024-08-26 18:58:58 +05:30
|
|
|
<Button
|
2024-06-24 12:08:21 +05:30
|
|
|
colorScheme={"forestGreen"}
|
|
|
|
|
rounded={"lg"}
|
|
|
|
|
// onMouseOver={() => setIsDrawerOpen(true)}
|
|
|
|
|
// onMouseLeave={() => setIsDrawerOpen(false)}
|
|
|
|
|
onClick={openDrawerOnClick}
|
|
|
|
|
style={{
|
|
|
|
|
width: 18,
|
|
|
|
|
height: 26,
|
|
|
|
|
position: "absolute",
|
2024-06-25 18:41:41 +05:30
|
|
|
right: -19,
|
2024-06-24 12:08:21 +05:30
|
|
|
bottom: 28,
|
2024-06-25 18:41:41 +05:30
|
|
|
zIndex: 99,
|
2024-06-24 12:08:21 +05:30
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{isDrawerOpen || openDrawerClick ? (
|
|
|
|
|
<ArrowLeftIcon className="web-text-small" />
|
|
|
|
|
) : (
|
|
|
|
|
<ArrowRightIcon className="web-text-small " />
|
|
|
|
|
)}
|
2024-08-26 18:58:58 +05:30
|
|
|
</Button>
|
2024-09-23 15:21:42 +05:30
|
|
|
{/* <Text textAlign={'center'} fontWeight={500} fontSize={'xs'} color={"gray.600"}>{getCountdownTimer(localStorage.getItem('accessTokenExp'))}</Text> */}
|
2024-06-24 12:08:21 +05:30
|
|
|
</aside>
|
|
|
|
|
)}
|
2024-06-20 12:09:48 +05:30
|
|
|
|
|
|
|
|
<main
|
2024-10-11 14:52:17 +05:30
|
|
|
className={`h-100 ${
|
|
|
|
|
slideFromRight ? "pe-3" : "ps-3"
|
|
|
|
|
} d-flex flex-column gap-0`}
|
2024-06-20 12:09:48 +05:30
|
|
|
style={{
|
2024-08-12 16:19:47 +05:30
|
|
|
width: `calc(100% - ${isDrawerOpen || openDrawerClick ? 230 : 74}px)`,
|
2024-06-20 12:09:48 +05:30
|
|
|
transition: "width 0.3s ease-in-out",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-24 12:08:21 +05:30
|
|
|
{/* <header className="p-2 ps-0 pt-3 fw-400 border-bottom">
|
|
|
|
|
<span className="fs-5">{getTitle()}</span>
|
|
|
|
|
</header> */}
|
|
|
|
|
|
|
|
|
|
<HeaderMain
|
2024-10-11 17:32:36 +05:30
|
|
|
data={data}
|
2024-06-24 12:08:21 +05:30
|
|
|
slideDirecttion={slideFromRight}
|
|
|
|
|
logOutHandler={logOutHandler}
|
|
|
|
|
icon
|
|
|
|
|
title={getTitle()}
|
|
|
|
|
/>
|
2024-10-11 14:52:17 +05:30
|
|
|
|
|
|
|
|
{/* <CustomBreadcrumb /> */}
|
2024-06-24 12:08:21 +05:30
|
|
|
|
2024-10-11 17:26:27 +05:30
|
|
|
<AppContent data={data} />
|
2024-06-24 12:08:21 +05:30
|
|
|
</main>
|
2024-06-20 12:09:48 +05:30
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default DashboardLayout;
|
|
|
|
|
|
2024-10-11 17:32:36 +05:30
|
|
|
const AppContent = ({ data }) => {
|
2024-06-20 12:09:48 +05:30
|
|
|
return (
|
|
|
|
|
<Routes>
|
|
|
|
|
{RouteLink.map(({ path, Component }, index) => (
|
|
|
|
|
<Route key={index} path={path} element={<Component />} />
|
|
|
|
|
))}
|
2024-10-11 14:52:17 +05:30
|
|
|
|
|
|
|
|
<Route
|
|
|
|
|
path="/fawateer"
|
|
|
|
|
element={
|
2024-10-11 17:32:36 +05:30
|
|
|
data?.data?.role === "Maker" ? <CreateRequest /> : <ApproveRequest />
|
2024-10-11 14:52:17 +05:30
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
path="/fawateer-history"
|
|
|
|
|
element={
|
2024-10-11 17:26:27 +05:30
|
|
|
data?.data?.role === "Maker" ? (
|
2024-10-11 14:52:17 +05:30
|
|
|
<ApproveHistoryMaker />
|
2024-10-11 17:32:36 +05:30
|
|
|
) : (
|
2024-10-11 14:52:17 +05:30
|
|
|
<ApproveHistory />
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
/>
|
2024-12-09 20:10:47 +05:30
|
|
|
|
2024-06-20 12:09:48 +05:30
|
|
|
<Route path="*" element={<NotFound />} />
|
|
|
|
|
</Routes>
|
|
|
|
|
);
|
|
|
|
|
};
|