import { usePage } from '@inertiajs/react'; import type { Auth } from '@/types/auth'; export function usePermission() { const { auth } = usePage<{auth: Auth}>().props; const hasPermission = (permission: string) => { if (auth.roles.includes('Developer')) return true; return auth.permissions.includes(permission); }; const hasRole = (role: string) => { return auth.roles.includes(role); }; return { hasPermission, hasRole }; }