// imports

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

// types

export type SaveProductRequest = {
    product_slug: string;
};

const useSaveProduct = () => {
    // state

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

    // methods

    const handleSaveProduct = async (variables: SaveProductRequest) => {
        const { data } = await axios.post(`${API_ENDPOINTS.product.save}`, variables);
        return data;
    };

    return useMutation({
        mutationFn: (variables: SaveProductRequest) => handleSaveProduct(variables),
    });
};

export default useSaveProduct;
