'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));
}
