@@ -8,15 +8,15 @@ import Navbar from "@/components/ui/Navbar";
88import Footer from "@/components/ui/Footer" ;
99import Accordion from "@/components/ui/Accordion" ;
1010
11- import FacultySelector from "@/components/cards/FacultySelector" ;
12- import CourseCard from "@/components/cards/CourseCard" ;
13- import ViewTimeTable from "@/components/cards/ViewTimeTable" ;
14- import { TimetableProvider } from "@/lib/TimeTableContext" ;
11+ // import FacultySelector from "@/components/cards/FacultySelector";
12+ // import CourseCard from "@/components/cards/CourseCard";
13+ // import ViewTimeTable from "@/components/cards/ViewTimeTable";
14+ // import { TimetableProvider } from "@/lib/TimeTableContext";
1515import { fullCourseData } from "@/lib/type" ;
1616const LOCAL_STORAGE_KEY = "selectedCourses" ;
1717
1818export default function View ( ) {
19- const [ selectedCourses , setSelectedCourses ] = useState < fullCourseData [ ] > ( ( ) => {
19+ const [ selectedCourses ] = useState < fullCourseData [ ] > ( ( ) => {
2020 if ( typeof window === "undefined" ) return [ ] ;
2121 try {
2222 const saved = localStorage . getItem ( "selectedCourses" ) ;
@@ -27,59 +27,59 @@ export default function View() {
2727 } ) ;
2828
2929
30- const facultySelectorOnConfirm = ( newCourse : fullCourseData ) => {
31- setSelectedCourses ( ( prevCourses ) => {
32- const existingIndex = prevCourses . findIndex (
33- ( course ) => course . id === newCourse . id
34- ) ;
35-
36- if ( existingIndex !== - 1 ) {
37- const existingCourse = prevCourses [ existingIndex ] ;
38-
39- // Replace faculty lists for matching slotNames, and add new ones if not already present
40- const updatedSlots = newCourse . courseSlots . map ( ( newSlot ) => {
41- const existingSlot = existingCourse . courseSlots . find (
42- ( slot ) => slot . slotName === newSlot . slotName
43- ) ;
44-
45- if ( existingSlot ) {
46- // Replace the faculty list
47- return {
48- ...existingSlot ,
49- slotFaculties : newSlot . slotFaculties ,
50- } ;
51- } else {
52- // New slot, just add it
53- return newSlot ;
54- }
55- } ) ;
56-
57- // Merge any slots from existingCourse that are not in newCourse
58- const preservedOldSlots = existingCourse . courseSlots . filter (
59- ( oldSlot ) =>
60- ! newCourse . courseSlots . some (
61- ( newSlot ) => newSlot . slotName === oldSlot . slotName
62- )
63- ) ;
64-
65- const mergedSlots = [ ...preservedOldSlots , ...updatedSlots ] ;
66-
67- const updatedCourse = {
68- ...existingCourse ,
69- courseSlots : mergedSlots ,
70- } ;
71-
72- const updatedCourses = [ ...prevCourses ] ;
73- updatedCourses [ existingIndex ] = updatedCourse ;
74-
75- return updatedCourses ;
76- } else {
77- // New course, add directly
78- return [ ...prevCourses , newCourse ] ;
79- }
80- }
81- ) ;
82- } ;
30+ // const facultySelectorOnConfirm = (newCourse: fullCourseData) => {
31+ // setSelectedCourses((prevCourses) => {
32+ // const existingIndex = prevCourses.findIndex(
33+ // (course) => course.id === newCourse.id
34+ // );
35+
36+ // if (existingIndex !== -1) {
37+ // const existingCourse = prevCourses[existingIndex];
38+
39+ // // Replace faculty lists for matching slotNames, and add new ones if not already present
40+ // const updatedSlots = newCourse.courseSlots.map((newSlot) => {
41+ // const existingSlot = existingCourse.courseSlots.find(
42+ // (slot) => slot.slotName === newSlot.slotName
43+ // );
44+
45+ // if (existingSlot) {
46+ // // Replace the faculty list
47+ // return {
48+ // ...existingSlot,
49+ // slotFaculties: newSlot.slotFaculties,
50+ // };
51+ // } else {
52+ // // New slot, just add it
53+ // return newSlot;
54+ // }
55+ // });
56+
57+ // // Merge any slots from existingCourse that are not in newCourse
58+ // const preservedOldSlots = existingCourse.courseSlots.filter(
59+ // (oldSlot) =>
60+ // !newCourse.courseSlots.some(
61+ // (newSlot) => newSlot.slotName === oldSlot.slotName
62+ // )
63+ // );
64+
65+ // const mergedSlots = [...preservedOldSlots, ...updatedSlots];
66+
67+ // const updatedCourse = {
68+ // ...existingCourse,
69+ // courseSlots: mergedSlots,
70+ // };
71+
72+ // const updatedCourses = [...prevCourses];
73+ // updatedCourses[existingIndex] = updatedCourse;
74+
75+ // return updatedCourses;
76+ // } else {
77+ // // New course, add directly
78+ // return [...prevCourses, newCourse];
79+ // }
80+ // }
81+ // );
82+ // };
8383
8484 useEffect ( ( ) => {
8585 if ( typeof window === "undefined" ) return ;
0 commit comments