import React, { useContext, useEffect, useState } from "react"; import logo from "../assets/logo2.png"; import logoDark from "../assets/logo.png"; import logoMini from "../assets/logo-min.png"; import logoMiniDark from "../assets/favicon.png"; import { useDispatch } from "react-redux"; import { loginUser } from "../Redux/Slice/auth"; import Button02 from "../Components/Buttons/Button02"; import { TbArrowBadgeLeftFilled, TbListDetails, TbReportMoney, TbTransactionDollar, } from "react-icons/tb"; import { TbArrowBadgeRightFilled } from "react-icons/tb"; import { ArrowBackIcon, ArrowLeftIcon, ArrowRightIcon } from "@chakra-ui/icons"; import { Link, NavLink, Route, Routes, useLocation, useNavigate, } from "react-router-dom"; import { RouteLink } from "../Routes/Routes"; import NotFound from "../Pages/NotFound"; import { nav } from "../Routes/Nav"; import { Avatar, Box, Button, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, Portal, Text, WrapItem, Popover, Tag, Accordion, AccordionItem, AccordionButton, AccordionIcon, AccordionPanel, Image, } from "@chakra-ui/react"; import GlobalStateContext from "../Contexts/GlobalStateContext"; import Cookies from "js-cookie"; // Import the Cookies library import Header from "../Components/Header"; import HeaderMain from "../Components/HeaderMain"; import { IoMdSwap } from "react-icons/io"; import { RiBankLine, RiExchangeBoxLine, RiFileUserLine, RiMoneyDollarBoxLine, } from "react-icons/ri"; import { VscSymbolClass } from "react-icons/vsc"; import { MdNotificationsNone, MdOutlineAddChart } from "react-icons/md"; import { HiOutlineChartSquareBar } from "react-icons/hi"; import { GrManual } from "react-icons/gr"; import { LuContact } from "react-icons/lu"; import shield from "../assets/shield.png" import SplashScreen from "../Pages/SplashScreen"; const DashboardLayout = () => { const navigate = useNavigate(); const dispach = useDispatch(); const location = useLocation(); const path = location.pathname; const [isDrawerOpen, setIsDrawerOpen] = useState(false); const [openDrawerClick, setOpenDrawerClick] = useState(true); const { setIsAuthenticate, colorMode, toggleColorMode, setSlideFormRight, slideFromRight } = useContext(GlobalStateContext); const [isSplashVisible, setSplashVisible] = useState(true); useEffect(() => { // Set a timer to hide the splash screen after 3 seconds const timer = setTimeout(() => { setSplashVisible(false); }, 2000); // 3000ms = 3 seconds // Cleanup the timer return () => clearTimeout(timer); }, []); const openDrawerOnClick = () => { setOpenDrawerClick(!openDrawerClick); }; const logOutHandler = () => { // dispach(loginUser(false)); setIsAuthenticate(false); Cookies.remove("isAuthenticated"); navigate("/login"); }; console.log(); // // Function to get the title based on the route const getTitle = () => { switch (true) { case "/": return "👋🏻 Hi, Admin"; case path.startsWith("/sponser"): return ( Sponser ); case path.startsWith("/investment-type"): return ( Investment Type ); case path.startsWith("/exchange-rate"): return ( Echange rate ); case path.startsWith("/create-io"): return ( Create IO ); case path.startsWith("/view-io"): return ( View IO ); case path.startsWith("/investor-details"): return ( Investor Details ); case path.startsWith("/investor-transactions"): return ( Investor Transactions ); case path.startsWith("/withdraw-request"): return ( Withdrawal pending request ); case path.startsWith("/withdraw-history"): return ( Withdrawal request ); case path.startsWith("/investor-request"): return ( Investor pending request ); case path.startsWith("/investor-history"): return ( Investor request ); case path.startsWith("/deletion-request"): return ( Deletion pending request ); case path.startsWith("/deletion-history"): return ( Deletion request ); case path.startsWith("/bank-investor"): return ( Ban / Unban Investor ); case path.startsWith("/academy"): return ( Academy ); case path.startsWith("/notification"): return ( Notification ); case path.startsWith("/contact"): return ( Contact Details ); case path.startsWith("/users"): return ( Users ); case path.startsWith("/bank-details"): return ( Bank Details ); case path.startsWith("/deletion-request"): return ( Deletion pending request ); case path.startsWith("/deletion-history"): return ( Deletion request ); case path.startsWith("/deletion-request"): return ( Deletion pending request ); case path.startsWith("/deletion-history"): return ( Deletion request ); default: if (path.startsWith("/community/view/")) { return ( Community ); } else if (path.startsWith("/community/edit/")) { return ( Community ); } return "Tanami"; } }; if (isSplashVisible) { return ; } return ( setSlideFormRight(!slideFromRight)} _hover={{ opacity: 1, }} zIndex={999} > {slideFromRight ? null : ( )} {/* {getTitle()} */} {/* =======[ Left ]============ */} {slideFromRight ? ( ) : null} ); }; export default DashboardLayout; const AppContent = () => { return ( {RouteLink.map(({ path, Component }, index) => ( } /> ))} } /> ); };