Skip to content

Commit 8c5f840

Browse files
committed
1:1 version in EditEventModal
1 parent b11abca commit 8c5f840

2 files changed

Lines changed: 10 additions & 26 deletions

File tree

src/backend/src/services/calendar.services.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export default class CalendarService {
243243
* @param shopIds An array of shops associated with the event.
244244
* @param machineryIds An array of machinery associated with the event.
245245
* @param workPackageIds An array of work packages associated with the event.
246+
* @param scheduleSlots An array of schedule slots associated with the event.
246247
* @param questionDocumentLink The link to the question document.
247248
* @param location Location of the event.
248249
* @param zoomLink Zoom Link if the event is online.

src/frontend/src/pages/CalendarPage/Components/EditEventModal.tsx

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { EventInstance, EventType, EventDocumentUploadArgs } from 'shared';
44
import { convertEventToFormValues } from '../../../utils/calendar.utils';
55
import { useEditEvent, useEditScheduleSlot, useUploadManyDocuments } from '../../../hooks/calendar.hooks';
66
import { useToast } from '../../../hooks/toasts.hooks';
7-
import { AlertColor } from '@mui/material';
7+
import ErrorPage from '../../ErrorPage';
88
import LoadingIndicator from '../../../components/LoadingIndicator';
99

1010
export interface EditEventModalProps {
@@ -20,13 +20,8 @@ const EditEventModal: React.FC<EditEventModalProps> = ({ open, onClose, event, e
2020
const { mutateAsync: uploadDocuments } = useUploadManyDocuments();
2121
const { mutateAsync: editScheduleSlot } = useEditScheduleSlot(event.eventId, event.scheduleSlotId);
2222

23-
if (isError) {
24-
editEventModalError(error, toast);
25-
}
26-
27-
if (isLoading) {
28-
return <LoadingIndicator />;
29-
}
23+
if (isError) return <ErrorPage message={error?.message} />;
24+
if (isLoading) return <LoadingIndicator />;
3025

3126
const initialValues = convertEventToFormValues(event);
3227

@@ -69,7 +64,12 @@ const EditEventModal: React.FC<EditEventModalProps> = ({ open, onClose, event, e
6964

7065
toast.success('Event updated successfully!');
7166
} catch (e: unknown) {
72-
editEventModalError(e, toast);
67+
if (e instanceof Error) {
68+
toast.error(e.message, 5000);
69+
} else {
70+
toast.error('Failed to update event', 5000);
71+
}
72+
throw e;
7373
}
7474
};
7575

@@ -87,20 +87,3 @@ const EditEventModal: React.FC<EditEventModalProps> = ({ open, onClose, event, e
8787
};
8888

8989
export default EditEventModal;
90-
function editEventModalError(
91-
e: unknown,
92-
toast: {
93-
fire: (message: string, options: { type: AlertColor; autoHideDuration?: number }) => void;
94-
info(message: string, autoHideDuration?: number): void;
95-
success(message: string, autoHideDuration?: number): void;
96-
warning(message: string, autoHideDuration?: number): void;
97-
error(message: string, autoHideDuration?: number): void;
98-
}
99-
) {
100-
if (e instanceof Error) {
101-
toast.error(e.message, 5000);
102-
} else {
103-
toast.error('Failed to update event', 5000);
104-
}
105-
throw e;
106-
}

0 commit comments

Comments
 (0)