diff --git a/globalSettings.yml b/globalSettings.yml index d393efa..de9ed9d 100644 --- a/globalSettings.yml +++ b/globalSettings.yml @@ -9,19 +9,7 @@ courses: name: UX - path: ./1425/2025-fall-alex/modules/ name: "1425" - - path: ./1405/2025_spring_alex/ - name: 1405_old - path: ./3840_Telemetry/2025_spring_alex/modules/ name: Telem and Ops - - path: ./4850_AdvancedFE/2024-fall-alex/modules/ - name: Old Adv Frontend - - path: ./1430/2025-spring-jonathan/Modules/ - name: Jonathan UX - - path: ./1400/2025_spring_alex/modules/ - name: 1400-spring - - path: ./1420/2024-fall/Modules/ - name: 1420_old - - path: ./3820_BackEnd/2025-fall/Modules/ - name: jonathan-backend - path: ./4850_AdvancedFE/2026-spring-alex/modules name: Adv Frontend Spring diff --git a/src/app/CourseList.tsx b/src/app/CourseList.tsx index 910dc51..c559abe 100644 --- a/src/app/CourseList.tsx +++ b/src/app/CourseList.tsx @@ -1,5 +1,10 @@ "use client"; +import { Toggle } from "@/components/form/Toggle"; import { useLocalCoursesSettingsQuery } from "@/features/local/course/localCoursesHooks"; +import { + useGlobalSettingsQuery, + useUpdateGlobalSettingsMutation, +} from "@/features/local/globalSettings/globalSettingsHooks"; import { getDateKey, getTermName, @@ -7,42 +12,122 @@ import { } from "@/features/local/utils/timeUtils"; import { getCourseUrl } from "@/services/urlUtils"; import Link from "next/link"; +import { useState } from "react"; +import Modal, { useModal } from "@/components/Modal"; +import { Spinner } from "@/components/Spinner"; export default function CourseList() { const { data: allSettings } = useLocalCoursesSettingsQuery(); + const [isDeleting, setIsDeleting] = useState(false); const coursesByStartDate = groupByStartDate(allSettings); const sortedDates = Object.keys(coursesByStartDate).sort(); - console.log(allSettings, coursesByStartDate); - return ( -
- {sortedDates.map((startDate) => ( -
-
{getTermName(startDate)}
- {coursesByStartDate[getDateKey(startDate)].map((settings) => ( -
- - {settings.name} - -
- ))} -
- ))} +
+ setIsDeleting(set)} + /> +
+ {sortedDates.map((startDate) => ( +
+
{getTermName(startDate)}
+ {coursesByStartDate[getDateKey(startDate)].map((settings) => ( + + ))} +
+ ))} +
+
+ ); +} + +function CourseItem({ + courseName, + isDeleting, +}: { + courseName: string; + isDeleting: boolean; +}) { + const { data: globalSettings } = useGlobalSettingsQuery(); + const updateSettingsMutation = useUpdateGlobalSettingsMutation(); + const modal = useModal(); + + return ( +
+ + {courseName} + + {isDeleting && ( + + {({ closeModal }) => ( +
+
+ Are you sure you want to remove {courseName} from global + settings? +
+
+
+ + +
+ {updateSettingsMutation.isPending && } +
+ )} +
+ )}
); } diff --git a/src/components/form/Toggle.tsx b/src/components/form/Toggle.tsx new file mode 100644 index 0000000..1c324d7 --- /dev/null +++ b/src/components/form/Toggle.tsx @@ -0,0 +1,37 @@ +import type { FC } from "react"; + +export const Toggle: FC<{ + label: string; + value: boolean; + onChange: (checked: boolean) => void; +}> = ({ label, value, onChange }) => { + return ( + + ); +};