diff --git a/src/actions/v2/get-class-group-dates.ts b/src/actions/v2/get-class-group-dates.ts index 61c66b05..034d8c0e 100644 --- a/src/actions/v2/get-class-group-dates.ts +++ b/src/actions/v2/get-class-group-dates.ts @@ -1,3 +1,5 @@ +"use server"; + import redis from "@/lib/redis"; import { getOrSetRedis } from "@/lib/redis/get-set"; import { fetchUsosApi } from "@/lib/usos"; diff --git a/src/actions/v2/get-course-edition-details.ts b/src/actions/v2/get-course-edition-details.ts index bf360a32..2aeff867 100644 --- a/src/actions/v2/get-course-edition-details.ts +++ b/src/actions/v2/get-course-edition-details.ts @@ -1,23 +1,41 @@ +"use server"; + import redis from "@/lib/redis"; import { getOrSetRedis } from "@/lib/redis/get-set"; import { fetchUsosApi } from "@/lib/usos"; +import type { LecturerDTO, UsosLecturer } from "./get-lecturer"; + interface UsosCourseEdition { course_id: string; term_id: string; course_units_ids: string[] | null; } +function normalizeLecturers(lecturers: UsosLecturer[]): LecturerDTO[] { + return lecturers.map((lecturer) => { + return { + id: lecturer.id, + firstName: lecturer.first_name, + lastName: lecturer.last_name, + titlesBefore: lecturer.titles?.before ?? null, + titlesAfter: lecturer.titles?.after ?? null, + photoUrl: lecturer.photo_urls?.["50x50"] ?? null, + homepageUrl: lecturer.homepage_url ?? null, + profileUrl: lecturer.profile_url ?? null, + }; + }); +} + interface UsosCourseUnitGroup { course_unit_id: string; group_number: number; - lecturer_ids: string[] | null; + lecturers: UsosLecturer[]; } interface UsosCourseUnit { id: string; classtype_id: string; - use_groups: boolean; groups: UsosCourseUnitGroup[] | null; } @@ -25,7 +43,7 @@ export interface CourseGroupDTO { unitId: string; groupNumber: string; classtypeId: string; - lecturerIds: string[]; + lecturers: LecturerDTO[]; } export interface CourseEditionDetailsDTO { @@ -37,18 +55,18 @@ export interface CourseEditionDetailsDTO { async function fetchCourseUnitGroups( unitId: string, ): Promise { - const data = await fetchUsosApi("courses/course_unit", { + const data = await fetchUsosApi("courses/unit", { unit_id: unitId, - fields: "id|classtype_id|use_groups|groups[group_number|lecturer_ids]", + fields: "id|classtype_id|groups[group_number|lecturers]", }); - if (!data.use_groups || data.groups == null || data.groups.length === 0) { + if (data.groups == null || data.groups.length === 0) { return [ { unitId: data.id, groupNumber: "1", classtypeId: data.classtype_id, - lecturerIds: [], + lecturers: [], }, ]; } @@ -57,7 +75,7 @@ async function fetchCourseUnitGroups( unitId: data.id, groupNumber: String(group.group_number), classtypeId: data.classtype_id, - lecturerIds: group.lecturer_ids ?? [], + lecturers: normalizeLecturers(group.lecturers), })); } diff --git a/src/actions/v2/get-course-editions-details.ts b/src/actions/v2/get-course-editions-details.ts index dda42e0c..a045d836 100644 --- a/src/actions/v2/get-course-editions-details.ts +++ b/src/actions/v2/get-course-editions-details.ts @@ -1,3 +1,5 @@ +"use server"; + import redis from "@/lib/redis"; import { getOrSetRedis } from "@/lib/redis/get-set"; import { fetchUsosApi } from "@/lib/usos"; diff --git a/src/actions/v2/get-course-editions-preview.ts b/src/actions/v2/get-course-editions-preview.ts index b6d004e6..5eef808e 100644 --- a/src/actions/v2/get-course-editions-preview.ts +++ b/src/actions/v2/get-course-editions-preview.ts @@ -1,3 +1,5 @@ +"use server"; + import { createHash } from "node:crypto"; import redis from "@/lib/redis"; diff --git a/src/actions/v2/get-course-groups-for-planner.ts b/src/actions/v2/get-course-groups-for-planner.ts index 4edd7e6f..0804cf79 100644 --- a/src/actions/v2/get-course-groups-for-planner.ts +++ b/src/actions/v2/get-course-groups-for-planner.ts @@ -1,4 +1,9 @@ -import type { GroupSchedulePattern } from "@/lib/utils/build-group-schedule-pattern"; +"use server"; + +import type { + GroupSchedulePattern, + ScheduleParity, +} from "@/lib/utils/build-group-schedule-pattern"; import { buildGroupSchedulePattern } from "@/lib/utils/build-group-schedule-pattern"; import type { ClassgroupDate } from "@/types"; @@ -6,7 +11,7 @@ import { getClassgroupDatesAction } from "./get-class-group-dates"; import type { CourseGroupDTO } from "./get-course-edition-details"; import { getCourseEditionDetailsAction } from "./get-course-edition-details"; import type { LecturerDTO } from "./get-lecturer"; -import { getLecturerAction } from "./get-lecturer"; +import { getTermAction } from "./get-term"; export interface PlannerGroupDTO { unitId: string; @@ -34,15 +39,40 @@ function toClassgroupDates( })); } -async function fetchGroupWithPattern(group: CourseGroupDTO): Promise<{ +function daysBetween(a: string, b: string): number { + const msPerDay = 1000 * 60 * 60 * 24; + return Math.round((new Date(b).getTime() - new Date(a).getTime()) / msPerDay); +} + +async function getSchedulePatternParity( + termId: string, + classGroupStartTime: string, +): Promise { + const term = await getTermAction(termId); + const weekNumber = + Math.floor(daysBetween(classGroupStartTime, term.startDate) / 7) + 1; + return weekNumber % 2 === 0 ? "odd" : "even"; +} + +async function fetchGroupWithPattern( + group: CourseGroupDTO, + termId: string, +): Promise<{ group: CourseGroupDTO; schedulePattern: GroupSchedulePattern | null; }> { const dates = await getClassgroupDatesAction(group.unitId, group.groupNumber); const classgroupDates = toClassgroupDates(dates); + const schedulePattern = buildGroupSchedulePattern(classgroupDates); + if (schedulePattern?.pattern === "biweekly") { + schedulePattern.parity = await getSchedulePatternParity( + termId, + dates[1].startTime ?? "", + ); + } return { group, - schedulePattern: buildGroupSchedulePattern(classgroupDates), + schedulePattern, }; } @@ -52,31 +82,17 @@ export async function getPlannerCourseGroupsAction( ): Promise { const editionDetails = await getCourseEditionDetailsAction(courseId, termId); - const [groupsWithPatterns, lecturersMap] = await Promise.all([ - Promise.all( - editionDetails.groups.map(async (group) => fetchGroupWithPattern(group)), + const groupsWithPatterns = await Promise.all( + editionDetails.groups.map(async (group) => + fetchGroupWithPattern(group, termId), ), - (async () => { - const uniqueLecturerIds = [ - ...new Set(editionDetails.groups.flatMap((g) => g.lecturerIds)), - ]; - const lecturerEntries = await Promise.all( - uniqueLecturerIds.map(async (id) => { - const lecturer = await getLecturerAction(id); - return [id, lecturer] as const; - }), - ); - return new Map(lecturerEntries); - })(), - ]); + ); return groupsWithPatterns.map(({ group, schedulePattern }) => ({ unitId: group.unitId, groupNumber: group.groupNumber, classtypeId: group.classtypeId, - lecturers: group.lecturerIds - .map((id) => lecturersMap.get(id)) - .filter((l): l is LecturerDTO => l != null), + lecturers: group.lecturers, schedulePattern, })); } diff --git a/src/actions/v2/get-faculties.ts b/src/actions/v2/get-faculties.ts new file mode 100644 index 00000000..4e8968df --- /dev/null +++ b/src/actions/v2/get-faculties.ts @@ -0,0 +1,97 @@ +interface Faculty { + value: string; + name: string; +} + +interface getFacultiesDTO { + data: Faculty[]; + isLoading: boolean; + isError: boolean; +} + +//in future can be replaced with database get + +export function getFacultiesAction(): getFacultiesDTO { + return { + data: [ + { + value: "W1", + name: "Wydział Architektury", + }, + { + value: "W2", + name: "Wydział Budownictwa Lądowego i Wodnego", + }, + { + value: "W3", + name: "Wydział Chemiczny", + }, + { + value: "W4N", + name: "Wydział Informatyki i Telekomunikacji", + }, + { + value: "W5", + name: "Wydział Elektryczny", + }, + { + value: "W6", + name: "Wydział Geoinżynierii, Górnictwa i Geologii", + }, + { + value: "W7", + name: "Wydział Inżynierii Środowiska", + }, + { + value: "W8N", + name: "Wydział Zarządzania", + }, + { + value: "W9", + name: "Wydział Mechaniczno-Energetyczny", + }, + { + value: "W10", + name: "Wydział Mechaniczny", + }, + { + value: "W11", + name: "Wydział Podstawowych Problemów Techniki", + }, + { + value: "W12", + name: "Wydział Elektroniki, Fotoniki i Mikrosystemów", + }, + { + value: "W13", + name: "Wydział Matematyki", + }, + { + value: "W14", + name: "Wydział Medyczny", + }, + { + value: "FLG", + name: "Filia w Legnicy", + }, + { + value: "SD1", + name: "Szkoła Doktorska Politechniki Wrocławskiej", + }, + { + value: "PRK24/S1", + name: "PRK24/S1", + }, + { + value: "PRK24/S3", + name: "PRK24/S3", + }, + { + value: "PWR", + name: "PWR", + }, + ], + isLoading: false, + isError: false, + }; +} diff --git a/src/actions/v2/get-faculty-registrations.ts b/src/actions/v2/get-faculty-registrations.ts index 77593aed..606535eb 100644 --- a/src/actions/v2/get-faculty-registrations.ts +++ b/src/actions/v2/get-faculty-registrations.ts @@ -1,3 +1,5 @@ +"use server"; + import redis from "@/lib/redis"; import { getOrSetRedis } from "@/lib/redis/get-set"; import { fetchUsosApi } from "@/lib/usos"; diff --git a/src/actions/v2/get-lecturer.ts b/src/actions/v2/get-lecturer.ts index aeb5c5c9..652fc4c3 100644 --- a/src/actions/v2/get-lecturer.ts +++ b/src/actions/v2/get-lecturer.ts @@ -1,8 +1,10 @@ +"use server"; + import redis from "@/lib/redis"; import { getOrSetRedis } from "@/lib/redis/get-set"; import { fetchUsosApi } from "@/lib/usos"; -interface UsosLecturer { +export interface UsosLecturer { id: string; first_name: string; last_name: string; diff --git a/src/actions/v2/get-registration-rounds.ts b/src/actions/v2/get-registration-rounds.ts index dada6be2..a06d624c 100644 --- a/src/actions/v2/get-registration-rounds.ts +++ b/src/actions/v2/get-registration-rounds.ts @@ -1,3 +1,5 @@ +"use server"; + import redis from "@/lib/redis"; import { getOrSetRedis } from "@/lib/redis/get-set"; import { fetchUsosApi } from "@/lib/usos"; @@ -37,10 +39,9 @@ export async function getRegistrationRoundsAction( `registrations/course_registration_rounds`, { registration_id: registrationId, - fields: "fields=id|name|status|registration_mode|start_date|end_date", + fields: "id|name|status|registration_mode|start_date|end_date", }, ); - return data.toSorted(sortByStartDateFunction); }, }); diff --git a/src/actions/v2/get-round-courses.ts b/src/actions/v2/get-round-courses.ts index ef40eded..dc9e1b2c 100644 --- a/src/actions/v2/get-round-courses.ts +++ b/src/actions/v2/get-round-courses.ts @@ -1,3 +1,5 @@ +"use server"; + import redis from "@/lib/redis"; import { getOrSetRedis } from "@/lib/redis/get-set"; import { fetchUsosApi } from "@/lib/usos"; diff --git a/src/actions/v2/get-term.ts b/src/actions/v2/get-term.ts new file mode 100644 index 00000000..7e5c1521 --- /dev/null +++ b/src/actions/v2/get-term.ts @@ -0,0 +1,48 @@ +"use server"; + +import redis from "@/lib/redis"; +import { getOrSetRedis } from "@/lib/redis/get-set"; +import { fetchUsosApi } from "@/lib/usos"; + +interface TermDTO { + id: string; + name: string; + startDate: string; + endDate: string; + finishDate: string; + isActive: boolean; +} + +interface UsosTerm { + id: string; + name: { pl: string }; + start_date: string; + end_date: string; + finish_date: string; + is_active: boolean; +} + +function normalizeTerm(data: UsosTerm): TermDTO { + return { + id: data.id, + name: data.name.pl, + startDate: data.start_date, + endDate: data.end_date, + finishDate: data.finish_date, + isActive: data.is_active, + }; +} + +export async function getTermAction(termId: string): Promise { + return getOrSetRedis({ + redis, + key: `usos:term:${termId}:`, + ttlSeconds: 60 * 60 * 24 * 7, + fetcher: async () => { + const data = await fetchUsosApi("terms/term", { + term_id: termId, + }); + return normalizeTerm(data); + }, + }); +} diff --git a/src/app/plans/edit/[id]/_components/app-sidebar.tsx b/src/app/plans/edit/[id]/_components/app-sidebar.tsx index cef47044..b960f635 100644 --- a/src/app/plans/edit/[id]/_components/app-sidebar.tsx +++ b/src/app/plans/edit/[id]/_components/app-sidebar.tsx @@ -6,7 +6,8 @@ import { isEqual } from "date-fns"; import { format } from "date-fns/format"; import React from "react"; -import { getFaculties } from "@/actions/get-faculties"; +import { getFacultiesAction } from "@/actions/v2/get-faculties"; +import { getFacultyRegistrationsAction } from "@/actions/v2/get-faculty-registrations"; import { Alerts } from "@/components/alerts"; import { AlgorithmDialog } from "@/components/algo-dialog"; import { GroupsAccordionItem } from "@/components/groups-accordion"; @@ -29,11 +30,10 @@ import { SidebarHeader, } from "@/components/ui/sidebar"; import { Skeleton } from "@/components/ui/skeleton"; -import { fetchClient } from "@/lib/fetch"; import type { usePlanType } from "@/lib/use-plan"; import { registrationReplacer } from "@/lib/utils"; import { serverToLocalPlan } from "@/lib/utils/server-to-local-plan"; -import type { CourseType, FacultyType, PlanResponseType } from "@/types"; +import type { CourseType, PlanResponseType } from "@/types"; import { OfflineAlert } from "./offline-alert"; import { SyncErrorAlert } from "./sync-error-alert"; @@ -64,25 +64,23 @@ export function AppSidebar({ offlineAlert: boolean; faculty: string | null; }) { - const faculties = useQuery({ - queryKey: ["faculties"], - queryFn: getFaculties, - }); + const faculties = getFacultiesAction(); const registrations = useQuery({ enabled: faculty !== null && faculty !== "", queryKey: ["registrations", faculty], queryFn: async () => { - const response = await fetchClient({ - url: `/departments/${encodeURIComponent(faculty ?? "")}/registrations`, - method: "GET", - }); + const registrationsDTO = await getFacultyRegistrationsAction( + faculty ?? "", + ); - if (!response.ok) { - throw new Error("Network response was not ok"); - } - - return response.json() as Promise; + return registrationsDTO.map((registrationDTO) => { + return { + id: registrationDTO.id, + name: registrationDTO.description, + departmentId: faculty ?? "W4N", + }; + }); }, }); @@ -190,7 +188,7 @@ export function AppSidebar({ ) : ( - {faculties.data?.map((f) => ( + {faculties.data.map((f) => ( { + const date = new Date(startTime).getDay(); + switch (date) { + case 0: { + return "niedziela"; + } + case 1: { + return "poniedziałek"; + } + case 2: { + return "wtorek"; + } + case 3: { + return "środa"; + } + case 4: { + return "czwartek"; + } + case 5: { + return "piątek"; + } + case 6: { + return "sobota"; + } + default: { + return "poniedziałek"; + } + } +}; + +const getLecturersString = (lecturers: LecturerDTO[]): string => { + let output = ""; + for (const l of lecturers) { + output += `${l.firstName} ${l.lastName}`; + } + //console.log("Wykladowcy", output) + return output; +}; + +const translateSchedulePatternParity = ( + parity: ScheduleParity, +): "-" | "TN" | "TP" | "!" => { + switch (parity) { + case "all": { + return "-"; + } + case "even": { + return "TP"; + } + case "odd": { + return "TN"; + } + case "unknown": { + return "!"; + } + } +}; + export function CreateNewPlanPage({ planId }: { planId: string }) { const session = useSession(); const isLoggedIn = session.data !== null; @@ -78,22 +145,85 @@ export function CreateNewPlanPage({ planId }: { planId: string }) { const coursesFunction = useMutation({ mutationKey: ["courses"], mutationFn: async (registrationId: string) => { - const onlindeFacultyId = - onlinePlan?.registrations[0]?.departmentId ?? - plan.registrations[0]?.departmentId; - const response = await fetchClient({ - url: `/departments/${encodeURIComponent(onlindeFacultyId)}/registrations/${encodeURIComponent(registrationId)}/courses`, - method: "GET", - }); + const rounds = await getRegistrationRoundsAction(registrationId); + + const nominalRound = rounds[0]; + + const roundCourses = await getRegistrationRoundCoursesAction( + nominalRound.id, + ); - if (!response.ok) { - toast.error( - "Coś poszło nie tak podczas pobierania kursów, spróbuj ponownie", + const normalizedCourses: CourseType = []; + + let index = 0; + + for (const course of roundCourses) { + const groups = await getPlannerCourseGroupsAction( + course.courseId, + course.termId, ); - throw new Error("Network response was not ok"); + + const newCourse: SingleCourse = { + id: course.courseId, + name: course.courseName, + groups: [], + registrationId, + }; + //console.log("przed zmianami", groups) + for (const group of groups) { + //console.log("grupa", group) + newCourse.groups.push({ + id: Math.random() * index, + name: course.courseName, + averageRating: "0.0", + opinionsCount: 0, + type: group.classtypeId as "W" | "C" | "L" | "S" | "P", + courseId: course.courseId, + createdAt: "", + updatedAt: "", + spotsOccupied: course.registrationsCount, + spotsTotal: course.limits, + isActive: true, + url: "", + lecturer: getLecturersString(group.lecturers), + lecturers: group.lecturers.map((lecturer) => { + return { + ...lecturer, + name: lecturer.firstName, + surname: lecturer.lastName, + createdAt: "", + updatedAt: "", + averageRating: "0", + opinionsCount: "0", + id: Number.parseInt(lecturer.id), + }; + }), + group: group.groupNumber, + + meetings: [ + { + id: Math.floor(Math.random() * 1000), + groupId: Number.parseInt(group.groupNumber), + startTime: group.schedulePattern?.startTime ?? "7:30", + endTime: group.schedulePattern?.endTime ?? "9:00", + week: translateSchedulePatternParity( + group.schedulePattern?.parity ?? "all", + ), + createdAt: "", + updatedAt: "", + day: getDayOfWeek( + group.schedulePattern?.startTime ?? "01.01.1970", + ), + }, + ], + }); + index++; + } + + normalizedCourses.push(newCourse); } - return response.json() as Promise; + return normalizedCourses; }, }); const { diff --git a/src/components/hour.tsx b/src/components/hour.tsx index eecae80a..c81ebd7f 100644 --- a/src/components/hour.tsx +++ b/src/components/hour.tsx @@ -15,7 +15,7 @@ function Hour({ hour, widthPx = "100" }: { hour: string; widthPx?: string }) { "relative z-0 text-xs leading-6 text-gray-500 after:absolute after:-z-10 after:bg-slate-200 dark:after:bg-slate-800", isHorizontal ? `after:top-1/2 after:h-[1px] after:w-[var(--after-width)] after:min-w-[130px]` - : "-translate-x-1/2 transform text-center after:left-1/2 after:top-[-30px] after:h-screen after:w-[1px]", + : "-translate-x-1/2 transform text-center after:left-1/2 after:top-[-30px] after:h-[5000px] after:w-[1px]", )} style={ isHorizontal diff --git a/src/lib/utils/build-group-schedule-pattern.ts b/src/lib/utils/build-group-schedule-pattern.ts index 9422867c..85d23025 100644 --- a/src/lib/utils/build-group-schedule-pattern.ts +++ b/src/lib/utils/build-group-schedule-pattern.ts @@ -21,7 +21,6 @@ export interface GroupSchedulePattern { } const WEEKLY_GAP = 7; -const BIWEEKLY_GAP = 14; const GAP_TOLERANCE = 2; function daysBetween(a: string, b: string): number { @@ -53,6 +52,79 @@ function addDays(isoDate: string, days: number): string { return d.toISOString().slice(0, 10); } +function getGapsMode(numbers: number[]): number[] { + if (numbers.length === 0) { + return []; + } + + const frequencyMap: Record = {}; + let maxFreq = 0; + + for (const gap of numbers) { + frequencyMap[gap] = (frequencyMap[gap] || 0) + 1; + if (frequencyMap[gap] > maxFreq) { + maxFreq = frequencyMap[gap]; + } + } + + const modes: number[] = []; + + for (const key in frequencyMap) { + if (frequencyMap[key] === maxFreq) { + modes.push(Number(key)); + } + } + + return modes; +} + +function getHoursMode(hours: string[]): string { + const frequencyMap: Record = {}; + let maxCount = 0; + let mode = hours[0]; + + for (const item of hours) { + frequencyMap[item] = (frequencyMap[item] || 0) + 1; + + if (frequencyMap[item] > maxCount) { + maxCount = frequencyMap[item]; + mode = item; + } + } + + return mode; +} + +export function getMostFrequentTimes(entries: ClassgroupDate[]): { + startTime: string; + endTime: string; +} { + const startTimes: string[] = []; + const endTimes: string[] = []; + + for (const entry of entries) { + const startTimePart = entry.startTime.split(" ")[1]; + const endTimePart = entry.endTime.split(" ")[1]; + + if (startTimePart) { + startTimes.push(startTimePart); + } + if (endTimePart) { + endTimes.push(endTimePart); + } + } + + const modeStartTime = getHoursMode(startTimes); + const modeEndTime = getHoursMode(endTimes); + + const baseDate = entries[0].date; + + return { + startTime: `${baseDate} ${modeStartTime}`, + endTime: `${baseDate} ${modeEndTime}`, + }; +} + export function buildGroupSchedulePattern( dates: ClassgroupDate[], ): GroupSchedulePattern | null { @@ -65,13 +137,15 @@ export function buildGroupSchedulePattern( const firstEntry = sorted[0]; const lastEntry = sorted.at(-1) ?? firstEntry; + const { startTime, endTime } = getMostFrequentTimes(dates); + if (sorted.length === 1) { return { pattern: "irregular", parity: "unknown", weekday: isoWeekday(firstDate), - startTime: firstEntry.startTime, - endTime: firstEntry.endTime, + startTime, + endTime, firstOccurrence: firstEntry.date, lastOccurrence: lastEntry.date, occurrencesCount: 1, @@ -84,15 +158,14 @@ export function buildGroupSchedulePattern( .map((entry, index) => daysBetween(sorted[index].date, entry.date)); const weeklyGaps = gaps.filter((g) => isNear(g, WEEKLY_GAP)); - const biweeklyGaps = gaps.filter((g) => isNear(g, BIWEEKLY_GAP)); const total = gaps.length; let pattern: SchedulePattern; let parity: ScheduleParity; let exceptions: string[] = []; - const allWeekly = weeklyGaps.length === total; - const allBiweekly = biweeklyGaps.length === total; + const allWeekly = getGapsMode(gaps).includes(7); + const allBiweekly = getGapsMode(gaps).includes(14); if (allWeekly) { pattern = "weekly"; @@ -127,8 +200,8 @@ export function buildGroupSchedulePattern( pattern, parity, weekday: isoWeekday(firstDate), - startTime: firstEntry.startTime, - endTime: firstEntry.endTime, + startTime, + endTime, firstOccurrence: firstEntry.date, lastOccurrence: lastEntry.date, occurrencesCount: sorted.length, diff --git a/src/lib/utils/server-to-local-plan.ts b/src/lib/utils/server-to-local-plan.ts index b0dc2f77..7a6f0a4b 100644 --- a/src/lib/utils/server-to-local-plan.ts +++ b/src/lib/utils/server-to-local-plan.ts @@ -8,6 +8,10 @@ import type { SingleGroup, } from "@/types"; +const formatMeetingTime = (groupMeetingTime: string): string => { + return `${groupMeetingTime.split(":")[0].slice(groupMeetingTime.split(":")[0].length - 2, groupMeetingTime.split(":")[0].length)}:${groupMeetingTime.split(":")[1]}`; +}; + export const serverToLocalPlan = ( courses: CourseType, shouldCourseBeChecked: ((course: SingleCourse) => boolean) | boolean, @@ -49,8 +53,10 @@ export const serverToLocalPlan = ( meeting.week === "-" ? "" : (meeting.week as "" | "TN" | "TP" | "!"), - endTime: meeting.endTime.split(":").slice(0, 2).join(":"), - startTime: meeting.startTime.split(":").slice(0, 2).join(":"), + //endTime: meeting.endTime.split(":").slice(0, 2).join(":"), + endTime: formatMeetingTime(meeting.endTime), + //startTime: meeting.startTime.split(":").slice(0, 2).join(":"), + startTime: formatMeetingTime(meeting.startTime), spotsOccupied: g.spotsOccupied, spotsTotal: g.spotsTotal, averageRating: Number.parseFloat(g.averageRating), @@ -61,5 +67,6 @@ export const serverToLocalPlan = ( .toSorted((a, b) => { return a.name.localeCompare(b.name); }); + //console.log("extended courses", extendedCourses) return extendedCourses; };