import {
  SiteDefaultDataType,
  UpdateDefaultFormValues,
} from "@/components/forms/default/UpdateDefaultsForm";
import { getAllDefaults, getUpdateDefaults } from "@/service/apis/default";
import { ServerResponse } from "@/types";
import {
  useMutation,
  UseMutationResult,
  useQuery,
} from "@tanstack/react-query";

export const useGetAllDefaults = () =>
  useQuery({
    queryKey: ["get-all-defaults"],
    queryFn: () => getAllDefaults(),
    retry: false,
    refetchOnWindowFocus: false,
  });

export const useUpdateDefaults = () => {
  return useMutation<
    ServerResponse,
    Error,
    { data: UpdateDefaultFormValues },
    ServerResponse
  >({
    mutationFn: (payload) => getUpdateDefaults(payload),
  });
};
