From fc81e26164b51778946ac181afc19af51341b494 Mon Sep 17 00:00:00 2001 From: Daniel Xue Date: Sat, 24 Aug 2024 22:30:59 -0400 Subject: [PATCH 1/3] await backend calls. --- .../InstructorCalendar/InstructorCalendarModals.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx b/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx index a48a3cba..0d4ce04d 100644 --- a/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx +++ b/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx @@ -129,7 +129,7 @@ export const EditEventModal = (props: EditEventProps) => { setModalState(null); }; - const handleEditEvent = () => { + const handleEditEvent = async () => { const start = startDate; const end = endDate; const timeDeltaStart = start.getTime() - occurrence.start.getTime(); @@ -160,7 +160,7 @@ export const EditEventModal = (props: EditEventProps) => { ? dateToEventISO(moment(erpDate).endOf("day").toDate()) : null, }; - updateEvent(editedEvent); + await updateEvent(editedEvent); // Revalidate everything, since new event could have created many new occurrences. mutate(undefined, undefined, { sendRequest: false }); setModalState(null); @@ -175,8 +175,7 @@ export const EditEventModal = (props: EditEventProps) => { setModalState(null); }; - const handleDeleteEvent = () => { - deleteEvent(occurrence.event.id); + const handleDeleteEvent = async () => { // Optimistically delete all without revalidation, then revalidate all. occurrences.forEach( (o) => @@ -187,6 +186,7 @@ export const EditEventModal = (props: EditEventProps) => { revalidate: false, }) ); + await deleteEvent(occurrence.event.id); mutate(undefined, undefined, { sendRequest: false }); setModalState(null); }; @@ -327,7 +327,7 @@ export const NewEventModal = (props: NewEventProps) => { } }, [show]); - const handleCreateEvent = () => { + const handleCreateEvent = async () => { const newEvent: ApiPartialEvent = { title, start: dateToEventISO(startDate), @@ -348,8 +348,7 @@ export const NewEventModal = (props: NewEventProps) => { ? dateToEventISO(moment(erpDate).endOf("day").toDate()) : null, }; - createEvent(newEvent); - + await createEvent(newEvent); mutate(undefined, undefined, { sendRequest: false }); if (isRecurring) setLastSubmittedErp(erpDate); setModalState(false); From e256823181c998c38785bccc373af1f59d8436cb Mon Sep 17 00:00:00 2001 From: Daniel Xue Date: Sat, 24 Aug 2024 22:32:27 -0400 Subject: [PATCH 2/3] early close modal on optimistic rendering. --- .../Calendar/InstructorCalendar/InstructorCalendarModals.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx b/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx index 0d4ce04d..195416ba 100644 --- a/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx +++ b/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx @@ -186,9 +186,9 @@ export const EditEventModal = (props: EditEventProps) => { revalidate: false, }) ); + setModalState(null); await deleteEvent(occurrence.event.id); mutate(undefined, undefined, { sendRequest: false }); - setModalState(null); }; const handleClose = () => { From ca4a71ce4bc7152834e59c2e4c8779f4039e977f Mon Sep 17 00:00:00 2001 From: Daniel Xue Date: Sat, 24 Aug 2024 22:42:27 -0400 Subject: [PATCH 3/3] change text --- .../Calendar/InstructorCalendar/InstructorCalendarModals.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx b/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx index 195416ba..4857c8a9 100644 --- a/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx +++ b/frontend/components/Calendar/InstructorCalendar/InstructorCalendarModals.tsx @@ -241,7 +241,7 @@ export const EditEventModal = (props: EditEventProps) => { title={`Delete ${ occurrence.event.rule ? "Recurring " : "" }Event`} - occurrenceText="Delete This Event" + occurrenceText="Cancel This Event" eventText={ occurrence.event.rule ? "Delete All Events"