// 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();

    // methods

    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;
