Add send otp api

This commit is contained in:
marzban-dev
2024-12-30 19:55:30 +03:30
parent aba3a1e427
commit ac3c3483d8
2 changed files with 32 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
// 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;
+4 -1
View File
@@ -1,6 +1,9 @@
export const API_ENDPOINTS = {
account : {
send_otp : "/accounts/send_otp",
},
auth: {
login: "/token",
signin: "/token",
logout: "/accounts/logout",
}
};