From d345dd25a89f5913ae2de3fc5b82452e5f59d240 Mon Sep 17 00:00:00 2001 From: alex-budko Date: Wed, 24 Aug 2022 11:41:45 -0400 Subject: [PATCH 01/20] iCal download feature --- frontend/plan/actions/index.js | 7 ++ .../plan/components/schedule/Schedule.tsx | 4 + .../schedule/ScheduleSelectorDropdown.tsx | 12 +- frontend/plan/package.json | 1 + frontend/plan/reducers/schedule.js | 112 ++++++++++++++++++ 5 files changed, 134 insertions(+), 2 deletions(-) diff --git a/frontend/plan/actions/index.js b/frontend/plan/actions/index.js index 031b90cc2..10cfcd2c2 100644 --- a/frontend/plan/actions/index.js +++ b/frontend/plan/actions/index.js @@ -25,6 +25,7 @@ export const REMOVE_SCHED_ITEM = "REMOVE_SCHED_ITEM"; export const DELETE_SCHEDULE = "DELETE_SCHEDULE"; export const RENAME_SCHEDULE = "RENAME_SCHEDULE"; export const DUPLICATE_SCHEDULE = "DUPLICATE_SCHEDULE"; +export const DOWNLOAD_SCHEDULE = "DOWNLOAD_SCHEDULE"; export const CLEAR_SCHEDULE = "CLEAR_SCHEDULE"; export const ENFORCE_SEMESTER = "ENFORCE_SEMESTER"; export const CLEAR_ALL_SCHEDULE_DATA = "CLEAR_ALL_SCHEDULE_DATA"; @@ -82,6 +83,12 @@ export const duplicateSchedule = (scheduleName) => ({ scheduleName, }); +// download schedule action +export const downloadSchedule = (scheduleName) => ({ + type: DOWNLOAD_SCHEDULE, + scheduleName, +}); + export const deleteSchedule = (scheduleName) => ({ type: DELETE_SCHEDULE, scheduleName, diff --git a/frontend/plan/components/schedule/Schedule.tsx b/frontend/plan/components/schedule/Schedule.tsx index bfee3588f..f55a9e9db 100644 --- a/frontend/plan/components/schedule/Schedule.tsx +++ b/frontend/plan/components/schedule/Schedule.tsx @@ -9,6 +9,7 @@ import { fetchCourseDetails, changeSchedule, duplicateSchedule, + downloadSchedule, deleteSchedule, openModal, } from "../../actions"; @@ -34,6 +35,7 @@ interface ScheduleProps { schedulesMutator: { copy: (scheduleName: string) => void; remove: (scheduleName: string) => void; + download: (scheduleName: string) => void; // NOT IN ORIGINAL PROPS create: () => void; @@ -332,6 +334,8 @@ const mapDispatchToProps = (dispatch: ThunkDispatch) => ({ schedulesMutator: { copy: (scheduleName: string) => dispatch(duplicateSchedule(scheduleName)), + download: (scheduleName: string) => + dispatch(downloadSchedule(scheduleName)), remove: (scheduleName: string) => dispatch(deleteSchedule(scheduleName)), rename: (oldName: string) => diff --git a/frontend/plan/components/schedule/ScheduleSelectorDropdown.tsx b/frontend/plan/components/schedule/ScheduleSelectorDropdown.tsx index 9a8a3db9e..5cd498d78 100644 --- a/frontend/plan/components/schedule/ScheduleSelectorDropdown.tsx +++ b/frontend/plan/components/schedule/ScheduleSelectorDropdown.tsx @@ -9,6 +9,7 @@ interface DropdownButton { makeActive: () => void; mutators: { copy: () => void; + download: () => void; remove: () => void; rename: () => void; }; @@ -66,7 +67,7 @@ const DropdownButton = ({ text, onClick, makeActive, - mutators: { copy, remove, rename }, + mutators: { copy, download, remove, rename }, }: DropdownButton) => (