Files
hossein-por-shop/frontend/composables/api/account/useDeleteAddress.ts
T
2025-02-02 23:04:49 +03:30

33 lines
648 B
TypeScript

// imports
import { useMutation } from "@tanstack/vue-query";
import { API_ENDPOINTS } from "~/constants";
// types
export type DeleteAddressRequest = {
id: number;
};
const useDeleteAddress = () => {
// state
const { $axios: axios } = useNuxtApp();
// method
const handleDeleteAddress = async (id: number) => {
const { data } = await axios.delete(
`${API_ENDPOINTS.account.address.delete}/${id}`
);
return data;
};
return useMutation({
mutationFn: (data: DeleteAddressRequest) =>
handleDeleteAddress(data.id),
});
};
export default useDeleteAddress;