Skip to content

Commit 1f8a121

Browse files
authored
chore: merge pull request PapillonApp#326 from tom-theret/timetables/infos
Timetables/infos
2 parents 1464d7c + 7c2d717 commit 1f8a121

File tree

6 files changed

+56
-15
lines changed

6 files changed

+56
-15
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"buffer": "^6.0.3",
2727
"cal-parser": "^1.0.2",
2828
"date-fns": "^3.6.0",
29-
"esup-multi.js": "^1.0.1",
29+
"esup-multi.js": "^1.0.2",
3030
"expo": "^51.0.36",
3131
"expo-asset": "^10.0.10",
3232
"expo-auth-session": "~5.5.2",

src/services/multi/data/timetable.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { MultiAccount } from "@/stores/account/types";
2-
import type { Timetable, TimetableClass} from "../../shared/Timetable";
2+
import { TimetableClassStatus, type Timetable, type TimetableClass} from "../../shared/Timetable";
33
import { weekNumberToDateRange } from "@/utils/epochWeekNumber";
44
import type { EventResponse } from "esup-multi.js";
55
import { ErrorServiceUnauthenticated } from "@/services/shared/errors";
@@ -11,10 +11,15 @@ const decodeTimetableClass = (c: EventResponse): TimetableClass => ({
1111
title: c.course.label,
1212
startTimestamp: new Date(c.startDateTime).getTime(),
1313
endTimestamp: new Date(c.endDateTime).getTime(),
14-
room: c.course.online ? "En ligne" : c.rooms.map((room: any) => room.label).join(", "),
15-
teacher: c.teachers.map((teacher: any) => teacher.displayname).join(", "),
14+
room: c.rooms.map((room: any) => room.label).join(", ") || void 0,
15+
building: c.rooms.map((room: any) => room.building).filter((building: any) => building).join(", ") || void 0,
16+
teacher: c.teachers.map((teacher: any) => teacher.displayname).join(", ") || void 0,
17+
group: c.groups.map((group: any) => group.label).join(", ") || void 0,
1618
backgroundColor: c.course.color,
19+
status: c.course.online ? TimetableClassStatus.ONLINE : void 0,
20+
statusText: c.course.online ? TimetableClassStatus.ONLINE : void 0,
1721
source: "UPHF",
22+
url: c.course.url,
1823
});
1924

2025
export const getTimetableForWeek = async (account: MultiAccount, weekNumber: number): Promise<Timetable> => {
@@ -30,9 +35,9 @@ export const getTimetableForWeek = async (account: MultiAccount, weekNumber: num
3035
course: event.course,
3136
rooms: event.rooms,
3237
teachers: event.teachers,
33-
groups: event.groups
38+
groups: event.groups,
3439
}))
3540
);
3641

37-
return await eventsList.map(decodeTimetableClass); // TODO for Papillon team: add the group to the timetable
42+
return await eventsList.map(decodeTimetableClass);
3843
};

src/services/pronote/timetable.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const decodeTimetableClass = (c: pronote.TimetableClassLesson | pronote.Timetabl
1111
startTimestamp: c.startDate.getTime(),
1212
endTimestamp: c.endDate.getTime(),
1313
additionalNotes: c.notes,
14-
backgroundColor: c.backgroundColor
14+
backgroundColor: c.backgroundColor,
1515
};
1616

