import { useMutation, useQuery } from "@tanstack/react-query";
import {
  fetchAllRecords,
  fetchRecordDetails,
} from "@/user-management/all-records/services/allRecordsService";
import type { AllRecordsParams } from "@/user-management/all-records/types";

export const useAllRecords = () =>
  useMutation({
    mutationKey: ["all-records"],
    mutationFn: (params: AllRecordsParams) => fetchAllRecords(params),
  });

export const useRecordDetails = (id?: string) =>
  useQuery({
    queryKey: ["all-records", "details", id],
    queryFn: () => fetchRecordDetails(id!),
    enabled: Boolean(id),
  });
