formatting

This commit is contained in:
2024-12-29 18:39:31 -07:00
parent 41c3f26829
commit 9894a0da59
18 changed files with 186 additions and 172 deletions

View File

@@ -10,28 +10,28 @@ import Login from "../pages/Login";
import Logout from "../pages/Logout";
const AllRoutes = () => {
return (
<Routes>
{/* Routes that require user to be logged in */}
<Route element={<AuthOnlyRoutes />}>
<Route path="/logout" element={<Logout />} />
<Route path="/graph" element={<Graph />} />
{/* <Route path="/playlists" element={<Playlists />} /> */}
</Route>
return (
<Routes>
{/* Routes that require user to be logged in */}
<Route element={<AuthOnlyRoutes />}>
<Route path="/logout" element={<Logout />} />
<Route path="/graph" element={<Graph />} />
{/* <Route path="/playlists" element={<Playlists />} /> */}
</Route>
{/* Routes that require user to be logged *out* */}
<Route element={<UnAuthOnlyRoutes />}>
<Route path="/login" element={<Login />} />
</Route>
{/* Routes that require user to be logged *out* */}
<Route element={<UnAuthOnlyRoutes />}>
<Route path="/login" element={<Login />} />
</Route>
{/* Common routes */}
<Route path="/" element={<Landing />} />
{/* Common routes */}
<Route path="/" element={<Landing />} />
{/* 404 */}
<Route path="/page-not-found" element={<PageNotFound />} />
<Route path="*" element={<PageNotFound />} />
</Routes>
);
{/* 404 */}
<Route path="/page-not-found" element={<PageNotFound />} />
<Route path="*" element={<PageNotFound />} />
</Routes>
);
};
export default AllRoutes;
export default AllRoutes;

View File

@@ -5,19 +5,19 @@ import { AuthContext } from "../App";
import { showWarnToastNotification } from "../components/ToastNotification";
function AuthOnlyRoutes() {
let location = useLocation();
const auth = useContext(AuthContext);
let location = useLocation();
const auth = useContext(AuthContext);
const handleRouteRender = () => {
if (auth !== true) {
showWarnToastNotification(<p>Sign in, please!</p>);
return <Navigate to={"/login"} state={{ from: location }} />;
} else {
return <Outlet />;
}
};
const handleRouteRender = () => {
if (auth !== true) {
showWarnToastNotification(<p>Sign in, please!</p>);
return <Navigate to={"/login"} state={{ from: location }} />;
} else {
return <Outlet />;
}
};
return handleRouteRender();
return handleRouteRender();
}
export default AuthOnlyRoutes;
export default AuthOnlyRoutes;

View File

@@ -5,19 +5,19 @@ import { AuthContext } from "../App";
import { showWarnToastNotification } from "../components/ToastNotification";
function UnAuthOnlyRoutes() {
let location = useLocation();
const auth = useContext(AuthContext);
let location = useLocation();
const auth = useContext(AuthContext);
const handleRouteRender = () => {
if (auth !== true) {
return <Outlet />;
} else {
showWarnToastNotification(<p>Already logged in!</p>);
return <Navigate to={"/graph"} state={{ from: location }} />;
}
};
const handleRouteRender = () => {
if (auth !== true) {
return <Outlet />;
} else {
showWarnToastNotification(<p>Already logged in!</p>);
return <Navigate to={"/graph"} state={{ from: location }} />;
}
};
return handleRouteRender();
return handleRouteRender();
}
export default UnAuthOnlyRoutes;
export default UnAuthOnlyRoutes;