95 lines
2.3 KiB
TypeScript
95 lines
2.3 KiB
TypeScript
import { apiClient } from './client';
|
|
|
|
export interface StaffMemberDto {
|
|
id: string;
|
|
userId: string;
|
|
email: string;
|
|
name: string;
|
|
isOwner: boolean;
|
|
isActive: boolean;
|
|
invitationStatus: 'ACTIVE' | 'PENDING' | 'EXPIRED';
|
|
invitedAt: string | null;
|
|
acceptedAt: string | null;
|
|
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;
|
|
invitationId: string | null;
|
|
invitationUrl: string | null;
|
|
invitationStatus: 'PENDING' | 'ACCEPTED';
|
|
};
|
|
}
|
|
|
|
export interface PreviewInviteResponse {
|
|
success: boolean;
|
|
data: {
|
|
email: string;
|
|
name: string;
|
|
organizationName: string;
|
|
expiresAt: string;
|
|
status: 'PENDING' | 'ACCEPTED';
|
|
};
|
|
}
|
|
|
|
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;
|
|
},
|
|
|
|
previewInvite: async (token: string): Promise<PreviewInviteResponse> => {
|
|
const response = await apiClient.get(`/staff/invitations/preview?token=${encodeURIComponent(token)}`);
|
|
return response.data;
|
|
},
|
|
|
|
acceptInvite: async (body: {
|
|
token: string;
|
|
password: string;
|
|
name: string;
|
|
}): Promise<{ success: boolean; message: string; data: { email: string } }> => {
|
|
const response = await apiClient.post('/staff/invitations/accept', 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;
|
|
},
|
|
};
|