diff --git a/backend/src/controllers/permanence.controller.ts b/backend/src/controllers/permanence.controller.ts index 87f5336..f873651 100644 --- a/backend/src/controllers/permanence.controller.ts +++ b/backend/src/controllers/permanence.controller.ts @@ -58,37 +58,37 @@ export const createPermanence = async (req: Request, res: Response) => { export const updatePermanence = async (req: Request, res: Response) => { - const { permId, name, description, location, start_at, end_at, capacity, difficulty, respoId } = req.body; - if (!name || !location || !start_at || !end_at || !capacity || !difficulty) { - Error(res, { msg: "Tous les champs sont requis" }); - return; - } - - const validation = validatePermanenceData(start_at, end_at); - if (!validation.valid) { - Error(res, { msg: validation.msg }); - return; - } - - try { - await permanence_service.updatePermanence( - permId, - name, - description, - location, - new Date(start_at), - new Date(end_at), - Number(capacity), - Number(difficulty), - Number(respoId) - ); - Ok(res, { msg: "Permanence mis à jour avec succès" }); - } catch (err) { - console.error(err); - Error(res, { msg: "Erreur lors de la mis à jour de la permanence" }); - } + const { permId, name, description, location, start_at, end_at, capacity, difficulty, respoId } = req.body; + + const validation = validatePermanenceData(start_at, end_at); + if (!validation.valid) { + Error(res, { msg: validation.msg }); + return; + } + + try { + const perm = await permanence_service.getPermanenceById(permId); + + await permanence_service.updatePermanence( + permId ?? perm.id, + name ?? perm.name, + description ?? perm.description, + location ?? perm.location, + start_at ? new Date(start_at) : perm.start_at, + end_at ? new Date(end_at) : perm.end_at, + capacity !== undefined ? Number(capacity) : perm.capacity, + difficulty !== undefined ? Number(difficulty) : perm.difficulty, + Number(respoId) + ); + + Ok(res, { msg: "Permanence mise à jour avec succès" }); + } catch (err) { + console.error(err); + Error(res, { msg: "Erreur lors de la mise à jour de la permanence" }); + } }; + // ➕ Créer une permanence export const deletePermanence = async (req: Request, res: Response) => { diff --git a/frontend/src/components/Admin/AdminPerm/adminPermForm.tsx b/frontend/src/components/Admin/AdminPerm/adminPermForm.tsx index 6c06e2f..2b9b0f1 100644 --- a/frontend/src/components/Admin/AdminPerm/adminPermForm.tsx +++ b/frontend/src/components/Admin/AdminPerm/adminPermForm.tsx @@ -69,17 +69,16 @@ const PermanenceForm = ({ }, [editMode, editPermanence]); const handleSubmit = async () => { - if ( - !name || - !desc || - !location || - !startAt || - !endAt || - !capacity || - !difficulty - ) { - Swal.fire("Erreur", "Veuillez remplir tous les champs", "warning"); - return; + if (!editMode) { + if (!name || !desc || !location || !startAt || !endAt) { + Swal.fire("Erreur", "Veuillez remplir tous les champs", "warning"); + return; + } + + if (capacity < 0 || difficulty < 0) { + Swal.fire("Erreur", "Capacité et difficulté doivent être positives", "warning"); + return; + } } diff --git a/frontend/src/components/auth/authForm.tsx b/frontend/src/components/auth/authForm.tsx index cbc4693..3dafd77 100644 --- a/frontend/src/components/auth/authForm.tsx +++ b/frontend/src/components/auth/authForm.tsx @@ -82,69 +82,74 @@ export const AuthForm = () => { }; return ( -
-
-
-

Connexion

- - {error &&

{error}

} - -
-
-
- - -
-
- - -
+
+
+
+

Connexion

+ + {error &&

{error}

} + + +
+
+ +
- -
- - - - - -

- ✉️ Tu es un nouveau ? Vérifie ton mail pour activer ton compte. -

+
+ +
- -
+
+ +
+ + + + +

+ ✉️ Nouveau ? Ton compte se crée via login + mot de passe. + Vérifie ton mail pour l’activer. +

+
+ + {/* Bouton CAS placé en bas avec précision */} +
+ +
+
- ); +
+); }