20 lines
486 B
React
20 lines
486 B
React
import { Navigate } from 'react-router-dom'
|
|
import { useAuth } from '../context/AuthContext'
|
|
|
|
// Nur fuer Admins; wird innerhalb von ProtectedRoute verwendet. Alle anderen landen bei den Tickets.
|
|
export default function AdminRoute({ children }) {
|
|
const { loading, isAdmin } = useAuth()
|
|
|
|
if (loading) {
|
|
return (
|
|
<div className="loading">
|
|
<p>Wird geladen …</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!isAdmin) return <Navigate to="/tickets" replace />
|
|
|
|
return children
|
|
}
|