first commit

This commit is contained in:
ryanwong
2022-11-26 01:25:31 -05:00
commit 9075aad9d3
23 changed files with 3598 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
import React from "react";
import { AuthContext } from "./authContext";
import { Routes, Route, Navigate } from "react-router-dom";
import SnackBar from "./components/SnackBar";
import AdminDashboardPage from "./pages/AdminDashboardPage";
import AdminLoginPage from "./pages/AdminLoginPage";
import NotFoundPage from "./pages/NotFoundPage";
function renderRoutes(role) {
switch (role) {
case "admin":
return (
<Routes>
<Route
path="/admin/dashboard"
element={<AdminDashboardPage />}
></Route>
</Routes>
);
break;
default:
return (
<Routes>
<Route exact path="/admin/login" element={<AdminLoginPage />}></Route>
<Route path="*" exact element={<NotFoundPage />}></Route>
</Routes>
);
break;
}
}
function Main() {
const { state } = React.useContext(AuthContext);
return (
<div className="h-full">
<div className="flex w-full">
<div className="w-full">
<div className="page-wrapper w-full py-10 px-5">
{!state.isAuthenticated
? renderRoutes("none")
: renderRoutes(state.role)}
</div>
</div>
</div>
<SnackBar />
</div>
);
}
export default Main;