diff --git a/backend/package.json b/backend/package.json index bc5808b..e6f9d80 100644 --- a/backend/package.json +++ b/backend/package.json @@ -64,6 +64,7 @@ "eslint-plugin-unused-imports": "^4.4.1", "globals": "^15.15.0", "nodemon": "^3.1.9", + "prettier": "^3.9.6", "ts-node": "^10.9.2", "tsx": "^4.19.3", "typescript": "^5.8.3", diff --git a/backend/pnpm-lock.yaml b/backend/pnpm-lock.yaml index 9c971a9..7ecb392 100644 --- a/backend/pnpm-lock.yaml +++ b/backend/pnpm-lock.yaml @@ -129,6 +129,9 @@ importers: nodemon: specifier: ^3.1.9 version: 3.1.14 + prettier: + specifier: ^3.9.6 + version: 3.9.6 ts-node: specifier: ^10.9.2 version: 10.9.2(@types/node@22.20.1)(typescript@5.9.3) @@ -2273,6 +2276,11 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + prettier@3.9.6: + resolution: {integrity: sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==} + engines: {node: '>=14'} + hasBin: true + proxy-addr@2.0.7: resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} engines: {node: '>= 0.10'} @@ -4903,6 +4911,8 @@ snapshots: prelude-ls@1.2.1: {} + prettier@3.9.6: {} + proxy-addr@2.0.7: dependencies: forwarded: 0.2.0 diff --git a/backend/src/middlewares/multer.middleware.ts b/backend/src/middlewares/multer.middleware.ts index 1d42489..193ab05 100644 --- a/backend/src/middlewares/multer.middleware.ts +++ b/backend/src/middlewares/multer.middleware.ts @@ -14,6 +14,7 @@ export enum MIMEType { const acceptedMIMETypesByItem: Record> = { foodmenu: { menu: [MIMEType.PDF], + allergens: [MIMEType.PDF], }, news: {}, notebooks: { @@ -23,6 +24,7 @@ const acceptedMIMETypesByItem: Record> = { plannings: { tc: [MIMEType.PDF], tci: [MIMEType.PDF], + ri: [MIMEType.PDF], bachelor_ia: [MIMEType.PDF], fise: [MIMEType.PDF], fisea: [MIMEType.PDF], diff --git a/frontend/package.json b/frontend/package.json index eabf39d..b910d3b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -58,6 +58,7 @@ "eslint-plugin-simple-import-sort": "^13.0.0", "eslint-plugin-unused-imports": "^4.4.1", "globals": "^15.15.0", + "prettier": "^3.9.6", "typescript": "~5.7.2", "typescript-eslint": "^8.24.1", "vite": "^6.4.2" diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 9b1f503..a6963f3 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -141,6 +141,9 @@ importers: globals: specifier: ^15.15.0 version: 15.15.0 + prettier: + specifier: ^3.9.6 + version: 3.9.6 typescript: specifier: ~5.7.2 version: 5.7.3 @@ -2898,6 +2901,11 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + prettier@3.9.6: + resolution: {integrity: sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==} + engines: {node: '>=14'} + hasBin: true + prompts@2.4.2: resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} engines: {node: '>= 6'} @@ -6406,6 +6414,8 @@ snapshots: prelude-ls@1.2.1: {} + prettier@3.9.6: {} + prompts@2.4.2: dependencies: kleur: 3.0.3 diff --git a/frontend/src/components/Admin/adminExportImport.tsx b/frontend/src/components/Admin/adminExportImport.tsx index 33a01e5..418d572 100644 --- a/frontend/src/components/Admin/adminExportImport.tsx +++ b/frontend/src/components/Admin/adminExportImport.tsx @@ -89,6 +89,7 @@ export const AdminImportFoodMenu = () => { + ); @@ -108,6 +109,7 @@ export const AdminImportPlannings = () => { + diff --git a/frontend/src/components/Plannings/planningSection.tsx b/frontend/src/components/Plannings/planningSection.tsx index 2845626..22614d5 100644 --- a/frontend/src/components/Plannings/planningSection.tsx +++ b/frontend/src/components/Plannings/planningSection.tsx @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react'; +import { checkUploadAvailability } from '../../utils/utils'; import { Card, CardContent, CardHeader, CardTitle } from '../ui/card'; type Planning = { @@ -32,6 +33,10 @@ const plannings: Planning[] = [ name: 'Planning Master', url: `${import.meta.env.VITE_API_URL}/uploads/plannings/master.pdf`, }, + { + name: 'Etudiants Etranger / International Students', + url: `${import.meta.env.VITE_API_URL}/uploads/plannings/ri.pdf`, + }, ]; export const PlanningSection = () => { @@ -42,8 +47,7 @@ export const PlanningSection = () => { const availability: Record = {}; for (const planning of plannings) { try { - const response = await fetch(planning.url, { method: 'HEAD' }); - availability[planning.name] = response.ok; + availability[planning.name] = await checkUploadAvailability(planning.url); } catch { availability[planning.name] = false; } diff --git a/frontend/src/components/WEI_SDI_Food/foodSection.tsx b/frontend/src/components/WEI_SDI_Food/foodSection.tsx index 44ee840..6c11a73 100644 --- a/frontend/src/components/WEI_SDI_Food/foodSection.tsx +++ b/frontend/src/components/WEI_SDI_Food/foodSection.tsx @@ -1,19 +1,22 @@ -import { useEffect, useState } from "react"; +import { useEffect, useState } from 'react'; -import { checkFoodStatus } from "../../services/requests/event.service"; -import { getPermission } from "../../services/requests/user.service"; -import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"; +import { checkFoodStatus } from '../../services/requests/event.service'; +import { getPermission } from '../../services/requests/user.service'; +import { checkUploadAvailability } from '../../utils/utils'; +import { Card, CardContent, CardHeader, CardTitle } from '../ui/card'; export const FoodSection = () => { const [isFoodOpen, setIsFoodOpen] = useState(false); const [isMenuAvailable, setIsMenuAvailable] = useState(false); + const [isAllergensAvailable, setIsAllergensAvailable] = useState(false); const permission = getPermission(); const menuUrl = `${import.meta.env.VITE_API_URL}/uploads/foodmenu/menu.pdf`; + const allergensUrl = `${import.meta.env.VITE_API_URL}/uploads/foodmenu/allergens.pdf`; useEffect(() => { - const script = document.createElement("script"); - script.src = "https://www.billetweb.fr/js/export.js"; + const script = document.createElement('script'); + script.src = 'https://www.billetweb.fr/js/export.js'; script.async = true; document.body.appendChild(script); @@ -22,25 +25,14 @@ export const FoodSection = () => { const status = await checkFoodStatus(); setIsFoodOpen(status); } catch { - alert("Erreur lors de la récupération du statut de la nourriture."); - } - }; - - const checkMenuAvailability = async () => { - try { - const response = await fetch(menuUrl, { method: "HEAD" }); - if (response.ok) { - setIsMenuAvailable(true); - } - } catch { - // Ne rien faire si le fichier n'est pas disponible + alert('Erreur lors de la récupération du statut de la nourriture.'); } }; void fetchStatus(); - void checkMenuAvailability(); - }, [menuUrl]); - + checkUploadAvailability(menuUrl, () => setIsMenuAvailable(true)); + checkUploadAvailability(allergensUrl, () => setIsAllergensAvailable(true)); + }, [menuUrl, allergensUrl]); return ( @@ -58,9 +50,7 @@ export const FoodSection = () => {

🚫 Les menus de la semaine ne sont pas encore disponibles.

-

- Reste connecté, ils seront bientôt publiés ! -

+

Reste connecté, ils seront bientôt publiés !

) : ( @@ -70,19 +60,34 @@ export const FoodSection = () => { -