@@ -4,7 +4,7 @@ import type { EventInstance, EventType, EventDocumentUploadArgs } from 'shared';
44import { convertEventToFormValues } from '../../../utils/calendar.utils' ;
55import { useEditEvent , useEditScheduleSlot , useUploadManyDocuments } from '../../../hooks/calendar.hooks' ;
66import { useToast } from '../../../hooks/toasts.hooks' ;
7- import { AlertColor } from '@mui/material ' ;
7+ import ErrorPage from '../../ErrorPage ' ;
88import LoadingIndicator from '../../../components/LoadingIndicator' ;
99
1010export 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
8989export 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