Files
flyer-crawler.projectium.com/components/AdminRoute.tsx
Torben Sorensen 5eba160a55
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 3m21s
move the "System Check" to a new admin area
2025-11-11 12:47:38 -08:00

19 lines
451 B
TypeScript

import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import type { Profile } from '../types';
interface AdminRouteProps {
profile: Profile | null;
}
export const AdminRoute: React.FC<AdminRouteProps> = ({ profile }) => {
// An admin is identified by the 'admin' role in their profile.
const isAdmin = profile?.role === 'admin';
if (!isAdmin) {
return <Navigate to="/" replace />;
}
return <Outlet />;
};