// imports

import { useMutation } from "@tanstack/vue-query";
import { API_ENDPOINTS } from "~/constants";

// types

export type SetOrderAddressRequest = {
    address_id: number;
};

const useSetOrderAddress = () => {
    // state

    const { $axios: axios } = useNuxtApp();

    // methods

    const handleSetOrderAddress = async (params: SetOrderAddressRequest) => {
        const { data } = await axios.post(
            API_ENDPOINTS.orders.delivery.set_address,
            { ...params }
        );
        return data;
    };

    return useMutation({
        mutationFn: (AddressData: SetOrderAddressRequest) =>
            handleSetOrderAddress(AddressData),
    });
};

export default useSetOrderAddress;
