64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
|
|
import { apiClient } from './client';
|
||
|
|
|
||
|
|
export interface StaffMemberDto {
|
||
|
|
id: string;
|
||
|
|
userId: string;
|
||
|
|
email: string;
|
||
|
|
name: string;
|
||
|
|
isOwner: boolean;
|
||
|
|
permissions: string[] | null;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface StaffListResponse {
|
||
|
|
success: boolean;
|
||
|
|
data: {
|
||
|
|
members: StaffMemberDto[];
|
||
|
|
seats: {
|
||
|
|
used: number;
|
||
|
|
limit: number | null;
|
||
|
|
unlimited: boolean;
|
||
|
|
};
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface InviteStaffResponse {
|
||
|
|
success: boolean;
|
||
|
|
data: {
|
||
|
|
membershipId: string;
|
||
|
|
userId: string;
|
||
|
|
email: string;
|
||
|
|
temporaryPassword: string | null;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
export const staffApi = {
|
||
|
|
list: async (): Promise<StaffListResponse> => {
|
||
|
|
const response = await apiClient.get('/staff');
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
invite: async (body: {
|
||
|
|
email: string;
|
||
|
|
name: string;
|
||
|
|
permissionNames: string[];
|
||
|
|
}): Promise<InviteStaffResponse> => {
|
||
|
|
const response = await apiClient.post('/staff/invite', body);
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
updateMember: async (
|
||
|
|
membershipId: string,
|
||
|
|
body: { name?: string; permissionNames?: string[] },
|
||
|
|
): Promise<{ success: boolean; message: string }> => {
|
||
|
|
const response = await apiClient.patch(`/staff/members/${membershipId}`, body);
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
removeMember: async (
|
||
|
|
membershipId: string,
|
||
|
|
): Promise<{ success: boolean; message: string }> => {
|
||
|
|
const response = await apiClient.delete(`/staff/members/${membershipId}`);
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
};
|