feat: Added viewer
This commit is contained in:
17
viewer/lib/api.ts
Normal file
17
viewer/lib/api.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { SubstitutionData } from "./types";
|
||||
|
||||
export async function getData(): Promise<SubstitutionData | null> {
|
||||
try {
|
||||
const res = await fetch('http://localhost:3000/versioned/v3', {
|
||||
next: { revalidate: 60 },
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return res.json();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
49
viewer/lib/types.ts
Normal file
49
viewer/lib/types.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
export interface TeacherReference {
|
||||
name: string;
|
||||
code: string;
|
||||
}
|
||||
|
||||
export type AbsenceEntry =
|
||||
| { type: 'wholeDay'; teacher: string; teacherCode: string }
|
||||
| { type: 'single'; teacher: string; teacherCode: string; hours: string }
|
||||
| { type: 'range'; teacher: string; teacherCode: string; hours: { from: string; to: string } }
|
||||
| { type: 'exkurze'; teacher: string; teacherCode: string }
|
||||
| { type: 'zastoupen'; teacher: string; teacherCode: string; zastupuje: { teacher: string | null } }
|
||||
| { type: 'invalid'; original: string; teacher?: null; teacherCode?: null };
|
||||
|
||||
export interface ChangeEntry {
|
||||
text: string;
|
||||
backgroundColor?: string | null;
|
||||
foregroundColor?: string | null;
|
||||
}
|
||||
|
||||
export interface SubstitutionDayData {
|
||||
info: { inWork: boolean };
|
||||
takesPlace: string;
|
||||
changes: Record<string, (ChangeEntry | null)[]>;
|
||||
absence: AbsenceEntry[];
|
||||
}
|
||||
|
||||
export interface SubstitutionData {
|
||||
status: {
|
||||
currentUpdateSchedule: number;
|
||||
lastUpdated: string;
|
||||
}
|
||||
schedule: Record<string, SubstitutionDayData>;
|
||||
}
|
||||
|
||||
export interface Hour {
|
||||
subject: string;
|
||||
title: string;
|
||||
teacher: {
|
||||
code: string;
|
||||
name: string;
|
||||
}
|
||||
group?: string;
|
||||
room: string;
|
||||
}
|
||||
|
||||
export interface LocalData {
|
||||
class: string;
|
||||
timetable: Hour[][][];
|
||||
}
|
||||
6
viewer/lib/utils.ts
Normal file
6
viewer/lib/utils.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
Reference in New Issue
Block a user