From 104341ddc4add57f83c58cb3fabb23b6fbfdd3e4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 2 Nov 2025 00:00:35 +0900 Subject: wip --- frontend/src/components/ProtectedRoute.tsx | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 frontend/src/components/ProtectedRoute.tsx (limited to 'frontend/src/components/ProtectedRoute.tsx') diff --git a/frontend/src/components/ProtectedRoute.tsx b/frontend/src/components/ProtectedRoute.tsx new file mode 100644 index 0000000..0cfef42 --- /dev/null +++ b/frontend/src/components/ProtectedRoute.tsx @@ -0,0 +1,32 @@ +import type { ReactNode } from "react"; +import { Redirect } from "wouter"; +import { useAuth } from "../contexts/AuthContext"; + +interface Props { + children: ReactNode; +} + +export function ProtectedRoute({ children }: Props) { + const { user, isLoading } = useAuth(); + + if (isLoading) { + return ( +
+ Loading... +
+ ); + } + + if (!user) { + return ; + } + + return <>{children}; +} -- cgit v1.2.3-70-g09d2