admin guard

This commit is contained in:
Artem Tsyrulnikov
2026-03-25 11:58:56 +03:00
parent b397860513
commit 045cb4232a
5 changed files with 163 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
import { FC, ReactNode } from 'react'
import { Navigate } from 'react-router-dom'
import { isAuthenticated } from './authService'
interface AdminGuardProps {
children: ReactNode
}
const AdminGuard: FC<AdminGuardProps> = ({ children }) => {
if (!isAuthenticated()) {
return <Navigate to="/login" replace />
}
return <>{children}</>
}
export default AdminGuard