mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-12 23:33:43 +08:00
15 lines
392 B
TypeScript
15 lines
392 B
TypeScript
'use client';
|
|
|
|
import { hasPermission, type Permission } from '@/lib/store/auth-store';
|
|
|
|
interface PermissionGateProps {
|
|
permission: Permission;
|
|
children: React.ReactNode;
|
|
fallback?: React.ReactNode;
|
|
}
|
|
|
|
export function PermissionGate({ permission, children, fallback = null }: PermissionGateProps) {
|
|
if (!hasPermission(permission)) return <>{fallback}</>;
|
|
return <>{children}</>;
|
|
}
|