feat: use static data instead of fetching from the API
This commit is contained in:
334
src/demoData.js
Normal file
334
src/demoData.js
Normal file
@ -0,0 +1,334 @@
|
||||
export const DEMO_SESSION_INFO = {
|
||||
authenticated: true,
|
||||
appliedKeys: [],
|
||||
permissions: [],
|
||||
};
|
||||
|
||||
export const DEMO_CLASS_LIST = ["Demo", "Empty"];
|
||||
|
||||
export const DEMO_TIMETABLE = {
|
||||
timetables: [
|
||||
{
|
||||
id: 1,
|
||||
title: "Demo",
|
||||
createdAt: "2023-08-28T08:00:53.233Z",
|
||||
updatedAt: "2025-01-07T11:37:42.590Z",
|
||||
class: "Demo",
|
||||
validFrom: "2023-08-28T08:00:53.233Z",
|
||||
validUntil: null,
|
||||
data: [
|
||||
[
|
||||
[{}],
|
||||
[{ room: "R 206", length: 1, subject: "MA1", teacher: "Wen" }],
|
||||
[{ room: "R 307", length: 2, subject: "en1", teacher: "Fre" }],
|
||||
[{ room: "R 005", length: 2, subject: "de2", teacher: "Str" }],
|
||||
],
|
||||
[
|
||||
[{ room: "R 107", length: 2, subject: "IN2", teacher: "Kom" }],
|
||||
[{ room: "R 206", length: 2, subject: "MA1", teacher: "Wen" }],
|
||||
[{ room: "R 403", subject: "geo2", teacher: "Spl" }],
|
||||
[{ room: "", length: 1, subject: "", teacher: "" }],
|
||||
[{ room: "R 007", subject: "Sp-Th", teacher: "Bun" }],
|
||||
[{ room: "R 313", subject: "pw1", teacher: "Göl" }],
|
||||
],
|
||||
[
|
||||
[{ room: "R 313", length: 2, subject: "pw1", teacher: "Göl" }],
|
||||
[{ room: "R 314", length: 2, subject: "ge1", teacher: "Mog" }],
|
||||
[{ room: "R 307", subject: "en1", teacher: "Fre" }],
|
||||
[{ room: "R 403", length: 2, subject: "geo2", teacher: "Spl" }],
|
||||
[{}],
|
||||
[{ room: "R 002", length: 2, subject: "Sp-Fit", teacher: "Gan" }],
|
||||
],
|
||||
[
|
||||
[{ room: "R 206", length: 2, subject: "MA1", teacher: "Wen" }],
|
||||
[{ room: "R 107", length: 2, subject: "IN2", teacher: "Kom" }],
|
||||
[{ room: "R 209", subject: "ph1", teacher: "And" }],
|
||||
[{ room: "R 005", length: 2, subject: "Sp-Th", teacher: "Bun" }],
|
||||
],
|
||||
[
|
||||
[{ room: "R 107", length: 2, subject: "IN2", teacher: "Kom" }],
|
||||
[{ room: "R 314", length: 1, subject: "ge1", teacher: "Mog" }],
|
||||
[{ room: "R 005", subject: "de2", teacher: "Str" }],
|
||||
[{ room: "R 209", length: 2, subject: "ph1", teacher: "And" }],
|
||||
],
|
||||
],
|
||||
source: "Demo Provider",
|
||||
trusted: true,
|
||||
},
|
||||
],
|
||||
times: [
|
||||
{
|
||||
lesson: 1,
|
||||
start: "1970-01-01T07:00:00.000Z",
|
||||
end: "1970-01-01T07:45:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 3,
|
||||
start: "1970-01-01T08:50:00.000Z",
|
||||
end: "1970-01-01T09:35:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 5,
|
||||
start: "1970-01-01T11:10:00.000Z",
|
||||
end: "1970-01-01T11:55:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 6,
|
||||
start: "1970-01-01T12:00:00.000Z",
|
||||
end: "1970-01-01T12:45:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 7,
|
||||
start: "1970-01-01T12:50:00.000Z",
|
||||
end: "1970-01-01T13:35:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 8,
|
||||
start: "1970-01-01T13:40:00.000Z",
|
||||
end: "1970-01-01T14:25:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 9,
|
||||
start: "1970-01-01T14:30:00.000Z",
|
||||
end: "1970-01-01T15:15:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 10,
|
||||
start: "1970-01-01T15:20:00.000Z",
|
||||
end: "1970-01-01T16:05:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 11,
|
||||
start: "1970-01-01T16:10:00.000Z",
|
||||
end: "1970-01-01T16:55:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 2,
|
||||
start: "1970-01-01T07:45:00.000Z",
|
||||
end: "1970-01-01T08:30:00.000Z",
|
||||
},
|
||||
{
|
||||
lesson: 4,
|
||||
start: "1970-01-01T09:40:00.000Z",
|
||||
end: "1970-01-01T10:25:00.000Z",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export function getDemoSubstitutions(date) {
|
||||
let weekday = new Date(date).getDay();
|
||||
|
||||
switch (weekday) {
|
||||
case 1: {
|
||||
return [
|
||||
{
|
||||
id: 0,
|
||||
class: ["Demo"],
|
||||
type: "cancellation",
|
||||
rawType: "Entfall",
|
||||
lesson: 5,
|
||||
date: date,
|
||||
notes: null,
|
||||
teacher: "Str",
|
||||
change: {},
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
class: ["Demo"],
|
||||
type: "cancellation",
|
||||
rawType: "Entfall",
|
||||
lesson: 6,
|
||||
date: date,
|
||||
notes: null,
|
||||
teacher: "Str",
|
||||
change: {},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
class: ["Demo"],
|
||||
type: "change",
|
||||
rawType: "Raum-Vtr.",
|
||||
lesson: 3,
|
||||
date: date,
|
||||
notes: null,
|
||||
teacher: "Fre",
|
||||
change: {
|
||||
room: "308",
|
||||
teacher: "Fre",
|
||||
subject: "en1",
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
case 2: {
|
||||
return [
|
||||
{
|
||||
id: 3,
|
||||
class: ["Demo"],
|
||||
type: "cancellation",
|
||||
rawType: "Entfall",
|
||||
lesson: 7,
|
||||
date: date,
|
||||
notes: null,
|
||||
teacher: "Bun",
|
||||
change: {},
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
class: ["Demo"],
|
||||
type: "change",
|
||||
rawType: "Vertretung",
|
||||
lesson: 8,
|
||||
date: date,
|
||||
notes: null,
|
||||
teacher: "Bun",
|
||||
change: {
|
||||
room: "007",
|
||||
teacher: "Aci",
|
||||
subject: "Sp-Th",
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
case 3: {
|
||||
return [
|
||||
{
|
||||
id: 5,
|
||||
class: ["Demo"],
|
||||
type: "cancellation",
|
||||
rawType: "Entfall",
|
||||
lesson: 9,
|
||||
date: date,
|
||||
notes: "Aufgaben im Sekretariat",
|
||||
teacher: "Gan",
|
||||
change: {},
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
class: ["Demo"],
|
||||
type: "cancellation",
|
||||
rawType: "Entfall",
|
||||
lesson: 10,
|
||||
date: date,
|
||||
notes: null,
|
||||
teacher: "Gan",
|
||||
change: {},
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
export function getDemoHistory(date) {
|
||||
let weekday = new Date(date).getDay();
|
||||
|
||||
switch (weekday) {
|
||||
case 1: {
|
||||
return [
|
||||
...getDemoSubstitutions(date).map((e) => substitutionToChange(e)),
|
||||
];
|
||||
}
|
||||
case 2: {
|
||||
return [
|
||||
...getDemoSubstitutions(date).map((e) => substitutionToChange(e)),
|
||||
{
|
||||
id: 101,
|
||||
type: "deletion",
|
||||
class: ["Demo"],
|
||||
substitutionId: 100,
|
||||
lesson: 5,
|
||||
updatedAt: date - 47800000,
|
||||
date: date,
|
||||
teacher: null,
|
||||
change: {
|
||||
date: date,
|
||||
type: "cancellation",
|
||||
class: ["Demo"],
|
||||
notes: null,
|
||||
change: {},
|
||||
lesson: 5,
|
||||
rawType: "Entfall",
|
||||
teacher: "Spl",
|
||||
},
|
||||
parseEventId: 0,
|
||||
},
|
||||
{
|
||||
id: 100,
|
||||
type: "addition",
|
||||
class: ["Demo"],
|
||||
substitutionId: 100,
|
||||
lesson: 5,
|
||||
updatedAt: date - 57800000,
|
||||
date: date,
|
||||
teacher: null,
|
||||
change: {
|
||||
date: date,
|
||||
type: "cancellation",
|
||||
class: ["Demo"],
|
||||
notes: null,
|
||||
change: {},
|
||||
lesson: 5,
|
||||
rawType: "Entfall",
|
||||
teacher: "Spl",
|
||||
},
|
||||
parseEventId: 0,
|
||||
},
|
||||
];
|
||||
}
|
||||
case 3: {
|
||||
return [
|
||||
{
|
||||
id: 102,
|
||||
type: "change",
|
||||
class: ["Demo"],
|
||||
substitutionId: 5,
|
||||
lesson: 9,
|
||||
updatedAt: date - 57800000,
|
||||
date: date,
|
||||
teacher: null,
|
||||
change: {
|
||||
notes: {
|
||||
before: null,
|
||||
after: "Aufgaben im Sekretariat",
|
||||
},
|
||||
},
|
||||
parseEventId: 0,
|
||||
},
|
||||
...getDemoSubstitutions(date)
|
||||
.map((e) => substitutionToChange(e))
|
||||
.map((e) => {
|
||||
e.change.notes = null;
|
||||
return e;
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function substitutionToChange(substitution) {
|
||||
return {
|
||||
id: substitution.id,
|
||||
type: "addition",
|
||||
class: substitution.class,
|
||||
substitutionId: substitution.id,
|
||||
lesson: substitution.lesson,
|
||||
updatedAt: substitution.date - 46800000,
|
||||
date: substitution.date,
|
||||
teacher: null,
|
||||
change: {
|
||||
date: substitution.date,
|
||||
type: substitution.type,
|
||||
class: substitution.class,
|
||||
notes: substitution.notes,
|
||||
change: substitution.change,
|
||||
lesson: substitution.lesson,
|
||||
rawType: substitution.rawType,
|
||||
teacher: substitution.teacher,
|
||||
},
|
||||
parseEventId: 0,
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user