first commit

This commit is contained in:
ahmadrezabd
2025-11-18 20:22:25 +03:30
commit 948238b6d9
55 changed files with 13772 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import { Navigate, useLocation } from 'react-router-dom';
import { useAtom } from 'jotai';
import { isAuthenticatedAtom } from '@/atoms/auth';
import { isSupabaseConfigured } from '@/services/supabase';
interface ProtectedRouteProps {
children: React.ReactNode;
}
export function ProtectedRoute({ children }: ProtectedRouteProps) {
const [isAuthenticated] = useAtom(isAuthenticatedAtom);
const location = useLocation();
// In offline mode, allow access without authentication
if (!isSupabaseConfigured) {
return <>{children}</>;
}
if (!isAuthenticated) {
return <Navigate to="/login" state={{ from: location }} replace />;
}
return <>{children}</>;
}