From 94dfd77523af95003aadd02fb2f92420c680eeb0 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Thu, 13 Jun 2024 21:32:31 -0700 Subject: [PATCH] feat: support switching skeleton schedules (#994) --- .../components/Calendar/CalendarToolbar.tsx | 63 +++++++++++++------ .../AddedCourses/AddedCoursePane.tsx | 10 +-- .../src/components/buttons/Copy.tsx | 17 ++--- apps/antalmanac/src/stores/AppStore.ts | 10 ++- apps/antalmanac/src/stores/Schedules.ts | 6 +- 5 files changed, 73 insertions(+), 33 deletions(-) diff --git a/apps/antalmanac/src/components/Calendar/CalendarToolbar.tsx b/apps/antalmanac/src/components/Calendar/CalendarToolbar.tsx index 863eba1d8..85e33f543 100644 --- a/apps/antalmanac/src/components/Calendar/CalendarToolbar.tsx +++ b/apps/antalmanac/src/components/Calendar/CalendarToolbar.tsx @@ -46,7 +46,12 @@ function handleUndo() { undoDelete(null); } -function EditScheduleButton(props: { index: number }) { +interface RenameScheduleButtonProps { + index: number; + disabled?: boolean; +} + +function RenameScheduleButton({ index, disabled }: RenameScheduleButtonProps) { const [open, setOpen] = useState(false); const handleOpen = useCallback(() => { @@ -59,15 +64,24 @@ function EditScheduleButton(props: { index: number }) { return ( - - - - + + + + + + + + ); } -function DeleteScheduleButton(props: { index: number }) { +interface DeleteScheduleButtonProps { + index: number; + disabled?: boolean; +} + +function DeleteScheduleButton({ index, disabled }: DeleteScheduleButtonProps) { const [open, setOpen] = useState(false); const handleOpen = useCallback(() => { @@ -80,18 +94,30 @@ function DeleteScheduleButton(props: { index: number }) { return ( - - - - + + + + + + + + ); } +interface AddScheduleButtonProps { + disabled: boolean; +} + /** * MenuItem nested in the select menu to add a new schedule through a dialog. */ -function AddScheduleButton() { +function AddScheduleButton({ disabled }: AddScheduleButtonProps) { const [open, setOpen] = useState(false); const handleOpen = useCallback(() => { @@ -104,7 +130,7 @@ function AddScheduleButton() { return ( <> - - - - + + + ))} - + @@ -251,6 +276,7 @@ function CalendarPaneToolbar(props: CalendarPaneToolbarProps) { const { showFinalsSchedule, toggleDisplayFinalsSchedule } = props; const [scheduleNames, setScheduleNames] = useState(AppStore.getScheduleNames()); const [skeletonMode, setSkeletonMode] = useState(AppStore.getSkeletonMode()); + const [skeletonScheduleNames, setSkeletonScheduleNames] = useState(AppStore.getSkeletonScheduleNames()); const handleToggleFinals = useCallback(() => { logAnalytics({ @@ -267,6 +293,7 @@ function CalendarPaneToolbar(props: CalendarPaneToolbarProps) { useEffect(() => { const handleSkeletonModeChange = () => { setSkeletonMode(AppStore.getSkeletonMode()); + setSkeletonScheduleNames(AppStore.getSkeletonScheduleNames()); }; AppStore.on('skeletonModeChange', handleSkeletonModeChange); @@ -298,7 +325,7 @@ function CalendarPaneToolbar(props: CalendarPaneToolbarProps) { }} > - +