mirror of
https://git.meshkee.com/Meshkee/dashboards.git
synced 2026-08-11 22:30:58 +04:30
Includes business, customer, and super-admin apps with shared packages and production deploy scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
22 lines
471 B
TypeScript
22 lines
471 B
TypeScript
import { Navigate, Outlet } from 'react-router-dom'
|
|
import { useAuth } from '../context/AuthContext'
|
|
import styles from './RouteLoader.module.css'
|
|
|
|
export function ProtectedRoute() {
|
|
const { user, isLoading } = useAuth()
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className={styles.loaderWrap}>
|
|
<div className={styles.loader} aria-label="Loading" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!user) {
|
|
return <Navigate to="/login" replace />
|
|
}
|
|
|
|
return <Outlet />
|
|
}
|