Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create Snackbar When Copying Schedules #811

Merged
merged 12 commits into from
Dec 4, 2023
9 changes: 7 additions & 2 deletions apps/antalmanac/src/actions/AppStoreActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,18 @@ export const changeCourseColor = (sectionCode: string, term: string, newColor: s
AppStore.changeCourseColor(sectionCode, term, newColor);
};

export const copySchedule = (to: number) => {
export const copySchedule = (name: string, to: number) => {
logAnalytics({
category: analyticsEnum.addedClasses.title,
action: analyticsEnum.addedClasses.actions.COPY_SCHEDULE,
});

AppStore.copySchedule(to);
try {
AppStore.copySchedule(to);
openSnackbar('success', `Schedule copied to ${name}.`);
KevinWu098 marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
openSnackbar('error', `Could not copy schedule to ${name}.`);
}
};

export const toggleTheme = (radioGroupEvent: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ function handleClear() {
}
}

function createCopyHandler(index: number) {
function createCopyHandler(name: string, index: number) {
return () => {
copySchedule(index);
copySchedule(name, index);
};
}

Expand Down Expand Up @@ -148,12 +148,14 @@ function CopyScheduleButton() {
<MenuItem
key={index}
disabled={AppStore.getCurrentScheduleIndex() === index}
onClick={createCopyHandler(index)}
onClick={createCopyHandler(name, index)}
>
Copy to {name}
</MenuItem>
))}
<MenuItem onClick={createCopyHandler(scheduleNames.length)}>Copy to All Schedules</MenuItem>
<MenuItem onClick={createCopyHandler('All Schedules', scheduleNames.length)}>
Copy to All Schedules
</MenuItem>
</Menu>
</>
)}
Expand Down
Loading