feature: a minimal implementation of staff management is done.
This commit is contained in:
63
frontend/src/lib/api/staff.ts
Normal file
63
frontend/src/lib/api/staff.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
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;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user