import { queryOptions } from "@tanstack/react-query";
import { authClient } from "@/lib/auth-client";

export function permissionQuery(permissions: Record<string, string[]>) {
	return queryOptions({
		queryKey: ["permission", permissions],
		queryFn: async () => {
			const result = await authClient.admin.hasPermission({
				permissions,
			});

			return result.data?.success ?? false;
		},
		staleTime: 30_000,
	});
}
