From e461fdd3ed350394af3e1270e290f5c880bad297 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Fri, 20 Dec 2024 22:52:39 +0100 Subject: [PATCH 01/30] fix --- src/services/pronote/chats.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/pronote/chats.ts b/src/services/pronote/chats.ts index 89a08197f..7b45859db 100644 --- a/src/services/pronote/chats.ts +++ b/src/services/pronote/chats.ts @@ -56,7 +56,7 @@ export const createDiscussionRecipients = async (account: PronoteAccount): Promi const recipientsALL = await Promise.all([ pronote.EntityKind.Teacher, pronote.EntityKind.Personal - ].map(kind => pronote.newDiscussionRecipients(account.instance!, user, kind))); + ].map(kind => pronote.newDiscussionRecipients(account.instance!, kind))); const recipients = recipientsALL.flat(); info("PRONOTE->createDiscussionRecipients(): OK", "pronote"); From 40869691a0c577df96ac735e13dca48624b4aec3 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 19:50:41 +0100 Subject: [PATCH 02/30] Update TimetableElement.tsx --- .../Home/Elements/TimetableElement.tsx | 95 +++++++++++-------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 148478a2d..e1504c0bb 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -12,7 +12,7 @@ import MissingItem from "@/components/Global/MissingItem"; import { TimetableItem } from "../../Lessons/Atoms/Item"; interface TimetableElementProps { - onImportance: (value: number) => unknown + onImportance: (value: number) => unknown; } const TimetableElement: React.FC = ({ onImportance }) => { @@ -46,17 +46,14 @@ const TimetableElement: React.FC = ({ onImportance }) => ); }; - const isTomorrow = (timestamp: number) => { - const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 1); - const date = new Date(timestamp); - return ( - date.getDate() === tomorrow.getDate() && - date.getMonth() === tomorrow.getMonth() && - date.getFullYear() === tomorrow.getFullYear() - ); + const isWeekend = () => { + const today = new Date().getDay(); + return today === 6 || today === 0; // 6 = Saturday, 0 = Sunday }; + const isVacation = (courses: TimetableClass[]) => + courses.length === 1 && courses[0].type === "vacation"; + const fetchTimetable = async () => { if (!timetables[currentWeekNumber] && account.instance) { setLoading(true); @@ -68,37 +65,18 @@ const TimetableElement: React.FC = ({ onImportance }) => } }; - const filterAndSortCourses = (weekCourses: TimetableClass[]): TimetableClass[] => { - const now = Date.now(); - const todayCourses = weekCourses - .filter(c => isToday(c.startTimestamp) && c.endTimestamp > now) - .sort((a, b) => a.startTimestamp - b.startTimestamp); - - if (todayCourses.length > 0) { - return todayCourses; - } - - const tomorrowCourses = weekCourses - .filter(c => isTomorrow(c.startTimestamp)) - .sort((a, b) => a.startTimestamp - b.startTimestamp); - - if (tomorrowCourses.length > 0) { - return tomorrowCourses.slice(0, 3); - } - - return weekCourses - .filter(c => c.startTimestamp > now) - .sort((a, b) => a.startTimestamp - b.startTimestamp) - .slice(0, 3); - }; - const updateNextCourses = () => { if (!account.instance || !timetables[currentWeekNumber]) { return; } const weekCourses = timetables[currentWeekNumber]; - const upcomingCourses = filterAndSortCourses(weekCourses); + const now = Date.now(); + + const upcomingCourses = weekCourses + .filter((c) => c.startTimestamp > now) + .sort((a, b) => a.startTimestamp - b.startTimestamp) + .slice(0, 3); setNextCourses(upcomingCourses); ImportanceHandler(upcomingCourses); @@ -134,6 +112,44 @@ const TimetableElement: React.FC = ({ onImportance }) => ); } + if (isWeekend()) { + return ( + + + + + + ); + } + + if (isVacation(nextCourses)) { + return ( + + + + + + ); + } + if (hidden || nextCourses.length === 0) { return ( = ({ onImportance }) => const label = isToday(nextCourses[0].startTimestamp) ? "Emploi du temps" - : isTomorrow(nextCourses[0].startTimestamp) - ? "Cours de demain" - : "Prochains cours"; + : "Prochains cours"; return ( <> @@ -166,10 +180,7 @@ const TimetableElement: React.FC = ({ onImportance }) => label={label} trailing={} /> - + {nextCourses.map((course, index) => ( From 29825f95013c3a9c76a824e4684bdd1d89c7c6f5 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 19:53:28 +0100 Subject: [PATCH 03/30] Update TimetableElement.tsx --- .../Home/Elements/TimetableElement.tsx | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index e1504c0bb..6551ccb25 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -46,6 +46,17 @@ const TimetableElement: React.FC = ({ onImportance }) => ); }; + const isTomorrow = (timestamp: number) => { + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + const date = new Date(timestamp); + return ( + date.getDate() === tomorrow.getDate() && + date.getMonth() === tomorrow.getMonth() && + date.getFullYear() === tomorrow.getFullYear() + ); + }; + const isWeekend = () => { const today = new Date().getDay(); return today === 6 || today === 0; // 6 = Saturday, 0 = Sunday @@ -54,6 +65,26 @@ const TimetableElement: React.FC = ({ onImportance }) => const isVacation = (courses: TimetableClass[]) => courses.length === 1 && courses[0].type === "vacation"; + const filterAndSortCourses = (weekCourses: TimetableClass[]): TimetableClass[] => { + const now = Date.now(); + const todayCourses = weekCourses + .filter((c) => isToday(c.startTimestamp) && c.endTimestamp > now) + .sort((a, b) => a.startTimestamp - b.startTimestamp); + if (todayCourses.length > 0) { + return todayCourses; + } + const tomorrowCourses = weekCourses + .filter((c) => isTomorrow(c.startTimestamp)) + .sort((a, b) => a.startTimestamp - b.startTimestamp); + if (tomorrowCourses.length > 0) { + return tomorrowCourses.slice(0, 3); + } + return weekCourses + .filter((c) => c.startTimestamp > now) + .sort((a, b) => a.startTimestamp - b.startTimestamp) + .slice(0, 3); + }; + const fetchTimetable = async () => { if (!timetables[currentWeekNumber] && account.instance) { setLoading(true); @@ -71,12 +102,7 @@ const TimetableElement: React.FC = ({ onImportance }) => } const weekCourses = timetables[currentWeekNumber]; - const now = Date.now(); - - const upcomingCourses = weekCourses - .filter((c) => c.startTimestamp > now) - .sort((a, b) => a.startTimestamp - b.startTimestamp) - .slice(0, 3); + const upcomingCourses = filterAndSortCourses(weekCourses); setNextCourses(upcomingCourses); ImportanceHandler(upcomingCourses); @@ -171,6 +197,8 @@ const TimetableElement: React.FC = ({ onImportance }) => const label = isToday(nextCourses[0].startTimestamp) ? "Emploi du temps" + : isTomorrow(nextCourses[0].startTimestamp) + ? "Cours de demain" : "Prochains cours"; return ( From 1ba5b297cc6892b62eb3139821b0ac7ca8d89aa2 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 21:25:49 +0100 Subject: [PATCH 04/30] Create holidayEmoji.ts --- src/utils/format/holidayEmoji.ts | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/utils/format/holidayEmoji.ts diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts new file mode 100644 index 000000000..76038b030 --- /dev/null +++ b/src/utils/format/holidayEmoji.ts @@ -0,0 +1,54 @@ +export const getHolidayEmoji = (date: Date = new Date()): string => { + const year = date.getFullYear(); + + const holidays = [ + { start: new Date(`${year}-01-01`), end: new Date(`${year}-01-01`), emoji: "🎉" }, // Nouvel An + { start: new Date(`${year}-05-01`), end: new Date(`${year}-05-01`), emoji: "🌹" }, // Fête du Travail + { start: new Date(`${year}-05-08`), end: new Date(`${year}-05-08`), emoji: "🇫🇷" }, // Armistice 1945 + { start: new Date(`${year}-07-14`), end: new Date(`${year}-07-14`), emoji: "🎇" }, // Fête Nationale + { start: new Date(`${year}-11-01`), end: new Date(`${year}-11-01`), emoji: "🕯️" }, // Toussaint + { start: new Date(`${year}-11-11`), end: new Date(`${year}-11-11`), emoji: "🕊️" }, // Armistice + { start: new Date(`${year}-12-25`), end: new Date(`${year}-12-25`), emoji: "🎄" }, // Noël + ]; + + const schoolHolidays = [ + { + start: new Date(`${year}-10-19`), + end: new Date(`${year}-11-04`), + emoji: "🍂", // Vacances de la Toussaint + }, + { + start: new Date(`${year}-12-21`), + end: new Date(`${year + 1}-01-06`), + emoji: "❄️", // Vacances de Noël + }, + { + start: new Date(`${year + 1}-02-08`), + end: new Date(`${year + 1}-03-10`), + emoji: "⛷️", // Vacances d'hiver + }, + { + start: new Date(`${year + 1}-04-05`), + end: new Date(`${year + 1}-04-28`), + emoji: "🌸", // Vacances de printemps + }, + { + start: new Date(`${year + 1}-07-05`), + end: new Date(`${year + 1}-09-01`), + emoji: "🏖️", // Grandes vacances + }, + ]; + + // Combine jours fériés et vacances scolaires + const allPeriods = [...holidays, ...schoolHolidays]; + + // Vérifie si la date donnée se trouve dans l'une des périodes + for (const period of allPeriods) { + if (date >= period.start && date <= period.end) { + return period.emoji; + } + } + + // Emoji par défaut + return "📚"; +}; From 29666710aa52d171550bce3e47c0866b799bd46e Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 21:29:48 +0100 Subject: [PATCH 05/30] Update Page.tsx --- src/views/account/Lessons/Atoms/Page.tsx | 36 +++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/views/account/Lessons/Atoms/Page.tsx b/src/views/account/Lessons/Atoms/Page.tsx index 7564e7eac..44876d23d 100644 --- a/src/views/account/Lessons/Atoms/Page.tsx +++ b/src/views/account/Lessons/Atoms/Page.tsx @@ -17,6 +17,9 @@ import { Timetable, TimetableClass } from "@/services/shared/Timetable"; import { animPapillon } from "@/utils/ui/animations"; import LessonsLoading from "./Loading"; import MissingItem from "@/components/Global/MissingItem"; +import { getHolidayEmoji } from "@/utils/format/holidayEmoji"; + +const emoji = getHolidayEmoji(); const RefreshControl = createNativeWrapper(RNRefreshControl, { disallowInterruption: true, @@ -63,6 +66,7 @@ export const Page = ({ day, date, current, paddingTop, refreshAction, loading, w > {current && {day && day.length > 0 && day[0].type !== "vacation" && day.map((item, i) => ( - - + + {day[i + 1] && day[i + 1].startTimestamp - item.endTimestamp > 1740000 && ( @@ -92,8 +96,6 @@ export const Page = ({ day, date, current, paddingTop, refreshAction, loading, w style={{ padding: 26, }} - entering={animPapillon(FadeInDown)} - exiting={animPapillon(FadeOutUp).delay(100)} > @@ -105,28 +107,28 @@ export const Page = ({ day, date, current, paddingTop, refreshAction, loading, w emoji="🌴" title="C'est le week-end !" description="Profitez de votre week-end, il n'y a pas de cours aujourd'hui." - entering={animPapillon(FadeInDown)} - exiting={animPapillon(FadeOut)} /> ) : ( ) )} - {day.length === 1 && current && !loading && (day[0].type === "vacation" ? : <> - )} + {day.length === 1 && + current && + !loading && + (day[0].type === "vacation" ? ( + + ) : ( + <> + ))} ); }; @@ -161,7 +163,7 @@ const SeparatorCourse: React.FC<{ .stiffness(300) : void 0 } - exiting={Platform.OS === "ios" ? FadeOut.duration(300) : void 0} + > Date: Sun, 22 Dec 2024 21:31:59 +0100 Subject: [PATCH 06/30] Update Page.tsx --- src/views/account/Lessons/Atoms/Page.tsx | 33 ++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/views/account/Lessons/Atoms/Page.tsx b/src/views/account/Lessons/Atoms/Page.tsx index 44876d23d..bae4bbf5b 100644 --- a/src/views/account/Lessons/Atoms/Page.tsx +++ b/src/views/account/Lessons/Atoms/Page.tsx @@ -66,7 +66,6 @@ export const Page = ({ day, date, current, paddingTop, refreshAction, loading, w > {current && {day && day.length > 0 && day[0].type !== "vacation" && day.map((item, i) => ( - - + + {day[i + 1] && day[i + 1].startTimestamp - item.endTimestamp > 1740000 && ( @@ -96,6 +95,8 @@ export const Page = ({ day, date, current, paddingTop, refreshAction, loading, w style={{ padding: 26, }} + entering={animPapillon(FadeInDown)} + exiting={animPapillon(FadeOutUp).delay(100)} > @@ -107,28 +108,28 @@ export const Page = ({ day, date, current, paddingTop, refreshAction, loading, w emoji="🌴" title="C'est le week-end !" description="Profitez de votre week-end, il n'y a pas de cours aujourd'hui." + entering={animPapillon(FadeInDown)} + exiting={animPapillon(FadeOut)} /> ) : ( ) )} - {day.length === 1 && - current && - !loading && - (day[0].type === "vacation" ? ( - - ) : ( - <> - ))} + {day.length === 1 && current && !loading && (day[0].type === "vacation" ? : <> + )} ); }; @@ -163,7 +164,7 @@ const SeparatorCourse: React.FC<{ .stiffness(300) : void 0 } - + exiting={Platform.OS === "ios" ? FadeOut.duration(300) : void 0} > Date: Sun, 22 Dec 2024 21:33:54 +0100 Subject: [PATCH 07/30] Update TimetableElement.tsx --- src/views/account/Home/Elements/TimetableElement.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 6551ccb25..b2703a4ae 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -10,12 +10,16 @@ import RedirectButton from "@/components/Home/RedirectButton"; import { updateTimetableForWeekInCache } from "@/services/timetable"; import MissingItem from "@/components/Global/MissingItem"; import { TimetableItem } from "../../Lessons/Atoms/Item"; +import { getHolidayEmoji } from "@/utils/format/holidayEmoji"; + + interface TimetableElementProps { onImportance: (value: number) => unknown; } const TimetableElement: React.FC = ({ onImportance }) => { + const emoji = getHolidayEmoji(); const account = useCurrentAccount((store) => store.account!); const timetables = useTimetableStore((store) => store.timetables); @@ -167,7 +171,7 @@ const TimetableElement: React.FC = ({ onImportance }) => > From fb88d3b64d4e2f711d3f2a0f1b5a8233ef051592 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 21:37:37 +0100 Subject: [PATCH 08/30] Update holidayEmoji.ts --- src/utils/format/holidayEmoji.ts | 35 ++++++-------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index 76038b030..12ee7de12 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -12,43 +12,20 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { ]; const schoolHolidays = [ - { - start: new Date(`${year}-10-19`), - end: new Date(`${year}-11-04`), - emoji: "🍂", // Vacances de la Toussaint - }, - { - start: new Date(`${year}-12-21`), - end: new Date(`${year + 1}-01-06`), - emoji: "❄️", // Vacances de Noël - }, - { - start: new Date(`${year + 1}-02-08`), - end: new Date(`${year + 1}-03-10`), - emoji: "⛷️", // Vacances d'hiver - }, - { - start: new Date(`${year + 1}-04-05`), - end: new Date(`${year + 1}-04-28`), - emoji: "🌸", // Vacances de printemps - }, - { - start: new Date(`${year + 1}-07-05`), - end: new Date(`${year + 1}-09-01`), - emoji: "🏖️", // Grandes vacances - }, + { start: new Date(`${year}-10-19`), end: new Date(`${year}-11-04`), emoji: "🍂" }, // Vacances de la Toussaint + { start: new Date(`${year}-12-21`), end: new Date(`${year + 1}-01-06`), emoji: "❄️" }, // Vacances de Noël + { start: new Date(`${year + 1}-02-08`), end: new Date(`${year + 1}-03-10`), emoji: "⛷️" }, // Vacances d'hiver + { start: new Date(`${year + 1}-04-05`), end: new Date(`${year + 1}-04-28`), emoji: "🌸" }, // Vacances de printemps + { start: new Date(`${year + 1}-07-05`), end: new Date(`${year + 1}-09-01`), emoji: "🏖️" }, // Grandes vacances ]; - // Combine jours fériés et vacances scolaires const allPeriods = [...holidays, ...schoolHolidays]; - // Vérifie si la date donnée se trouve dans l'une des périodes for (const period of allPeriods) { if (date >= period.start && date <= period.end) { return period.emoji; } } - // Emoji par défaut - return "📚"; + return "📚"; // Emoji par défaut }; From 4435864ca7b77ba6c80f2a023cfdf5b7edcfa3a4 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 21:38:30 +0100 Subject: [PATCH 09/30] Update holidayEmoji.ts From 76a116216b06f9cce81ddd816bfd3acfeaa7f5cb Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 21:39:03 +0100 Subject: [PATCH 10/30] Update TimetableElement.tsx --- .../Home/Elements/TimetableElement.tsx | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index b2703a4ae..ed2afc7c6 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -12,8 +12,6 @@ import MissingItem from "@/components/Global/MissingItem"; import { TimetableItem } from "../../Lessons/Atoms/Item"; import { getHolidayEmoji } from "@/utils/format/holidayEmoji"; - - interface TimetableElementProps { onImportance: (value: number) => unknown; } @@ -31,9 +29,7 @@ const TimetableElement: React.FC = ({ onImportance }) => const ImportanceHandler = (nextCourses: TimetableClass[]) => { if (nextCourses.length > 0) { let difference = new Date(nextCourses[0].startTimestamp).getHours() - new Date().getHours(); - if (difference < 0) { - difference = 0; - } + difference = Math.max(difference, 0); onImportance(6 - difference); } else { onImportance(0); @@ -125,12 +121,7 @@ const TimetableElement: React.FC = ({ onImportance }) => if (loading) { return ( - + = ({ onImportance }) => if (isWeekend()) { return ( - + = ({ onImportance }) => if (isVacation(nextCourses)) { return ( - + = ({ onImportance }) => if (hidden || nextCourses.length === 0) { return ( - + Date: Sun, 22 Dec 2024 21:40:43 +0100 Subject: [PATCH 11/30] mince --- .../Home/Elements/TimetableElement.tsx | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index ed2afc7c6..7606adfe5 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -29,7 +29,9 @@ const TimetableElement: React.FC = ({ onImportance }) => const ImportanceHandler = (nextCourses: TimetableClass[]) => { if (nextCourses.length > 0) { let difference = new Date(nextCourses[0].startTimestamp).getHours() - new Date().getHours(); - difference = Math.max(difference, 0); + if (difference < 0) { + difference = 0; + } onImportance(6 - difference); } else { onImportance(0); @@ -59,7 +61,7 @@ const TimetableElement: React.FC = ({ onImportance }) => const isWeekend = () => { const today = new Date().getDay(); - return today === 6 || today === 0; // 6 = Saturday, 0 = Sunday + return today === 6 || today === 0; // 6 = Samedi, 0 = Dimanche }; const isVacation = (courses: TimetableClass[]) => @@ -121,7 +123,12 @@ const TimetableElement: React.FC = ({ onImportance }) => if (loading) { return ( - + = ({ onImportance }) => if (isWeekend()) { return ( - + = ({ onImportance }) => if (isVacation(nextCourses)) { return ( - + = ({ onImportance }) => if (hidden || nextCourses.length === 0) { return ( - + Date: Sun, 22 Dec 2024 21:44:07 +0100 Subject: [PATCH 12/30] Update TimetableElement.tsx --- src/views/account/Home/Elements/TimetableElement.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 7606adfe5..75ddd8132 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -197,11 +197,12 @@ const TimetableElement: React.FC = ({ onImportance }) => ); } - const label = isToday(nextCourses[0].startTimestamp) - ? "Emploi du temps" - : isTomorrow(nextCourses[0].startTimestamp) - ? "Cours de demain" - : "Prochains cours"; +const label = isToday(nextCourses[0].startTimestamp) + ? "Emploi du temps" + : isTomorrow(nextCourses[0].startTimestamp) + ? "Cours de demain" + : "Prochains cours"; + return ( <> From 49afabe9b78cf307f15719d32bac29d13d17c794 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 21:47:57 +0100 Subject: [PATCH 13/30] Update TimetableElement.tsx --- src/views/account/Home/Elements/TimetableElement.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 75ddd8132..8673400a4 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -197,9 +197,9 @@ const TimetableElement: React.FC = ({ onImportance }) => ); } -const label = isToday(nextCourses[0].startTimestamp) - ? "Emploi du temps" - : isTomorrow(nextCourses[0].startTimestamp) + const label = isToday(nextCourses[0].startTimestamp) + ? "Emploi du temps" + : isTomorrow(nextCourses[0].startTimestamp) ? "Cours de demain" : "Prochains cours"; From 1948762c43c79f8f758b64a1b2f7b520714edd44 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 22:03:34 +0100 Subject: [PATCH 14/30] Update src/utils/format/holidayEmoji.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Raphaël <41128238+raphckrman@users.noreply.github.com> --- src/utils/format/holidayEmoji.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index 12ee7de12..b1af451c2 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -27,5 +27,5 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { } } - return "📚"; // Emoji par défaut + return "🏝️"; // Emoji par défaut }; From 65ff1a64e52135f2052ad7dfeb5d587b162d2451 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 22:04:01 +0100 Subject: [PATCH 15/30] Update src/views/account/Home/Elements/TimetableElement.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Raphaël <41128238+raphckrman@users.noreply.github.com> --- src/views/account/Home/Elements/TimetableElement.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 8673400a4..eab0eff58 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -203,7 +203,6 @@ const TimetableElement: React.FC = ({ onImportance }) => ? "Cours de demain" : "Prochains cours"; - return ( <> Date: Sun, 22 Dec 2024 22:07:04 +0100 Subject: [PATCH 16/30] Update holidayEmoji.ts --- src/utils/format/holidayEmoji.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index b1af451c2..ffd510f99 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -1,7 +1,7 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { const year = date.getFullYear(); - const holidays = [ + const allPeriods = [ { start: new Date(`${year}-01-01`), end: new Date(`${year}-01-01`), emoji: "🎉" }, // Nouvel An { start: new Date(`${year}-05-01`), end: new Date(`${year}-05-01`), emoji: "🌹" }, // Fête du Travail { start: new Date(`${year}-05-08`), end: new Date(`${year}-05-08`), emoji: "🇫🇷" }, // Armistice 1945 @@ -9,9 +9,6 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { { start: new Date(`${year}-11-01`), end: new Date(`${year}-11-01`), emoji: "🕯️" }, // Toussaint { start: new Date(`${year}-11-11`), end: new Date(`${year}-11-11`), emoji: "🕊️" }, // Armistice { start: new Date(`${year}-12-25`), end: new Date(`${year}-12-25`), emoji: "🎄" }, // Noël - ]; - - const schoolHolidays = [ { start: new Date(`${year}-10-19`), end: new Date(`${year}-11-04`), emoji: "🍂" }, // Vacances de la Toussaint { start: new Date(`${year}-12-21`), end: new Date(`${year + 1}-01-06`), emoji: "❄️" }, // Vacances de Noël { start: new Date(`${year + 1}-02-08`), end: new Date(`${year + 1}-03-10`), emoji: "⛷️" }, // Vacances d'hiver @@ -19,7 +16,6 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { { start: new Date(`${year + 1}-07-05`), end: new Date(`${year + 1}-09-01`), emoji: "🏖️" }, // Grandes vacances ]; - const allPeriods = [...holidays, ...schoolHolidays]; for (const period of allPeriods) { if (date >= period.start && date <= period.end) { From 267fe25a722d3448054b621d6f6099e4f8a18aeb Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 22:15:10 +0100 Subject: [PATCH 17/30] Update TimetableElement.tsx --- .../Home/Elements/TimetableElement.tsx | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index eab0eff58..f3a389001 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -102,25 +102,27 @@ const TimetableElement: React.FC = ({ onImportance }) => if (!account.instance || !timetables[currentWeekNumber]) { return; } - + const weekCourses = timetables[currentWeekNumber]; const upcomingCourses = filterAndSortCourses(weekCourses); - + const todayTimestamp = new Date().getTime(); + + const hasCoursesThisWeekend = weekCourses.some(course => + isWeekend(course.startTimestamp) && course.startTimestamp > todayTimestamp + ); + + if (isWeekend() && !hasCoursesThisWeekend) { + setNextCourses([]); + setHidden(false); + return; + } + setNextCourses(upcomingCourses); ImportanceHandler(upcomingCourses); setHidden(upcomingCourses.length === 0); }; - useEffect(() => { - fetchTimetable(); - }, [currentWeekNumber, account.instance]); - - useEffect(() => { - updateNextCourses(); - const intervalId = setInterval(updateNextCourses, 60000); - return () => clearInterval(intervalId); - }, [account.instance, timetables, currentWeekNumber]); - + if (loading) { return ( = ({ onImportance }) => ); } - - if (isWeekend()) { + + if (isWeekend() && nextCourses.length === 0) { return ( = ({ onImportance }) => ); } - + if (isVacation(nextCourses)) { return ( = ({ onImportance }) => ); } - - if (hidden || nextCourses.length === 0) { + + if (nextCourses.length === 0) { return ( = ({ onImportance }) => ); } + const label = isToday(nextCourses[0].startTimestamp) ? "Emploi du temps" : isTomorrow(nextCourses[0].startTimestamp) From 52c438236fe5b40a58cf851c6c8bdf51ffe6844c Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 22:17:10 +0100 Subject: [PATCH 18/30] Update TimetableElement.tsx --- src/views/account/Home/Elements/TimetableElement.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index f3a389001..8e3b54be2 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -123,6 +123,16 @@ const TimetableElement: React.FC = ({ onImportance }) => }; + useEffect(() => { + fetchTimetable(); + }, [currentWeekNumber, account.instance]); + + useEffect(() => { + updateNextCourses(); + const intervalId = setInterval(updateNextCourses, 60000); + return () => clearInterval(intervalId); + }, [account.instance, timetables, currentWeekNumber]); + if (loading) { return ( Date: Sun, 22 Dec 2024 22:20:27 +0100 Subject: [PATCH 19/30] Update TimetableElement.tsx --- src/views/account/Home/Elements/TimetableElement.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 8e3b54be2..f49768aac 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -59,11 +59,13 @@ const TimetableElement: React.FC = ({ onImportance }) => ); }; - const isWeekend = () => { - const today = new Date().getDay(); - return today === 6 || today === 0; // 6 = Samedi, 0 = Dimanche + const isWeekend = (timestamp: number) => { + const date = new Date(timestamp); + const day = date.getDay(); + return day === 6 || day === 0; // 6 = Samedi, 0 = Dimanche }; + const isVacation = (courses: TimetableClass[]) => courses.length === 1 && courses[0].type === "vacation"; From a8ae4d7ea21a384137f087f72fa849b7f444f512 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Sun, 22 Dec 2024 22:23:17 +0100 Subject: [PATCH 20/30] Update TimetableElement.tsx --- src/views/account/Home/Elements/TimetableElement.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index f49768aac..3f6b29698 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -113,7 +113,7 @@ const TimetableElement: React.FC = ({ onImportance }) => isWeekend(course.startTimestamp) && course.startTimestamp > todayTimestamp ); - if (isWeekend() && !hasCoursesThisWeekend) { + if (isWeekend(todayTimestamp) && !hasCoursesThisWeekend) { setNextCourses([]); setHidden(false); return; @@ -154,7 +154,7 @@ const TimetableElement: React.FC = ({ onImportance }) => ); } - if (isWeekend() && nextCourses.length === 0) { + if (isWeekend(todayTimestamp) && nextCourses.length === 0) { return ( Date: Sun, 22 Dec 2024 22:27:36 +0100 Subject: [PATCH 21/30] j ai fais dla merde --- .../Home/Elements/TimetableElement.tsx | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 3f6b29698..8673400a4 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -59,13 +59,11 @@ const TimetableElement: React.FC = ({ onImportance }) => ); }; - const isWeekend = (timestamp: number) => { - const date = new Date(timestamp); - const day = date.getDay(); - return day === 6 || day === 0; // 6 = Samedi, 0 = Dimanche + const isWeekend = () => { + const today = new Date().getDay(); + return today === 6 || today === 0; // 6 = Samedi, 0 = Dimanche }; - const isVacation = (courses: TimetableClass[]) => courses.length === 1 && courses[0].type === "vacation"; @@ -104,27 +102,15 @@ const TimetableElement: React.FC = ({ onImportance }) => if (!account.instance || !timetables[currentWeekNumber]) { return; } - + const weekCourses = timetables[currentWeekNumber]; const upcomingCourses = filterAndSortCourses(weekCourses); - const todayTimestamp = new Date().getTime(); - - const hasCoursesThisWeekend = weekCourses.some(course => - isWeekend(course.startTimestamp) && course.startTimestamp > todayTimestamp - ); - - if (isWeekend(todayTimestamp) && !hasCoursesThisWeekend) { - setNextCourses([]); - setHidden(false); - return; - } - + setNextCourses(upcomingCourses); ImportanceHandler(upcomingCourses); setHidden(upcomingCourses.length === 0); }; - useEffect(() => { fetchTimetable(); }, [currentWeekNumber, account.instance]); @@ -134,7 +120,7 @@ const TimetableElement: React.FC = ({ onImportance }) => const intervalId = setInterval(updateNextCourses, 60000); return () => clearInterval(intervalId); }, [account.instance, timetables, currentWeekNumber]); - + if (loading) { return ( = ({ onImportance }) => ); } - - if (isWeekend(todayTimestamp) && nextCourses.length === 0) { + + if (isWeekend()) { return ( = ({ onImportance }) => ); } - + if (isVacation(nextCourses)) { return ( = ({ onImportance }) => ); } - - if (nextCourses.length === 0) { + + if (hidden || nextCourses.length === 0) { return ( = ({ onImportance }) => ); } - const label = isToday(nextCourses[0].startTimestamp) ? "Emploi du temps" : isTomorrow(nextCourses[0].startTimestamp) ? "Cours de demain" : "Prochains cours"; + return ( <> Date: Mon, 23 Dec 2024 01:43:00 +0100 Subject: [PATCH 22/30] =?UTF-8?q?plus=20de=20jours=20f=C3=A9ri=C3=A9s=20et?= =?UTF-8?q?=20nouveaux=20emojis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/format/holidayEmoji.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index ffd510f99..03b81ea27 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -2,10 +2,14 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { const year = date.getFullYear(); const allPeriods = [ - { start: new Date(`${year}-01-01`), end: new Date(`${year}-01-01`), emoji: "🎉" }, // Nouvel An - { start: new Date(`${year}-05-01`), end: new Date(`${year}-05-01`), emoji: "🌹" }, // Fête du Travail + { start: new Date(`${year}-01-01`), end: new Date(`${year}-01-01`), emoji: "🎆" }, // Nouvel An + { start: new Date(`${year}-04-10`), end: new Date(`${year}-04-10`), emoji: "✝️" }, // Lundi de Pâques + { start: new Date(`${year}-05-01`), end: new Date(`${year}-05-01`), emoji: "⚒️" }, // Fête du Travail { start: new Date(`${year}-05-08`), end: new Date(`${year}-05-08`), emoji: "🇫🇷" }, // Armistice 1945 - { start: new Date(`${year}-07-14`), end: new Date(`${year}-07-14`), emoji: "🎇" }, // Fête Nationale + { start: new Date(`${year}-05-18`), end: new Date(`${year}-05-18`), emoji: "🌿" }, // Ascension + { start: new Date(`${year}-05-29`), end: new Date(`${year}-05-29`), emoji: "🔥" }, // Lundi de Pentecôte + { start: new Date(`${year}-07-14`), end: new Date(`${year}-07-14`), emoji: "🎆" }, // Fête Nationale + { start: new Date(`${year}-08-15`), end: new Date(`${year}-08-15`), emoji: "🌻" }, // Assomption { start: new Date(`${year}-11-01`), end: new Date(`${year}-11-01`), emoji: "🕯️" }, // Toussaint { start: new Date(`${year}-11-11`), end: new Date(`${year}-11-11`), emoji: "🕊️" }, // Armistice { start: new Date(`${year}-12-25`), end: new Date(`${year}-12-25`), emoji: "🎄" }, // Noël @@ -23,5 +27,5 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { } } - return "🏝️"; // Emoji par défaut + return "🏝️"; // Emoji par défaut }; From a06b5887133d0d0fe980c7f776e70587cfad343c Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Mon, 23 Dec 2024 01:51:41 +0100 Subject: [PATCH 23/30] Update holidayEmoji.ts --- src/utils/format/holidayEmoji.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index 03b81ea27..c50ca7dfa 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -27,5 +27,5 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { } } - return "🏝️"; // Emoji par défaut + return "🏝️";// Emoji par défaut }; From acbb5146bc65c22e5dce6c48b5497689f61b2361 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Mon, 23 Dec 2024 02:09:25 +0100 Subject: [PATCH 24/30] fix wekkend if lessons --- src/views/account/Home/Elements/TimetableElement.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 8673400a4..35dff99ee 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -59,9 +59,9 @@ const TimetableElement: React.FC = ({ onImportance }) => ); }; - const isWeekend = () => { + const isWeekend = (courses: TimetableClass[]) => { const today = new Date().getDay(); - return today === 6 || today === 0; // 6 = Samedi, 0 = Dimanche + return (today === 6 || today === 0) && courses.length === 0; }; const isVacation = (courses: TimetableClass[]) => @@ -140,7 +140,7 @@ const TimetableElement: React.FC = ({ onImportance }) => ); } - if (isWeekend()) { + if (isWeekend(nextCourses)) { return ( = ({ onImportance }) => ? "Cours de demain" : "Prochains cours"; - return ( <> Date: Mon, 23 Dec 2024 02:11:21 +0100 Subject: [PATCH 25/30] fix Lint --- src/views/account/Home/Elements/TimetableElement.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/account/Home/Elements/TimetableElement.tsx b/src/views/account/Home/Elements/TimetableElement.tsx index 35dff99ee..e87136ef0 100644 --- a/src/views/account/Home/Elements/TimetableElement.tsx +++ b/src/views/account/Home/Elements/TimetableElement.tsx @@ -61,7 +61,7 @@ const TimetableElement: React.FC = ({ onImportance }) => const isWeekend = (courses: TimetableClass[]) => { const today = new Date().getDay(); - return (today === 6 || today === 0) && courses.length === 0; + return (today === 6 || today === 0) && courses.length === 0; }; const isVacation = (courses: TimetableClass[]) => @@ -140,7 +140,7 @@ const TimetableElement: React.FC = ({ onImportance }) => ); } - if (isWeekend(nextCourses)) { + if (isWeekend(nextCourses)) { return ( Date: Mon, 23 Dec 2024 13:24:08 +0100 Subject: [PATCH 26/30] new emojis --- src/utils/format/holidayEmoji.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index c50ca7dfa..10266e9d2 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -2,30 +2,29 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { const year = date.getFullYear(); const allPeriods = [ - { start: new Date(`${year}-01-01`), end: new Date(`${year}-01-01`), emoji: "🎆" }, // Nouvel An - { start: new Date(`${year}-04-10`), end: new Date(`${year}-04-10`), emoji: "✝️" }, // Lundi de Pâques - { start: new Date(`${year}-05-01`), end: new Date(`${year}-05-01`), emoji: "⚒️" }, // Fête du Travail - { start: new Date(`${year}-05-08`), end: new Date(`${year}-05-08`), emoji: "🇫🇷" }, // Armistice 1945 + { start: new Date(`${year}-12-31`), end: new Date(`${year + 1}-01-01`), emoji: "🎇" }, // Nouvel An + { start: new Date(`${year}-04-10`), end: new Date(`${year}-04-10`), emoji: "🥚" }, // Lundi de Pâques + { start: new Date(`${year}-05-01`), end: new Date(`${year}-05-01`), emoji: "💼" }, // Fête du Travail + { start: new Date(`${year}-05-08`), end: new Date(`${year}-05-08`), emoji: "💐" }, // Armistice 1945 { start: new Date(`${year}-05-18`), end: new Date(`${year}-05-18`), emoji: "🌿" }, // Ascension - { start: new Date(`${year}-05-29`), end: new Date(`${year}-05-29`), emoji: "🔥" }, // Lundi de Pentecôte - { start: new Date(`${year}-07-14`), end: new Date(`${year}-07-14`), emoji: "🎆" }, // Fête Nationale + { start: new Date(`${year}-05-29`), end: new Date(`${year}-05-29`), emoji: "🕊️" }, // Lundi de Pentecôte + { start: new Date(`${year}-07-14`), end: new Date(`${year}-07-14`), emoji: "🇫🇷" }, // Fête Nationale { start: new Date(`${year}-08-15`), end: new Date(`${year}-08-15`), emoji: "🌻" }, // Assomption { start: new Date(`${year}-11-01`), end: new Date(`${year}-11-01`), emoji: "🕯️" }, // Toussaint - { start: new Date(`${year}-11-11`), end: new Date(`${year}-11-11`), emoji: "🕊️" }, // Armistice + { start: new Date(`${year}-11-11`), end: new Date(`${year}-11-11`), emoji: "💐" }, // Armistice 1918 { start: new Date(`${year}-12-25`), end: new Date(`${year}-12-25`), emoji: "🎄" }, // Noël { start: new Date(`${year}-10-19`), end: new Date(`${year}-11-04`), emoji: "🍂" }, // Vacances de la Toussaint { start: new Date(`${year}-12-21`), end: new Date(`${year + 1}-01-06`), emoji: "❄️" }, // Vacances de Noël { start: new Date(`${year + 1}-02-08`), end: new Date(`${year + 1}-03-10`), emoji: "⛷️" }, // Vacances d'hiver - { start: new Date(`${year + 1}-04-05`), end: new Date(`${year + 1}-04-28`), emoji: "🌸" }, // Vacances de printemps + { start: new Date(`${year + 1}-04-05`), end: new Date(`${year + 1}-04-28`), emoji: "🐝" }, // Vacances de printemps { start: new Date(`${year + 1}-07-05`), end: new Date(`${year + 1}-09-01`), emoji: "🏖️" }, // Grandes vacances ]; - for (const period of allPeriods) { if (date >= period.start && date <= period.end) { return period.emoji; } } - return "🏝️";// Emoji par défaut + return "🏝️"; // Emoji par défaut }; From 02b31198cce637b80913cced600ad88054a36671 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Mon, 23 Dec 2024 13:26:49 +0100 Subject: [PATCH 27/30] Update holidayEmoji.ts --- src/utils/format/holidayEmoji.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index 10266e9d2..67b87ab7c 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -2,7 +2,7 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { const year = date.getFullYear(); const allPeriods = [ - { start: new Date(`${year}-12-31`), end: new Date(`${year + 1}-01-01`), emoji: "🎇" }, // Nouvel An + { start: new Date(`${year}-12-31`), end: new Date(`${year}-01-01`), emoji: "🎇" }, // Nouvel An { start: new Date(`${year}-04-10`), end: new Date(`${year}-04-10`), emoji: "🥚" }, // Lundi de Pâques { start: new Date(`${year}-05-01`), end: new Date(`${year}-05-01`), emoji: "💼" }, // Fête du Travail { start: new Date(`${year}-05-08`), end: new Date(`${year}-05-08`), emoji: "💐" }, // Armistice 1945 @@ -14,10 +14,10 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { { start: new Date(`${year}-11-11`), end: new Date(`${year}-11-11`), emoji: "💐" }, // Armistice 1918 { start: new Date(`${year}-12-25`), end: new Date(`${year}-12-25`), emoji: "🎄" }, // Noël { start: new Date(`${year}-10-19`), end: new Date(`${year}-11-04`), emoji: "🍂" }, // Vacances de la Toussaint - { start: new Date(`${year}-12-21`), end: new Date(`${year + 1}-01-06`), emoji: "❄️" }, // Vacances de Noël - { start: new Date(`${year + 1}-02-08`), end: new Date(`${year + 1}-03-10`), emoji: "⛷️" }, // Vacances d'hiver - { start: new Date(`${year + 1}-04-05`), end: new Date(`${year + 1}-04-28`), emoji: "🐝" }, // Vacances de printemps - { start: new Date(`${year + 1}-07-05`), end: new Date(`${year + 1}-09-01`), emoji: "🏖️" }, // Grandes vacances + { start: new Date(`${year}-12-21`), end: new Date(`${year}-01-06`), emoji: "❄️" }, // Vacances de Noël + { start: new Date(`${year}-02-08`), end: new Date(`${year}-03-10`), emoji: "⛷️" }, // Vacances d'hiver + { start: new Date(`${year}-04-05`), end: new Date(`${year}-04-28`), emoji: "🐝" }, // Vacances de printemps + { start: new Date(`${year}-07-05`), end: new Date(`${year}-09-01`), emoji: "🏖️" }, // Grandes vacances ]; for (const period of allPeriods) { From d204f59481ad8293bca77e7eba7a07a94b730bb3 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Mon, 23 Dec 2024 23:35:50 +0100 Subject: [PATCH 28/30] Update src/utils/format/holidayEmoji.ts Co-authored-by: Vinicel <34098640+vinicel@users.noreply.github.com> --- src/utils/format/holidayEmoji.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index 67b87ab7c..023d2fd01 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -1,7 +1,7 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { const year = date.getFullYear(); - const allPeriods = [ + const periods = [ { start: new Date(`${year}-12-31`), end: new Date(`${year}-01-01`), emoji: "🎇" }, // Nouvel An { start: new Date(`${year}-04-10`), end: new Date(`${year}-04-10`), emoji: "🥚" }, // Lundi de Pâques { start: new Date(`${year}-05-01`), end: new Date(`${year}-05-01`), emoji: "💼" }, // Fête du Travail From 988c04a983a7bd5f87f0369399b312f625f445e4 Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Mon, 23 Dec 2024 23:35:58 +0100 Subject: [PATCH 29/30] Update src/utils/format/holidayEmoji.ts Co-authored-by: Vinicel <34098640+vinicel@users.noreply.github.com> --- src/utils/format/holidayEmoji.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index 023d2fd01..f630ad82a 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -20,11 +20,5 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { { start: new Date(`${year}-07-05`), end: new Date(`${year}-09-01`), emoji: "🏖️" }, // Grandes vacances ]; - for (const period of allPeriods) { - if (date >= period.start && date <= period.end) { - return period.emoji; - } - } - - return "🏝️"; // Emoji par défaut +return periods.find((period) => date >= period.start && date <= period.end)?.emoji ?? "🏝️"; }; From 532b8dbbcb2c9e9818d85285e42ab31677258bfb Mon Sep 17 00:00:00 2001 From: JyhuKo Date: Tue, 24 Dec 2024 00:27:24 +0100 Subject: [PATCH 30/30] fix lint --- src/utils/format/holidayEmoji.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/format/holidayEmoji.ts b/src/utils/format/holidayEmoji.ts index f630ad82a..a71f972a2 100644 --- a/src/utils/format/holidayEmoji.ts +++ b/src/utils/format/holidayEmoji.ts @@ -20,5 +20,5 @@ export const getHolidayEmoji = (date: Date = new Date()): string => { { start: new Date(`${year}-07-05`), end: new Date(`${year}-09-01`), emoji: "🏖️" }, // Grandes vacances ]; -return periods.find((period) => date >= period.start && date <= period.end)?.emoji ?? "🏝️"; + return periods.find((period) => date >= period.start && date <= period.end)?.emoji ?? "🏝️"; };