2023-08-27 21:38:59 +01:00
|
|
|
import api from "@/lib/api-client";
|
2024-05-04 15:46:11 +01:00
|
|
|
import {
|
|
|
|
IChangePassword,
|
2025-01-22 22:11:11 +00:00
|
|
|
ICollabToken,
|
2024-09-17 20:53:05 +06:00
|
|
|
IForgotPassword,
|
2024-05-04 15:46:11 +01:00
|
|
|
ILogin,
|
2024-09-19 15:51:51 +01:00
|
|
|
IPasswordReset,
|
2024-05-18 03:19:42 +01:00
|
|
|
ISetupWorkspace,
|
2024-09-19 15:51:51 +01:00
|
|
|
IVerifyUserToken,
|
2024-05-04 15:46:11 +01:00
|
|
|
} from "@/features/auth/types/auth.types";
|
2025-03-06 13:38:37 +00:00
|
|
|
import { IWorkspace } from "@/features/workspace/types/workspace.types.ts";
|
2023-08-27 21:38:59 +01:00
|
|
|
|
2025-01-22 22:11:11 +00:00
|
|
|
export async function login(data: ILogin): Promise<void> {
|
|
|
|
await api.post<void>("/auth/login", data);
|
2023-08-27 21:38:59 +01:00
|
|
|
}
|
|
|
|
|
2025-01-22 22:11:11 +00:00
|
|
|
export async function logout(): Promise<void> {
|
|
|
|
await api.post<void>("/auth/logout");
|
|
|
|
}
|
2024-05-04 15:46:11 +01:00
|
|
|
|
|
|
|
export async function changePassword(
|
2025-01-22 22:11:11 +00:00
|
|
|
data: IChangePassword,
|
2024-05-04 15:46:11 +01:00
|
|
|
): Promise<IChangePassword> {
|
|
|
|
const req = await api.post<IChangePassword>("/auth/change-password", data);
|
|
|
|
return req.data;
|
2023-08-27 21:38:59 +01:00
|
|
|
}
|
2024-05-18 03:19:42 +01:00
|
|
|
|
|
|
|
export async function setupWorkspace(
|
2025-01-22 22:11:11 +00:00
|
|
|
data: ISetupWorkspace,
|
2025-03-06 13:38:37 +00:00
|
|
|
): Promise<IWorkspace> {
|
|
|
|
const req = await api.post<IWorkspace>("/auth/setup", data);
|
2024-05-18 03:19:42 +01:00
|
|
|
return req.data;
|
|
|
|
}
|
2024-09-17 20:53:05 +06:00
|
|
|
|
2024-09-19 15:51:51 +01:00
|
|
|
export async function forgotPassword(data: IForgotPassword): Promise<void> {
|
2025-01-22 22:11:11 +00:00
|
|
|
await api.post<void>("/auth/forgot-password", data);
|
2024-09-19 15:51:51 +01:00
|
|
|
}
|
|
|
|
|
2025-01-22 22:11:11 +00:00
|
|
|
export async function passwordReset(data: IPasswordReset): Promise<void> {
|
|
|
|
await api.post<void>("/auth/password-reset", data);
|
2024-09-17 20:53:05 +06:00
|
|
|
}
|
|
|
|
|
2024-09-19 15:51:51 +01:00
|
|
|
export async function verifyUserToken(data: IVerifyUserToken): Promise<any> {
|
|
|
|
return api.post<any>("/auth/verify-token", data);
|
|
|
|
}
|
2025-01-22 22:11:11 +00:00
|
|
|
|
|
|
|
export async function getCollabToken(): Promise<ICollabToken> {
|
|
|
|
const req = await api.post<ICollabToken>("/auth/collab-token");
|
|
|
|
return req.data;
|
|
|
|
}
|