diff --git a/src/components/calendarOptions/events/display-categories.tsx b/src/components/calendarOptions/events/display-categories.tsx
index ad5a8e8..f3f7f26 100644
--- a/src/components/calendarOptions/events/display-categories.tsx
+++ b/src/components/calendarOptions/events/display-categories.tsx
@@ -31,39 +31,54 @@ export default function DisplayCategories({
label={`${ordinalNumbers[yearGroup.year - 1]} Year`}
key={`${ordinalNumbers[yearGroup.year - 1]} Year`}
>
-
- {yearGroup.categories.map((category) => (
-
- ))}
+
+ {Object.entries(yearGroup.semesters).map(
+ ([semesterKey, categories]) => (
+
+
+ {categories.map((category) => (
+
+ ))}
+
+
+ ),
+ )}
) : (
- yearGroup.categories.length > 0 && (
+ !yearGroup.year && (
- {yearGroup.categories.map((category) => (
-
- ))}
+ {Object.values(yearGroup.semesters).flatMap((categories) =>
+ categories.map((category) => (
+
+ )),
+ )}
)
@@ -75,17 +90,19 @@ export default function DisplayCategories({
return (
{items.flatMap((yearGroup) =>
- yearGroup.categories.map((category) => (
-
- )),
+ Object.values(yearGroup.semesters).flatMap((categories) =>
+ categories.map((category) => (
+
+ )),
+ ),
)}
);
diff --git a/src/contexts/events-provider.tsx b/src/contexts/events-provider.tsx
index d09a9b5..3b87c72 100644
--- a/src/contexts/events-provider.tsx
+++ b/src/contexts/events-provider.tsx
@@ -56,7 +56,10 @@ function sortCategoriesByYear(
{ otherCategories: [], courseCategories: [] },
);
- const otherFormatted = { categories: otherCategories };
+ const otherFormatted = {
+ year: undefined,
+ semesters: { 0: otherCategories },
+ };
const courseCategoriesMap = courseCategories.reduce(
(acc, category) => {
@@ -65,15 +68,22 @@ function sortCategoriesByYear(
if (!acc[yearKey]) {
acc[yearKey] = {
year: category.course ? Number(category.course.year) : 0,
- categories: [category],
+ semesters: {},
};
- } else {
- acc[yearKey].categories.push(category);
}
+ const semesterKey = category.course?.semester ?? 0;
+ if (!acc[yearKey].semesters[semesterKey]) {
+ acc[yearKey].semesters[semesterKey] = [];
+ }
+ acc[yearKey].semesters[semesterKey].push(category);
+
return acc;
},
- {} as Record
,
+ {} as Record<
+ string,
+ { year: number; semesters: Record }
+ >,
);
const courseCategoriesFormatted = Object.values(courseCategoriesMap);
diff --git a/src/lib/types.ts b/src/lib/types.ts
index 6118d05..0455ed6 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -65,7 +65,7 @@ export type IShiftsSorted = {
semesters: Record<
number,
Record<
- string,
+ number,
{
courseName: string;
color: string;
@@ -122,7 +122,7 @@ export interface IEventCategory {
export type IEventCategoriesSorted = {
year?: number;
- categories: IEventCategory[];
+ semesters: Record;
}[];
export interface IItemProps {