added delete address
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// 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;
|
||||
Reference in New Issue
Block a user