first commit

This commit is contained in:
2025-05-08 21:27:29 +05:30
commit 230d5c89f0
343 changed files with 42391 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { useAuth } from "../hooks/use-auth";
import { Loader2 } from "lucide-react";
import { Redirect, Route } from "wouter";
export function ProtectedRoute({
path,
component: Component,
}: {
path: string;
component: () => React.JSX.Element;
}) {
const { user, isLoading } = useAuth();
if (isLoading) {
return (
<Route path={path}>
<div className="flex items-center justify-center min-h-screen">
<Loader2 className="h-8 w-8 animate-spin text-border" />
</div>
</Route>
);
}
if (!user) {
return (
<Route path={path}>
<Redirect to="/auth" />
</Route>
);
}
return <Route path={path} component={Component} />;
}