15 lines
309 B
TypeScript
15 lines
309 B
TypeScript
import type { ReactNode } from 'react';
|
|
import { useAuth } from './AuthContext';
|
|
|
|
export function PermissionGate({
|
|
permission,
|
|
children,
|
|
fallback = null,
|
|
}: {
|
|
permission: string;
|
|
children: ReactNode;
|
|
fallback?: ReactNode;
|
|
}) {
|
|
return useAuth().hasPermission(permission) ? children : fallback;
|
|
}
|