mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +00:00
16 lines
418 B
TypeScript
16 lines
418 B
TypeScript
'use client';
|
|
|
|
import { useAuthStore } from './auth-store';
|
|
|
|
/**
|
|
* Returns whether the current user has a given permission key.
|
|
* Super admins and org admins always return true.
|
|
*
|
|
* Usage:
|
|
* const canCancel = usePermission(PERMS.bookings.cancel);
|
|
* {canCancel && <button>Cancel Booking</button>}
|
|
*/
|
|
export function usePermission(key: string): boolean {
|
|
return useAuthStore((s) => s.hasPermission(key));
|
|
}
|