diff --git a/frontend/src/pages/Login.jsx b/frontend/src/pages/Login.jsx index 71d1644..afc571a 100644 --- a/frontend/src/pages/Login.jsx +++ b/frontend/src/pages/Login.jsx @@ -1,11 +1,17 @@ import React, { useState, useEffect } from 'react'; import { useStore } from '../stores/store'; +const jourLabel = (jour) => { + if (!jour) return 'Jour à préciser'; + return jour.charAt(0).toUpperCase() + jour.slice(1); +}; + export default function Login() { const { login, loading, error, groupes, loadGroupes, setPage } = useStore(); const [courriel, setCourriel] = useState(localStorage.getItem('gm_courriel') || ''); const [pin, setPin] = useState(''); const [groupeId, setGroupeId] = useState(localStorage.getItem('gm_groupe_id') || ''); + const [groupeOuvert, setGroupeOuvert] = useState(localStorage.getItem('gm_groupe_id') || ''); const [seSouvenir, setSeSouvenir] = useState(!!localStorage.getItem('gm_courriel')); useEffect(() => { @@ -18,6 +24,7 @@ export default function Login() { if (groupeId && groupeExiste) return; const prochainGroupeId = groupes.length === 1 ? groupes[0].id : ''; setGroupeId(prochainGroupeId); + setGroupeOuvert(prochainGroupeId); if (prochainGroupeId) { localStorage.setItem('gm_groupe_id', prochainGroupeId); } else { @@ -25,6 +32,13 @@ export default function Login() { } }, [groupes, groupeId]); + const ouvrirGroupe = (id) => { + const prochain = groupeOuvert === id ? '' : id; + setGroupeOuvert(prochain); + setGroupeId(id); + localStorage.setItem('gm_groupe_id', id); + }; + const handleSubmit = async (e) => { e.preventDefault(); if (!courriel || !pin || !groupeId) return; @@ -33,114 +47,120 @@ export default function Login() { } catch {} }; - const groupeActif = groupes.find((g) => g.id === groupeId); - return ( -
District 87-16 · Région 87
-- 📍 - {groupeActif.adresse_local} -
- )} - {groupeActif.jour_reunion && ( -- 📅 - - {groupeActif.jour_reunion.charAt(0).toUpperCase() + groupeActif.jour_reunion.slice(1)} - {groupeActif.heure_reunion && ` à ${groupeActif.heure_reunion}`} - -
- )} - {groupeActif.format_reunion && ( -- 📖 - {groupeActif.format_reunion} -
- )} +Choisir un groupe
100% logiciel libre · Hébergé au Québec
+ {ouvert && ( +Lieu : {groupe.adresse_local}
+ )} + {groupe.format_reunion && ( +Format : {groupe.format_reunion}
+ )} + {groupe.district && ( +District : {groupe.district}
+ )} +100% logiciel libre · Hébergé au Québec
+