-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { $events } from "@/api/events"; | ||
import { findAcademicCalendarByGroups } from "@/lib/events/academic-calendar.tsx"; | ||
|
||
export function AcademicCalendarWidget() { | ||
const { data: eventGroups } = $events.useQuery("get", "/event-groups/"); | ||
const { data: predefined } = $events.useQuery("get", "/users/me/predefined"); | ||
|
||
if (!eventGroups || !predefined) return null; | ||
|
||
const groups = predefined.event_groups | ||
.map((v) => eventGroups.event_groups.find((g) => g.id === v)?.name) | ||
.filter((v) => v) as string[]; | ||
const academicCalendar = findAcademicCalendarByGroups(groups); | ||
|
||
if (!academicCalendar) return null; | ||
|
||
return ( | ||
<div className="group flex flex-row gap-4 rounded-2xl bg-primary-main px-4 py-6"> | ||
<div className="w-12"> | ||
<span className="icon-[ph--books] text-5xl text-brand-violet" /> | ||
</div> | ||
<div className="flex flex-col"> | ||
<div className="text-2xl font-semibold text-text-main"> | ||
<academicCalendar.Title /> | ||
</div> | ||
<div className="mt-2 whitespace-pre-wrap text-lg text-text-secondary/75"> | ||
<academicCalendar.Details /> | ||
</div> | ||
<a | ||
href="https://eduwiki.innopolis.university/index.php/AcademicCalendar" | ||
className="text-base text-text-secondary/75 hover:underline" | ||
> | ||
*based on <span className="text-brand-violet">Eduwiki</span>. | ||
</a> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { ReactElement } from "react"; | ||
|
||
export type AcademicCalendar = { | ||
groupPrefix: string; | ||
Title: () => ReactElement; | ||
Details: () => ReactElement; | ||
}; | ||
|
||
// prettier-ignore | ||
export const academicCalendar: AcademicCalendar[] = [{ | ||
groupPrefix: "B21", | ||
Title: () => <p>[B21] Semester F24: <span className="font-normal">Aug 26 - Dec 21</span></p>, | ||
Details: () => <> | ||
<p><span className="font-semibold">Winter break:</span> Dec 22 - Jan 12</p> | ||
</>, | ||
}, { | ||
groupPrefix: "B22", | ||
Title: () => <p>[B22] Semester F24: <span className="font-normal">Aug 26 - Dec 20</span></p>, | ||
Details: () => <> | ||
<p><span className="font-semibold">Exams:</span> Dec 10 - Dec 20</p> | ||
<p><span className="font-semibold">Winter break:</span> Dec 21 - Jan 19</p> | ||
</>, | ||
}, { | ||
groupPrefix: "B23", | ||
Title: () => <p>[B23] Semester F24: <span className="font-normal">Aug 26 - Dec 23</span></p>, | ||
Details: () => <> | ||
<p><span className="font-semibold">Exams:</span> Dec 10 - Dec 23</p> | ||
<p><span className="font-semibold">Winter break:</span> Dec 24 - Jan 19</p> | ||
</>, | ||
}, { | ||
groupPrefix: "B24-AI360", | ||
Title: () => <p>[B24-AI360] Semester F24: <span className="font-normal">Aug 26 - Dec 28</span></p>, | ||
Details: () => <> | ||
<p><span className="font-semibold">Exams:</span> Dec 10 - Dec 28</p> | ||
<p><span className="font-semibold">Winter break:</span> Dec 29 - Jan 19</p> | ||
</>, | ||
}, { | ||
groupPrefix: "B24", | ||
Title: () => <p>[B24] Semester F24: <span className="font-normal">Aug 26 - Dec 22</span></p>, | ||
Details: () => <> | ||
<p><span className="font-semibold">Exams:</span> Dec 10 - Dec 22</p> | ||
<p><span className="font-semibold">Winter break:</span> Dec 23 - Jan 19</p> | ||
</>, | ||
}, { | ||
groupPrefix: "M24", | ||
Title: () => <p>[M24] Semester F24: <span className="font-normal">Aug 26 - Dec 22</span></p>, | ||
Details: () => <> | ||
<p><span className="font-semibold">Exams:</span> Dec 10 - Dec 22</p> | ||
<p><span className="font-semibold">Winter break:</span> Dec 23 - Jan 19</p> | ||
</>, | ||
}]; | ||
|
||
export function findAcademicCalendarByGroups( | ||
groups: string[], | ||
): AcademicCalendar | undefined { | ||
return academicCalendar.find((calendar) => | ||
groups.some((group) => group.startsWith(calendar.groupPrefix)), | ||
); | ||
} |