refactor(UserSchedule): index by a unique id rather than name (#166)
* refactor(UserSchedule): index by a unique id rather than name * refactor: Update parameter names in schedule function jsdocs * refactor: change more instances of .name to .id * refactor: Fix typo in variable name and update references * refactor: Remove console.log statement * fix(chromatic): Update ScheduleListItem story * refactor: remove unused eslint rule
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { Course } from '@shared/types/Course';
|
||||
import type { UserSchedule } from '@shared/types/UserSchedule';
|
||||
import type { DialogProps } from '@views/components/common/Dialog/Dialog';
|
||||
import Dialog from '@views/components/common/Dialog/Dialog';
|
||||
import useSchedules from '@views/hooks/useSchedules';
|
||||
import React from 'react';
|
||||
|
||||
import Description from './Description';
|
||||
@@ -10,7 +10,6 @@ import HeadingAndActions from './HeadingAndActions';
|
||||
|
||||
export type CourseCatalogInjectedPopupProps = DialogProps & {
|
||||
course: Course;
|
||||
activeSchedule: UserSchedule;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -23,8 +22,9 @@ export type CourseCatalogInjectedPopupProps = DialogProps & {
|
||||
* @param {Function} props.onClose - The function to close the popup.
|
||||
* @returns {JSX.Element} The CourseCatalogInjectedPopup component.
|
||||
*/
|
||||
function CourseCatalogInjectedPopup({ course, activeSchedule, ...rest }: CourseCatalogInjectedPopupProps): JSX.Element {
|
||||
function CourseCatalogInjectedPopup({ course, ...rest }: CourseCatalogInjectedPopupProps): JSX.Element {
|
||||
const emptyRef = React.useRef<HTMLDivElement>(null);
|
||||
const [activeSchedule] = useSchedules();
|
||||
|
||||
return (
|
||||
<Dialog className='max-w-[780px] px-6' {...rest} initialFocus={emptyRef}>
|
||||
|
||||
@@ -100,9 +100,9 @@ export default function HeadingAndActions({ course, activeSchedule, onClose }: H
|
||||
const handleAddOrRemoveCourse = async () => {
|
||||
if (!activeSchedule) return;
|
||||
if (!courseAdded) {
|
||||
addCourse({ course, scheduleName: activeSchedule.name });
|
||||
addCourse({ course, scheduleId: activeSchedule.id });
|
||||
} else {
|
||||
removeCourse({ course, scheduleName: activeSchedule.name });
|
||||
removeCourse({ course, scheduleId: activeSchedule.id });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user