mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
92 lines
1.8 KiB
TypeScript
92 lines
1.8 KiB
TypeScript
import { URL_CONSTANTS } from "@/constants/URLS";
|
|
import { CreateUserPayload } from "@/types/createUser";
|
|
import { VerificationCodePayload } from "@/types/generateVerificationCode";
|
|
import { UserTypeRequest } from "@/types/userTypeRequest";
|
|
import { client } from "@/utils/api";
|
|
import { ApiResponse } from "@edr/types";
|
|
import { GenerateVerifcationCodePayload } from "node_modules/@tria-plc/iamui-common/dist/types/shared/services/authService";
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// API
|
|
// -----------------------------------------------------------------------------
|
|
|
|
export const createUser = async (
|
|
body: CreateUserPayload
|
|
) => {
|
|
const res =
|
|
await client.post<
|
|
ApiResponse<any>
|
|
>(
|
|
URL_CONSTANTS.USERS.SIGN_UP,
|
|
body
|
|
);
|
|
|
|
return res.data;
|
|
};
|
|
|
|
export const getMyInfo = async () => {
|
|
const res =
|
|
await client.get<
|
|
ApiResponse<any>
|
|
>(
|
|
URL_CONSTANTS.USERS.ME
|
|
);
|
|
|
|
return res.data;
|
|
};
|
|
|
|
export const generateVerificationCode = async (
|
|
body: VerificationCodePayload
|
|
) => {
|
|
const res =
|
|
await client.patch<
|
|
ApiResponse<string>
|
|
>(
|
|
URL_CONSTANTS.USERS.GENERATE_VERIFICATION_CODE,
|
|
body
|
|
);
|
|
|
|
return res.data.data;
|
|
};
|
|
|
|
export const setPassword = async (
|
|
body: any
|
|
) => {
|
|
const res =
|
|
await client.patch<
|
|
ApiResponse<string>
|
|
>(
|
|
URL_CONSTANTS.USERS.SET_PASSWORD,
|
|
body
|
|
);
|
|
|
|
return res.data.data;
|
|
};
|
|
|
|
export const createOTP = async (
|
|
body: any
|
|
) => {
|
|
const res =
|
|
await client.post<
|
|
ApiResponse<any>
|
|
>(
|
|
URL_CONSTANTS.OTP.SEND,
|
|
body
|
|
);
|
|
|
|
return res.data;
|
|
};
|
|
|
|
export const verifyOTP = async (
|
|
body: any
|
|
) => {
|
|
const res =
|
|
await client.post<
|
|
ApiResponse<any>
|
|
>(
|
|
URL_CONSTANTS.OTP.VERIFY,
|
|
body
|
|
);
|
|
|
|
return res.data;
|
|
}; |