// imports

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

// types

export type CreateContactUsTicketRequest = {
    full_name: string;
    email: string;
    phone: string;
    type: "ORDER_FOLLOW_UP" | "SUGGESTION" | "COMPLAINT";
    message: string;
};

const useCreateContactUsTicket = () => {
    // state

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

    // methods

    const handleCreateContactUsTicket = async (params: CreateContactUsTicketRequest) => {
        const { data } = await axios.post(API_ENDPOINTS.tickets.contact_us_ticket, params);
        return data;
    };

    return useMutation({
        mutationFn: (messageData: CreateContactUsTicketRequest) => handleCreateContactUsTicket(messageData),
    });
};

export default useCreateContactUsTicket;
