import { useMutation, UseMutationResult } from "react-query"; import useAxios from "./useAxios"; import { HEADER_KEY } from "../config"; import { AxiosResponse } from "../../types/Axios"; type DataToSend = { id?: number | string | any; key?: string | any; }; function useDeleteMutation( key: any, url: string, toast: boolean = true, ): UseMutationResult { const axios = useAxios(); return useMutation( async (dataToSend) => { const { data } = await axios.delete(url + `/` + dataToSend?.id, { headers: { [HEADER_KEY]: key, ["X-Custom-Message"]: toast, }, }); return data; }, ); } export default useDeleteMutation;