24 lines
978 B
TypeScript
24 lines
978 B
TypeScript
import type { AxiosResponse } from "axios";
|
|
import api, { apiGet, apiPatch, apiPost } from "./axios";
|
|
import type { UserMeResponse, LoginRequest, LoginResponse, LoginKeyResponse, RegisterRequest } from "../types/api";
|
|
|
|
export const login = (payload: LoginRequest): Promise<AxiosResponse<LoginResponse>> =>
|
|
apiPost<LoginResponse>("/api/v1/auth/login", payload);
|
|
|
|
export const getLoginKey = (): Promise<AxiosResponse<LoginKeyResponse>> =>
|
|
apiGet<LoginKeyResponse>("/api/v1/auth/login-key");
|
|
|
|
export const fetchMe = (): Promise<AxiosResponse<UserMeResponse>> => apiGet<UserMeResponse>("/api/v1/auth/me");
|
|
|
|
export const register = (payload: RegisterRequest): Promise<AxiosResponse<{ message: string }>> =>
|
|
apiPost("/api/v1/auth/register", payload);
|
|
|
|
export const updateProfile = (payload: {
|
|
full_name?: string;
|
|
clinical_department?: string;
|
|
current_password?: string;
|
|
password?: string;
|
|
}) => apiPatch<UserMeResponse>("/api/v1/auth/me", payload);
|
|
|
|
export default api;
|