Files
Torben Sorensen a3d3ddd772
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 57m50s
mock mock mock !
2025-12-19 20:31:04 -08:00

20 lines
491 B
TypeScript

// src/components/AdminRoute.tsx
import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import type { Profile } from '../types';
export 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 />;
};