improvement: a flow added for owner users to make it possible for them to participate in treatments or tasks.
This commit is contained in:
48
frontend/src/lib/api/account.ts
Normal file
48
frontend/src/lib/api/account.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { apiClient } from './client';
|
||||
|
||||
export type WorkingHoursPayload = {
|
||||
autoRepeatWeekly: boolean;
|
||||
blocks: { dayOfWeek: number; startMinute: number; endMinute: number; sortOrder?: number }[];
|
||||
};
|
||||
|
||||
export type ParticipationData = {
|
||||
membershipId: string;
|
||||
orgType: 'CLINIC' | 'LAB';
|
||||
participatesInTreatments: boolean;
|
||||
participatesInTasks: boolean;
|
||||
hasWorkingHours: boolean;
|
||||
};
|
||||
|
||||
export type ParticipationUpdateData = ParticipationData & {
|
||||
permissions?: string[];
|
||||
};
|
||||
|
||||
export const accountApi = {
|
||||
getParticipation: async (): Promise<{ success: boolean; data: ParticipationData }> => {
|
||||
const response = await apiClient.get('/auth/profile/participation');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
updateParticipation: async (participate: boolean): Promise<{
|
||||
success: boolean;
|
||||
data: ParticipationUpdateData;
|
||||
}> => {
|
||||
const response = await apiClient.patch('/auth/profile/participation', { participate });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
getMyWorkingHours: async (): Promise<{
|
||||
success: boolean;
|
||||
data: WorkingHoursPayload & { hasWorkingHours: boolean };
|
||||
}> => {
|
||||
const response = await apiClient.get('/auth/profile/working-hours');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
upsertMyWorkingHours: async (
|
||||
payload: WorkingHoursPayload,
|
||||
): Promise<{ success: boolean; message: string }> => {
|
||||
const response = await apiClient.put('/auth/profile/working-hours', payload);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user