// imports

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

// types

export type OtpRequest = {
    phone: string;
};

// methods

export const handleOtp = async (variables: OtpRequest) => {
    const { data } = await axios.post<OtpRequest>(`${API_ENDPOINTS.account.send_otp}`, variables);
    return data;
};

// composable

const useOtp = () => {
    return useMutation({
        mutationFn: (variables: OtpRequest) => handleOtp(variables)
    });
};

export default useOtp;
