mirror of
https://github.com/20kaushik02/spotify-manager-web.git
synced 2026-01-25 16:14:06 +00:00
formatting
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user