shoc-frontend-new/src/components/auth/guest-route.tsx
Alexandre Brandizzi c68d47af7b
Some checks failed
CI / ci (push) Has been cancelled
Deploy / deploy (push) Has been cancelled
chore: upgrade frontend dependencies (#24)
* chore: upgrade frontend application dependencies

* chore: upgrade frontend infrastructure dependencies

* fix: align lockfiles with CI npm

* fix: preserve ky error semantics

* fix: sanitize timeout error message
2026-07-14 21:35:59 -03:00

29 lines
649 B
TypeScript

import { Navigate } from "react-router";
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;
}