// imports

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

// types

export type SignInRequest = {
    otp: string;
    phone: string;
};

// methods

export const handleSignIn = async (variables: SignInRequest) => {
    const { data } = await axios.post<SignInRequest>(`${API_ENDPOINTS.auth.signin}/`, variables);
    return data;
};

// composable

const useSignIn = () => {
    return useMutation({
        mutationFn: (variables: SignInRequest) => handleSignIn(variables)
    });
};

export default useSignIn;
