add user invite
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { axios, type Page, type PageResult, type Role } from "timi-web";
|
||||
import { axios, type LoginResponse, type Page, type PageResult, type Role } from "timi-web";
|
||||
import type { ManagedUser } from "@/types/ManagedUser";
|
||||
import { withCurrentStoreId, withCurrentStorePage } from "@/utils/store";
|
||||
|
||||
@@ -9,6 +9,34 @@ type ListOptions = {
|
||||
storeId?: string;
|
||||
};
|
||||
|
||||
export type InviteRequest = {
|
||||
storeId?: string;
|
||||
roleId: string;
|
||||
};
|
||||
|
||||
export type InviteResult = {
|
||||
code: string;
|
||||
expireAt: number;
|
||||
};
|
||||
|
||||
export type InviteValidateResult = {
|
||||
valid: boolean;
|
||||
expireAt: number;
|
||||
};
|
||||
|
||||
export type InviteRegisterData = {
|
||||
code: string;
|
||||
phoneNo: string;
|
||||
name: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
export type InviteRegisterRequest = {
|
||||
captchaId: string;
|
||||
captcha: string;
|
||||
data: InviteRegisterData;
|
||||
};
|
||||
|
||||
async function list(page: Page<ManagedUser>, options?: ListOptions): Promise<PageResult<ManagedUser>> {
|
||||
if (options?.allStores) {
|
||||
return await axios.post(`${BASE_URI}/list`, page);
|
||||
@@ -55,6 +83,18 @@ async function roleList(): Promise<Role[]> {
|
||||
return await axios.post(`${BASE_URI}/role/list`);
|
||||
}
|
||||
|
||||
async function invite(request: InviteRequest): Promise<InviteResult> {
|
||||
return await axios.post(`${BASE_URI}/invite`, request);
|
||||
}
|
||||
|
||||
async function validateInvite(code: string): Promise<InviteValidateResult> {
|
||||
return await axios.post(`${BASE_URI}/invite/validate`, { code });
|
||||
}
|
||||
|
||||
async function registerByInvite(request: InviteRegisterRequest): Promise<LoginResponse> {
|
||||
return await axios.post(`${BASE_URI}/invite/register`, request);
|
||||
}
|
||||
|
||||
export default {
|
||||
list,
|
||||
detail,
|
||||
@@ -62,5 +102,8 @@ export default {
|
||||
update,
|
||||
transferStore,
|
||||
remove,
|
||||
roleList
|
||||
roleList,
|
||||
invite,
|
||||
validateInvite,
|
||||
registerByInvite
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user