diff --git a/src/states/Manage/Manage.jsx b/src/states/Manage/Manage.jsx index bef9982..b0280cd 100644 --- a/src/states/Manage/Manage.jsx +++ b/src/states/Manage/Manage.jsx @@ -1,19 +1,47 @@ -import {Navigate, useOutlet} from "react-router-dom"; +import {Navigate, useLocation, useOutlet} from "react-router-dom"; import Header from "@/states/Manage/components/Header"; +import {useEffect, useState} from "react"; +import pages from "./pages/pages.jsx"; +import Sidebar from "@/states/Manage/pages/Sidebar"; +import "./styles.sass"; + +export const getPage = (path) => { + path = path.split("/"); + path = path[path.length - 1]; + + for (const page in pages) { + let pagePath = pages[page].path.split("/"); + pagePath = pagePath[pagePath.length - 1]; + + if (pagePath === path) return pages[page]; + } + + return {}; +} export const Manage = () => { const outlet = useOutlet(); + const location = useLocation(); + + const [currentPage, setCurrentPage] = useState({}); + + useEffect(() => { + setCurrentPage(getPage(location.pathname)); + }, [location]); if (!localStorage.getItem("token")) { return ; } return ( - <> -
+
+ {Object.keys(currentPage).length !== 0 && } - {outlet} - +
+
+ {outlet} +
+
); } \ No newline at end of file