/**
 * 权限点 Hooks
 *
 * contract §2.4：adminPermissions
 */
import { useGraphQuery } from "./use-graphql";
import { ADMIN_PERMISSIONS_QUERY } from "@/lib/graphql-client";
import type { PermissionViewModel } from "@/types/view-models";

interface AdminPermissionsResponse {
  adminPermissions: PermissionViewModel[];
}

export function usePermissions() {
  const result = useGraphQuery<AdminPermissionsResponse>(
    ADMIN_PERMISSIONS_QUERY,
  );
  return {
    ...result,
    data: result.data?.adminPermissions ?? [],
  };
}
