// usePermissions Hook
import { useAuthStore } from '@/stores/authStore';

export function usePermissions() {
  const { checkPermission, isDBISLevel, user } = useAuthStore();

  const hasPermission = (permission: string): boolean => {
    return checkPermission(permission);
  };

  const hasAnyPermission = (permissions: string[]): boolean => {
    return permissions.some((p) => checkPermission(p));
  };

  const hasAllPermissions = (permissions: string[]): boolean => {
    return permissions.every((p) => checkPermission(p));
  };

  return {
    hasPermission,
    hasAnyPermission,
    hasAllPermissions,
    isDBISLevel: isDBISLevel(),
    user,
    permissions: user?.permissions || [],
  };
}

