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
