import { Button, Stack, Text } from '@mantine/core'; import { IconLock } from '@/components/icons'; import type { ReactNode } from 'react'; import { Link } from 'react-router-dom'; import { useAuth } from '../auth/AuthContext'; import { PageHeader } from './common'; /** Admin pages: everyone else gets a proper page that says why and leads back to Home. */ export function AdminOnly({ children, title = 'Settings' }: { children: ReactNode; title?: string }) { const { can, user } = useAuth(); if (can('admin')) return <>{children}; return (
This page needs the admin role You are signed in as {user?.username ?? 'a user'} ({user?.role ?? 'no role'}). Ask an administrator if you need access.
); }