Untitled
unknown
plain_text
a month ago
1.0 kB
2
Indexable
Never
import useAxios from '@/app/hooks/useAxios'; import useCustomToast from '@/app/hooks/useCustomToast'; import { useMutation, useQueryClient } from '@tanstack/react-query' import React from 'react' const useCityDelete = (cityID:string) => { const queryClient = useQueryClient(); const axios = useAxios(); const { customToast } = useCustomToast(); const mutation = useMutation({ mutationFn: (data: FormData) => { return axios.delete(`/v1/admin/cities/${cityID}`); }, onSuccess(data, variables, context) { queryClient.invalidateQueries({ queryKey: ['cities'] }) customToast({ title: data?.data?.message, variant: "success", }); }, onError(error: any, variables, context) { console.log("Errors", error); customToast({ title: "City delete failed", description: error?.response?.data?.message, variant: "destructive", }); }, }); return {mutation} } export default useCityDelete
Leave a Comment