Spaces:
Build error
Build error
Hkoradiya123
feat: Initialize frontend with Zustand for state management, Tailwind CSS for styling, and TypeScript for type safety
4854e2b Download frontend/src/components/ProtectedRoute.tsx from jinksQspider/fmpro: direct link, hf CLI and curl.
- Browser
- Download file 976 Bytes
-
https://huggingface.co/spaces/jinksQspider/fmpro/resolve/main/frontend/src/components/ProtectedRoute.tsx
- Command line
-
hf download hf://spaces/jinksQspider/fmpro/frontend/src/components/ProtectedRoute.tsx
-
curl -L -o ProtectedRoute.tsx https://huggingface.co/spaces/jinksQspider/fmpro/resolve/main/frontend/src/components/ProtectedRoute.tsx
976 Bytes
| /** | |
| * Protected Route Component | |
| */ | |
| import React from 'react'; | |
| import { Navigate } from 'react-router-dom'; | |
| import { useAuth } from '../hooks'; | |
| interface ProtectedRouteProps { | |
| children: React.ReactNode; | |
| adminOnly?: boolean; | |
| } | |
| export const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children, adminOnly = false }) => { | |
| const { isAuthenticated, user, isLoading } = useAuth(); | |
| if (isLoading) { | |
| return ( | |
| <div className="app-shell flex min-h-screen items-center justify-center"> | |
| <div className="text-center"> | |
| <div className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-[color:var(--brand)] border-t-transparent" /> | |
| <p className="mt-2 text-[color:var(--muted)]">Loading...</p> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| if (!isAuthenticated) { | |
| return <Navigate to="/login" />; | |
| } | |
| if (adminOnly && user?.role !== 'admin') { | |
| return <Navigate to="/dashboard" />; | |
| } | |
| return <>{children}</>; | |
| }; | |