mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 19:28:17 +00:00
user account create
This commit is contained in:
81
apps/edr-freight-web/portal/src/services/account.ts
Normal file
81
apps/edr-freight-web/portal/src/services/account.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
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 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;
|
||||
};
|
||||
@@ -133,5 +133,5 @@ export const getFileUploadSettingByCode = endpoint<string, FileUploadSetting>(
|
||||
.get<
|
||||
ApiResponse<FileUploadSetting>
|
||||
>(`${URL_CONSTANTS.FILES.FILE_UPLOAD_SETTINGS_BY_CODE}/${code}`)
|
||||
.then((res) => res.data.data),
|
||||
.then((res: any) => res.data.data),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user