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 ( -
-
+
+
+
☮️

Groupe Méditation

-

District 87-16 · Région 87

-
- - {/* Infos du groupe */} - {groupeActif && ( -
- {groupeActif.adresse_local && ( -

- 📍 - {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

- )} - -
- {groupes.length > 1 && ( - - )} - - setCourriel(e.target.value)} - className="w-full p-4 bg-gray-50 rounded-xl text-lg border-0 focus:ring-2 focus:ring-aa-blue" - autoComplete="username" - inputMode="email" - /> - - setPin(e.target.value.replace(/\D/g, '').slice(0, 4))} - className="w-full p-4 bg-gray-50 rounded-xl text-lg text-center tracking-[1em] border-0 focus:ring-2 focus:ring-aa-blue" - /> - - - - {error && ( -

{error}

- )} - - Découvrir l'application - -
+
+ {groupes.length === 0 ? ( +
+ Chargement des groupes... +
+ ) : groupes.map((groupe) => { + const ouvert = groupeOuvert === groupe.id; + const horaire = `${jourLabel(groupe.jour_reunion)}${groupe.heure_reunion ? ` · ${groupe.heure_reunion}` : ''}`; + return ( +
+ -

100% logiciel libre · Hébergé au Québec

+ {ouvert && ( +
+
+ {groupe.adresse_local && ( +

Lieu : {groupe.adresse_local}

+ )} + {groupe.format_reunion && ( +

Format : {groupe.format_reunion}

+ )} + {groupe.district && ( +

District : {groupe.district}

+ )} +
+ +
+ setCourriel(e.target.value)} + className="w-full rounded-xl border-0 bg-gray-50 p-4 text-lg focus:ring-2 focus:ring-aa-blue" + autoComplete="username" + inputMode="email" + /> + + setPin(e.target.value.replace(/\D/g, '').slice(0, 4))} + className="w-full rounded-xl border-0 bg-gray-50 p-4 text-center text-lg tracking-[0.8em] focus:ring-2 focus:ring-aa-blue" + /> + + + + {error && ( +

{error}

+ )} + + + + +
+
+ )} +
+ ); + })} +
+ +

100% logiciel libre · Hébergé au Québec

+
); }