aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/ProtectedRoute.tsx
blob: 3aeaebc270c09446d7273353b914eb5cdcb72319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { Redirect } from "wouter";
import { useAuth } from "../hooks/useAuth";

export default function ProtectedRoute({
	children,
}: {
	children: React.ReactNode;
}) {
	const { isLoggedIn } = useAuth();

	if (!isLoggedIn) {
		return <Redirect to="/login" />;
	}

	return <>{children}</>;
}