import { useMutation } from "@tanstack/react-query";
import { api } from "../api";
import { useUpdateLayerCounter } from "../stores/useUpdateLayerCounter";

export const useUpdateStatus = ({ onSuccess }) => {
  const { toggleUpdateCounter } = useUpdateLayerCounter();

  return useMutation({
    mutationFn: (params) => {
      return api.put(
        `/api/placement_points/update_status?${params.toString()}`
      );
    },
    onSuccess: () => {
      toggleUpdateCounter();
      onSuccess();
    },
  });
};