1717
if (c.is === "lesson") {
@@ -22,6 +22,7 @@ const decodeTimetableClass = (c: pronote.TimetableClassLesson | pronote.Timetabl
2222
subject: c.subject!.name,
2323
room: c.classrooms.join(", ") || void 0,
2424
teacher: c.teacherNames?.join(", ") ?? void 0,
25+
group: c.groupNames.join(", ") || void 0,
2526
status: c.status === "Cours annulé" || c.status === "Prof. absent" || c.status === "Classe absente" || c.status === "Prof./pers. absent" || c.status === "Sortie pédagogique" ? TimetableClassStatus.CANCELED : c.test ? TimetableClassStatus.TEST : void 0,
2627
statusText: c.test ? "Devoir Surveillé" : c.status,
2728
...base

src/services/shared/Timetable.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ export interface TimetableClass {
77
startTimestamp: number
88
endTimestamp: number
99
additionalNotes?: string
10+
building?: string
1011
room?: string
1112
teacher?: string
13+
group?: string
1214
backgroundColor?: string,
1315
status?: TimetableClassStatus,
1416
statusText?: string,
1517
source?: string
18+
url?: string
1619
}
1720

1821
export type Timetable = Array<TimetableClass>;
1922

2023
export enum TimetableClassStatus {
2124
CANCELED = "Annulé",
2225
MODIFIED = "Modifié",
26+
ONLINE = "En ligne",
2327
TEST = "ds",
2428
}

src/views/account/Lessons/Document.tsx

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ScrollView,
1111
Text,
1212
Platform,
13+
Linking,
1314
} from "react-native";
1415
import { Homework, HomeworkReturnType } from "@/services/shared/Homework";
1516
import { getSubjectData } from "@/services/shared/Subject";
@@ -18,16 +19,19 @@ import { Screen } from "@/router/helpers/types";
1819
import { formatDistance } from "date-fns";
1920
import { fr } from "date-fns/locale";
2021
import {
22+
Building,
2123
Clock,
2224
DoorOpen,
2325
FileText,
2426
Hourglass,
2527
Info,
28+
LinkIcon,
2629
PersonStanding,
30+
Users,
2731
} from "lucide-react-native";
2832

2933
import * as WebBrowser from "expo-web-browser";
30-
import { useTheme } from "@react-navigation/native";
34+
import { Link, useTheme } from "@react-navigation/native";
3135
import RenderHTML from "react-native-render-html";
3236
import { useSafeAreaInsets } from "react-native-safe-area-context";
3337
import { PapillonModernHeader } from "@/components/Global/PapillonModernHeader";
@@ -134,21 +138,44 @@ const LessonDocument: Screen<"LessonDocument"> = ({ route, navigation }) => {
134138
},
135139
],
136140
},
141+
{
142+
title: "Cours en ligne",
143+
informations: [
144+
{
145+
icon: <LinkIcon />,
146+
text: "URL du cours",
147+
value: lesson.url,
148+
enabled: lesson.url != null,
149+
},
150+
]
151+
},
137152
{
138153
title: "Contexte",
139154
informations: [
155+
{
156+
icon: <Building />,
157+
text: lesson.building?.includes(",") ? "Bâtiments" : "Bâtiment",
158+
value: lesson.building,
159+
enabled: lesson.building != null,
160+
},
140161
{
141162
icon: <DoorOpen />,
142-
text: "Salle de classe",
163+
text: lesson.room?.includes(",") ? "Salles de classe" : "Salle de classe",
143164
value: lesson.room,
144165
enabled: lesson.room != null,
145166
},
146167
{
147168
icon: <PersonStanding />,
148-
text: "Professeur",
169+
text: lesson.teacher?.includes(",") ? "Professeurs" : "Professeur",
149170
value: lesson.teacher,
150171
enabled: lesson.teacher != null,
151172
},
173+
{
174+
icon: <Users />,
175+
text: lesson.group?.includes(",") ? "Groupes" : "Groupe",
176+
value: lesson.group,
177+
enabled: lesson.group != null
178+
},
152179
],
153180
},
154181
{
@@ -226,7 +253,11 @@ const LessonDocument: Screen<"LessonDocument"> = ({ route, navigation }) => {
226253
}
227254

228255
return (
229-
<NativeItem key={index} icon={item.icon}>
256+
<NativeItem
257+
key={index}
258+
icon={item.icon}
259+
onPress={item.value && item.value.startsWith("http") ? () => Linking.openURL(item.value!) : void 0}
260+
>
230261
<NativeText variant="subtitle">{item.text}</NativeText>
231262
<NativeText variant="default">{item.value}</NativeText>
232263
</NativeItem>

0 commit comments

Comments
 (0)