mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 15:52:04 +00:00
30 lines
653 B
TypeScript
30 lines
653 B
TypeScript
|
|
import { Navigate } from "react-router-dom";
|
||
|
|
import { useAuthContext } from "@/providers/auth-context";
|
||
|
|
import { Box, CircularProgress } from "@mui/material";
|
||
|
|
|
||
|
|
interface GuestRouteProps {
|
||
|
|
children: React.ReactNode;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function GuestRoute({ children }: GuestRouteProps) {
|
||
|
|
const { isAuthenticated, isLoading } = useAuthContext();
|
||
|
|
|
||
|
|
if (isLoading) {
|
||
|
|
return (
|
||
|
|
<Box
|
||
|
|
className="flex min-h-screen items-center justify-center"
|
||
|
|
role="status"
|
||
|
|
aria-label="Loading"
|
||
|
|
>
|
||
|
|
<CircularProgress />
|
||
|
|
</Box>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (isAuthenticated) {
|
||
|
|
return <Navigate to="/" replace />;
|
||
|
|
}
|
||
|
|
|
||
|
|
return children;
|
||
|
|
}
|