From 63dba2d88ff4c83d8b3f8d5bacef007a485cb1c2 Mon Sep 17 00:00:00 2001 From: raphckrman <41128238+raphckrman@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:17:07 +0100 Subject: [PATCH 1/7] =?UTF-8?q?fix:=20Ajustement=20des=20dates=20pour=20co?= =?UTF-8?q?rrespondre=20=C3=A0=20la=20r=C3=A9alit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/account/Homeworks/Homeworks.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/account/Homeworks/Homeworks.tsx b/src/views/account/Homeworks/Homeworks.tsx index 0888bebd5..8b38f4596 100644 --- a/src/views/account/Homeworks/Homeworks.tsx +++ b/src/views/account/Homeworks/Homeworks.tsx @@ -99,7 +99,7 @@ const WeekView: Screen<"Homeworks"> = ({ route, navigation }) => { }; const currentWeek = getCurrentWeekNumber(); - const [data, setData] = useState(Array.from({ length: 100 }, (_, i) => currentWeek - 50 + i)); + const [data, setData] = useState(Array.from({ length: 100 }, (_, i) => currentWeek - 49 + i)); const [selectedWeek, setSelectedWeek] = useState(currentWeek); const [direction, setDirection] = useState<"left" | "right">("right"); From f7845118ba1b3ca6587970ebd142cb5c534e9a41 Mon Sep 17 00:00:00 2001 From: raphckrman <41128238+raphckrman@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:19:23 +0100 Subject: [PATCH 2/7] =?UTF-8?q?fix:=20Ajustement=20du=20num=C3=A9ro=20de?= =?UTF-8?q?=20la=20semaine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/account/Homeworks/Homeworks.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/account/Homeworks/Homeworks.tsx b/src/views/account/Homeworks/Homeworks.tsx index 8b38f4596..fad6bb26f 100644 --- a/src/views/account/Homeworks/Homeworks.tsx +++ b/src/views/account/Homeworks/Homeworks.tsx @@ -95,11 +95,11 @@ const WeekView: Screen<"Homeworks"> = ({ route, navigation }) => { start.setHours(0, 0, 0, 0); const diff = now.getTime() - start.getTime(); const oneWeek = 1000 * 60 * 60 * 24 * 7; - return Math.floor(diff / oneWeek); + return Math.floor(diff / oneWeek) + 1; }; const currentWeek = getCurrentWeekNumber(); - const [data, setData] = useState(Array.from({ length: 100 }, (_, i) => currentWeek - 49 + i)); + const [data, setData] = useState(Array.from({ length: 100 }, (_, i) => currentWeek - 50 + i)); const [selectedWeek, setSelectedWeek] = useState(currentWeek); const [direction, setDirection] = useState<"left" | "right">("right"); From 4b8f488620da68128c91768d8e4a6f183605ad2f Mon Sep 17 00:00:00 2001 From: oriionn Date: Sat, 11 Jan 2025 23:49:38 +0100 Subject: [PATCH 3/7] feat: use title instead of content if the content is nothing on Skolengo --- src/services/skolengo/data/homework.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/skolengo/data/homework.ts b/src/services/skolengo/data/homework.ts index be4db6abb..5a0d6f1c1 100644 --- a/src/services/skolengo/data/homework.ts +++ b/src/services/skolengo/data/homework.ts @@ -14,7 +14,7 @@ const decodeHomework = (h: HomeworkAssignment): Homework => { subject: h.subject?.label || "", attachments: h.attachments?.map(decodeSkoAttachment) || [], color: h.subject?.color || "#000000", - content:htmlToText(h.html||""), + content: (h.html && htmlToText(h.html || "") !== "") ? htmlToText(h.html) : h.title ?? "", due: h.dueDateTime ? new Date(h.dueDateTime).getTime() : -1, done: h.done, returnType: h.deliverWorkOnline ? HomeworkReturnType.FileUpload : HomeworkReturnType.Paper From 1f5eedb718c7960eaa2c8d8f183b570d0760a2fc Mon Sep 17 00:00:00 2001 From: Vince Linise Date: Mon, 20 Jan 2025 11:48:53 +0100 Subject: [PATCH 4/7] =?UTF-8?q?Refactor:=20Nettoyage=20des=20imports=20et?= =?UTF-8?q?=20am=C3=A9lioration=20de=20la=20lisibilit=C3=A9=20du=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/ecoledirecte/grades.ts | 1 - src/services/pronote/grades.ts | 50 ++++++++++++------- src/services/shared/Grade.ts | 4 +- src/services/skolengo/data/grades.ts | 4 +- src/views/account/Grades/Document.tsx | 8 ++- .../account/Grades/Subject/SubjectList.tsx | 1 - 6 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/services/ecoledirecte/grades.ts b/src/services/ecoledirecte/grades.ts index 9fc4833cd..2754abc0f 100644 --- a/src/services/ecoledirecte/grades.ts +++ b/src/services/ecoledirecte/grades.ts @@ -3,7 +3,6 @@ import type { Period } from "@/services/shared/Period"; import { type AverageOverview, type Grade, - GradeInformation, type GradeValue, } from "@/services/shared/Grade"; import ecoledirecte, { diff --git a/src/services/pronote/grades.ts b/src/services/pronote/grades.ts index 03df84275..0ad206e2d 100644 --- a/src/services/pronote/grades.ts +++ b/src/services/pronote/grades.ts @@ -1,34 +1,43 @@ import type { PronoteAccount } from "@/stores/account/types"; import type { Period } from "../shared/Period"; import { ErrorServiceUnauthenticated } from "../shared/errors"; -import { type AverageOverview, type Grade, GradeInformation, type GradeValue } from "../shared/Grade"; +import { + type AverageOverview, + type Grade, + type GradeValue, +} from "../shared/Grade"; import { decodeAttachment } from "./attachment"; import { decodePeriod } from "./period"; import pronote from "pawnote"; import { info } from "@/utils/logger/logger"; const getTab = (account: PronoteAccount): pronote.Tab => { - if (!account.instance) - throw new ErrorServiceUnauthenticated("pronote"); + if (!account.instance) throw new ErrorServiceUnauthenticated("pronote"); - const tab = account.instance.user.resources[0].tabs.get(pronote.TabLocation.Grades); + const tab = account.instance.user.resources[0].tabs.get( + pronote.TabLocation.Grades + ); if (!tab) throw new Error("Tu n'as pas accès à l'onglet 'Notes' dans PRONOTE"); return tab; }; -export const getGradesPeriods = (account: PronoteAccount): { periods: Period[], default: string } => { +export const getGradesPeriods = ( + account: PronoteAccount +): { periods: Period[]; default: string } => { const tab = getTab(account); info("PRONOTE->getGradesPeriods(): OK", "pronote"); return { default: tab.defaultPeriod!.name, - periods: tab.periods.map(decodePeriod) + periods: tab.periods.map(decodePeriod), }; }; -const decodeGradeValue = (value: pronote.GradeValue | undefined): GradeValue => { +const decodeGradeValue = ( + value: pronote.GradeValue | undefined +): GradeValue => { if (typeof value === "undefined") return { value: null, disabled: true, status: "unknown" }; @@ -54,21 +63,23 @@ const decodeGradeValue = (value: pronote.GradeValue | undefined): GradeValue => } }; -export const getGradesAndAverages = async (account: PronoteAccount, periodName: string): Promise<{ - grades: Grade[], - averages: AverageOverview +export const getGradesAndAverages = async ( + account: PronoteAccount, + periodName: string +): Promise<{ + grades: Grade[]; + averages: AverageOverview; }> => { const tab = getTab(account); // Vérifie aussi la validité de `account.instance`. - const period = tab.periods.find(p => p.name === periodName); - if (!period) - throw new Error("La période sélectionnée n'a pas été trouvée."); + const period = tab.periods.find((p) => p.name === periodName); + if (!period) throw new Error("La période sélectionnée n'a pas été trouvée."); const overview = await pronote.gradesOverview(account.instance!, period); const averages: AverageOverview = { classOverall: decodeGradeValue(overview.classAverage), overall: decodeGradeValue(overview.overallAverage), - subjects: overview.subjectsAverages.map(s => ({ + subjects: overview.subjectsAverages.map((s) => ({ classAverage: decodeGradeValue(s.class_average), color: s.backgroundColor, max: decodeGradeValue(s.max), @@ -76,11 +87,11 @@ export const getGradesAndAverages = async (account: PronoteAccount, periodName: id: s.subject.id ? s.subject.id.toString() : undefined, min: decodeGradeValue(s.min), average: decodeGradeValue(s.student), - outOf: decodeGradeValue(s.outOf) - })) + outOf: decodeGradeValue(s.outOf), + })), }; - const grades: Grade[] = overview.grades.map(g => ({ + const grades: Grade[] = overview.grades.map((g) => ({ id: buildLocalID(g), subjectName: g.subject.name, subjectId: g.subject.id ? g.subject.id.toString() : undefined, @@ -99,10 +110,11 @@ export const getGradesAndAverages = async (account: PronoteAccount, periodName: student: decodeGradeValue(g.value), average: decodeGradeValue(g.average), max: decodeGradeValue(g.max), - min: decodeGradeValue(g.min) + min: decodeGradeValue(g.min), })); return { averages, grades }; }; -export const buildLocalID = (g: pronote.Grade): string => `${g.subject.name}:${g.date.getTime()}/${g.comment || "none"}`; +export const buildLocalID = (g: pronote.Grade): string => + `${g.subject.name}:${g.date.getTime()}/${g.comment || "none"}`; diff --git a/src/services/shared/Grade.ts b/src/services/shared/Grade.ts index a8410e9b2..295f2793f 100644 --- a/src/services/shared/Grade.ts +++ b/src/services/shared/Grade.ts @@ -22,13 +22,13 @@ export interface GradeValue { value: number | null; status: string | null; - + /** * Whether the "value" should be counted * in the average or not. */ disabled?: boolean - + }; export interface Grade { diff --git a/src/services/skolengo/data/grades.ts b/src/services/skolengo/data/grades.ts index cec47baa3..805fe7d6a 100644 --- a/src/services/skolengo/data/grades.ts +++ b/src/services/skolengo/data/grades.ts @@ -1,8 +1,8 @@ -import { AverageOverview, Grade, GradeInformation, GradeValue } from "@/services/shared/Grade"; +import { AverageOverview, Grade, GradeValue } from "@/services/shared/Grade"; import type { SkolengoAccount } from "@/stores/account/types"; import { getPeriod } from "./period"; import { ErrorServiceUnauthenticated } from "@/services/shared/errors"; -import { Evaluation, EvaluationDetail } from "scolengo-api/types/models/Results"; +import { Evaluation } from "scolengo-api/types/models/Results"; const SKOLENGO_DEFAULT_SCALE = 20; diff --git a/src/views/account/Grades/Document.tsx b/src/views/account/Grades/Document.tsx index ba56ada31..e1592d4f2 100644 --- a/src/views/account/Grades/Document.tsx +++ b/src/views/account/Grades/Document.tsx @@ -6,13 +6,12 @@ import { } from "@/components/Global/NativeComponents"; import { getSubjectData } from "@/services/shared/Subject"; import { useTheme } from "@react-navigation/native"; -import React, { useCallback, useEffect, useLayoutEffect, useState } from "react"; -import { Image, ScrollView, Text, View, Platform, TouchableOpacity } from "react-native"; +import React, { useEffect, useLayoutEffect, useState } from "react"; +import { Image, ScrollView, Text, View, Platform } from "react-native"; import * as StoreReview from "expo-store-review"; import { Asterisk, Calculator, - Maximize2, Scale, School, UserMinus, @@ -24,7 +23,6 @@ import type { AverageDiffGrade } from "@/utils/grades/getAverages"; import { Screen } from "@/router/helpers/types"; import InsetsBottomView from "@/components/Global/InsetsBottomView"; import AsyncStorage from "@react-native-async-storage/async-storage"; -import { useSafeAreaInsets } from "react-native-safe-area-context"; const GradeDocument: Screen<"GradeDocument"> = ({ route, navigation }) => { const { grade, allGrades = [] } = route.params; @@ -335,7 +333,7 @@ const GradeDocument: Screen<"GradeDocument"> = ({ route, navigation }) => { }} numberOfLines={1} > - {grade.student.disabled ? (grade.student.status === null ? "N. Not" : grade.student.status) : grade.student.value?.toFixed(2)} + {grade.student.disabled ? (grade.student.status === null ? "N. Not" : grade.student.status) : grade.student.value?.toFixed(2)} Date: Mon, 20 Jan 2025 11:51:10 +0100 Subject: [PATCH 5/7] =?UTF-8?q?refactor:=20fix=20des=20probl=C3=A8mes=20de?= =?UTF-8?q?=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Global/PapillonPicker.tsx | 2 +- src/views/account/Grades/Subject/SubjectList.tsx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Global/PapillonPicker.tsx b/src/components/Global/PapillonPicker.tsx index 840c48efb..83a913021 100644 --- a/src/components/Global/PapillonPicker.tsx +++ b/src/components/Global/PapillonPicker.tsx @@ -21,7 +21,7 @@ interface PapillonPickerProps { delay?: number, direction?: "left" | "right", animated?: boolean, - onSelectionChange?: (item: string) => unknown + onSelectionChange?: any } const PapillonPicker: React.FC = ({ diff --git a/src/views/account/Grades/Subject/SubjectList.tsx b/src/views/account/Grades/Subject/SubjectList.tsx index 1dcc79011..87e1af073 100644 --- a/src/views/account/Grades/Subject/SubjectList.tsx +++ b/src/views/account/Grades/Subject/SubjectList.tsx @@ -20,12 +20,14 @@ interface SubjectItemProps { subject: GradesPerSubject; allGrades: Grade[]; navigation: NativeStackNavigationProp; + index?: number; } const SubjectItem: React.FC = ({ subject, allGrades, navigation, + index, }) => { const [subjectData, setSubjectData] = useState({ color: "#888888", From 3e10c37ec364263bc591e676552145b1579d8eb6 Mon Sep 17 00:00:00 2001 From: Vince Linise Date: Mon, 20 Jan 2025 13:02:56 +0100 Subject: [PATCH 6/7] =?UTF-8?q?refactor:=20am=C3=A9lioration=20de=20la=20m?= =?UTF-8?q?ise=20en=20page=20et=20ajustement=20des=20styles=20dans=20NewsL?= =?UTF-8?q?istItem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/account/News/Atoms/Item.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index e67293df0..86a5e63c4 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -35,23 +35,26 @@ const NewsListItem: React.FC = ({ index, message, navigation, {!message.read && !isED && ( )} + {message.title !== "" && + {message.title} + } - {message.title !== "" && - {message.title} - } {message.content && ( Date: Mon, 20 Jan 2025 13:06:58 +0100 Subject: [PATCH 7/7] =?UTF-8?q?refactor:=20am=C3=A9lioration=20du=20format?= =?UTF-8?q?age=20du=20r=C3=A9sum=C3=A9=20des=20nouvelles=20et=20ajustement?= =?UTF-8?q?=20des=20styles=20dans=20NewsListItem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/format/format_pronote_news.ts | 4 +++- src/views/account/News/Atoms/Item.tsx | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/format/format_pronote_news.ts b/src/utils/format/format_pronote_news.ts index a3e69046c..591f2b1fa 100644 --- a/src/utils/format/format_pronote_news.ts +++ b/src/utils/format/format_pronote_news.ts @@ -4,7 +4,9 @@ function parse_news_resume (content: string): string { const converted = convertHTML(content); const formatted = converted.replace(/Bonjour,|Bonjour à tous|Bonjour !|Bonsoir|Bonjour|Bonjour à tous, |Bonjour , |Bonsoir, /g, "").replace(/\n/g, ""); const trimmed = formatted.trim(); - return trimmed; + const decoma = (trimmed.startsWith(",") ? trimmed.slice(1) : trimmed).trim(); + const uppercased = decoma.charAt(0).toUpperCase() + decoma.slice(1); + return uppercased; } export default parse_news_resume; diff --git a/src/views/account/News/Atoms/Item.tsx b/src/views/account/News/Atoms/Item.tsx index 86a5e63c4..eb7cd980d 100644 --- a/src/views/account/News/Atoms/Item.tsx +++ b/src/views/account/News/Atoms/Item.tsx @@ -75,14 +75,12 @@ const NewsListItem: React.FC = ({ index, message, navigation, flexDirection: "row", alignItems: "center", justifyContent: "space-between", + marginTop: 5, }} > {formatDate(message.date)}