feat(web): TanStack Query hooks + session-guarded routes
Installs @tanstack/react-query and react-router-dom; adds typed query hooks (useMe, useObjectsPage, useObject, useFieldDefinitions, useLogin, useLogout), a QueryClient+MemoryRouter test render helper, and RequireAuth — a layout route that blocks unauthenticated access and redirects to /login. All 7 tests pass, typecheck/lint/build clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { Navigate, Outlet } from "react-router-dom";
|
||||
|
||||
import { useMe } from "../api/queries";
|
||||
|
||||
export function RequireAuth() {
|
||||
const { data: user, isLoading } = useMe();
|
||||
|
||||
if (isLoading) return <div role="status" aria-label="loading" />;
|
||||
|
||||
if (!user) return <Navigate to="/login" replace />;
|
||||
|
||||
return <Outlet />;
|
||||
}
|
||||
Reference in New Issue
Block a user