Files
hossein-por-shop/frontend/composables/api/auth/useOtp.ts
T
2024-12-30 19:55:30 +03:30

29 lines
571 B
TypeScript

// 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;