31 lines
573 B
TypeScript
31 lines
573 B
TypeScript
// imports
|
|
|
|
import { useMutation } from "@tanstack/vue-query";
|
|
import { API_ENDPOINTS } from "~/constants";
|
|
|
|
// types
|
|
|
|
export type OtpRequest = {
|
|
phone: string;
|
|
};
|
|
|
|
const useOtp = () => {
|
|
|
|
// state
|
|
|
|
const { $axios: axios } = useNuxtApp();
|
|
|
|
// methods
|
|
|
|
const handleOtp = async (variables: OtpRequest) => {
|
|
const { data } = await axios.post(`${API_ENDPOINTS.account.send_otp}`, variables);
|
|
return data;
|
|
};
|
|
|
|
return useMutation({
|
|
mutationFn: (variables: OtpRequest) => handleOtp(variables)
|
|
});
|
|
};
|
|
|
|
export default useOtp;
|