refactor: clarify frontend module ownership
Frontend verify / commits (pull_request) Failing after 1m19s
Frontend verify / security (pull_request) Skipped
Frontend verify / verify (pull_request) Skipped

This commit is contained in:
2026-09-29 07:07:36 +03:00
parent 7c28a423dd
commit f9f0f6921e
91 changed files with 1292 additions and 1050 deletions
+9 -4
View File
@@ -1,5 +1,4 @@
import type { FC, PropsWithChildren } from "react";
import { type FC, type PropsWithChildren, useState } from "react";
import { Navigate, useLocation } from "react-router";
import { useAuth } from "@/features/auth";
@@ -8,16 +7,22 @@ import { RouteSkeleton } from "./RouteFallback";
const Protected: FC<PropsWithChildren> = (props) => {
const { children } = props;
const { ready, user } = useAuth();
const { ready, signedOut, user } = useAuth();
const location = useLocation();
const [wasAuthenticated, setWasAuthenticated] = useState(false);
if (user && !wasAuthenticated) setWasAuthenticated(true);
if (!ready) return <RouteSkeleton variant="shell" />;
const loginState = signedOut && wasAuthenticated
? undefined
: { returnTo: `${location.pathname}${location.search}` };
return user
? <>{children}</>
: (
<Navigate
replace
state={{ returnTo: `${location.pathname}${location.search}` }}
state={loginState}
to="/login"
/>
);