RELEASE V5.0.0 : Voici les modifications apportées :

-> IMPLÉMENTATION DONNÉES GTFS / GTFS-RT / SIRI LTE SNCF
-> RESTRUCTURATION DE L'APP.

FONCTIONNALITÉS EN COURS DE DÉVELOPPEMENT :

-> REFONTE DU DESIGN DES AFFICHEURS CLASSIQUES
-> AMÉLIORATION DES
This commit is contained in:
mathis committed 2026-08-30 01:58:16 +02:00
1 parent 0e0d8c435f
commit 72de543dc6
18 files changed
+1550 -544

No files matched your search

+40 -32
View File
@@ -1,8 +1,12 @@
import React from 'react';
import WcsButton from '../components/WcsButton';
import sessionMemory from '../lib/sessionMemory';
import { getSourceFromPath } from '../services/railwayService';
export default function Displays({ onBack, navigate }) {
const source = getSourceFromPath(window.location.pathname);
const prefix = source === 'supabase' ? '/ferrovia' : '';
const types = [
{ id: 'classiques', label: 'Classiques' },
{ id: 'eva', label: 'EVA' },
@@ -10,25 +14,23 @@ export default function Displays({ onBack, navigate }) {
{ id: 'transilien', label: 'TRANSILIEN' }
];
// Récupérer la gare : soit dans le pathname (/afficheurs/<gare>),
// soit via la querystring ?gare=... si la route est déjà /afficheurs/<type>/<mode>
const parts = typeof window !== 'undefined' ? window.location.pathname.split('/').filter(Boolean) : [];
// Nettoyage du chemin pour extraire la gare même avec /ferrovia
const cleanPath = (typeof window !== 'undefined' ? window.location.pathname : '').replace(/^\/ferrovia/, '');
const parts = cleanPath.split('/').filter(Boolean);
const typeIds = types.map(t => t.id);
let gare = null;
if (parts[0] === 'afficheurs' && parts[1] && !typeIds.includes(parts[1])) {
// cas /afficheurs/<gare>
try {
gare = decodeURIComponent(parts.slice(1).join('/'));
} catch (e) {
gare = parts.slice(1).join('/');
}
} else {
// si l'URL est /afficheurs/<type>/<mode>, regarder dans la querystring ?gare=...
const paramsForGare = new URLSearchParams(window.location.search || '');
const g = paramsForGare.get('gare');
if (g) {
try {
// décoder puis remplacer les tirets par des espaces pour l'affichage
gare = decodeURIComponent(String(g).replace(/\+/g, ' ')).replace(/-/g, ' ');
} catch (e) {
gare = String(g).replace(/-/g, ' ');
@@ -36,37 +38,52 @@ export default function Displays({ onBack, navigate }) {
}
}
// déterminer le mode (departs/arrivees) : querystring > localStorage > default('departs')
// Déterminer le mode (departs/arrivees)
const params = new URLSearchParams(window.location.search || '');
let mode = params.get('mode');
if (!mode) {
try {
const stored = sessionMemory.get('afficheurMode');
if (stored) mode = stored;
} catch (e) {
// ignore
}
} catch (e) {}
}
if (!mode) mode = 'departs';
return (
<div style={{ padding: 20 }}>
<h1>Choisissez un type d'afficheur</h1>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
<h1 style={{ margin: 0 }}>Choisissez un type d'afficheur</h1>
<span style={{
fontSize: '12px',
fontWeight: '600',
padding: '4px 10px',
borderRadius: '12px',
background: source === 'supabase' ? '#e6f4ea' : '#e8f0fe',
color: source === 'supabase' ? '#137333' : '#1a73e8'
}}>
{source === 'supabase' ? '🗄️ BDD Ferrovia' : '🌐 SNCF (GTFS)'}
</span>
</div>
{gare && <p>Gare sélectionnée : <strong>{gare}</strong></p>}
<p>Mode sélectionné : <strong>{mode === 'arrivees' ? 'Arrivées' : 'Départs'}</strong></p>
{/* Boutons directs pour afficher les afficheurs classiques supprimés */}
<div style={{ display: 'flex', gap: 16, flexWrap: 'wrap', marginTop: 16 }}>
{types.map((t) => (
<div key={t.id} role="button" tabIndex={0} style={{ width: 220, padding: 16, borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.08)', background: '#fff', cursor: 'pointer' }} onClick={() => {
if (typeof navigate === 'function') {
const kebab = gare ? String(gare).trim().replace(/\s+/g, '-').replace(/\//g, '/') : '';
navigate(`/select-afficheur?gare=${encodeURIComponent(kebab)}&mode=${mode}&type=${t.id}`);
return;
}
alert(`${t.label} pour ${gare || '—'}`);
}}>
<div
key={t.id}
role="button"
tabIndex={0}
style={{ width: 220, padding: 16, borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.08)', background: '#fff', cursor: 'pointer' }}
onClick={() => {
if (typeof navigate === 'function') {
const kebab = gare ? String(gare).trim().replace(/\s+/g, '-').replace(/\//g, '/') : '';
navigate(`${prefix}/select-afficheur?gare=${encodeURIComponent(kebab)}&mode=${mode}&type=${t.id}`);
return;
}
alert(`${t.label} pour ${gare || '—'}`);
}}
>
<h3 style={{ margin: '0 0 8px' }}>{t.label}</h3>
<p style={{ margin: 0, color: '#555' }}>Afficher le style {t.label} pour la gare {gare || ''}.</p>
</div>
@@ -74,29 +91,21 @@ export default function Displays({ onBack, navigate }) {
</div>
<div style={{ marginTop: 24 }}>
{/* Bouton de retour au style WCS SNCF */}
<WcsButton
// Styliser le bouton comme un bouton d'action WCS. On peut ajuster `mode` ou
// ajouter `className` (ex: "wcs-primary") si vous avez des classes globales.
mode="plain"
className="wcs-primary"
onClick={() => {
// Appelle le callback fourni par le routeur simple si disponible
try {
if (typeof onBack === 'function') {
onBack();
return;
}
} catch (e) {
// ignore
}
} catch (e) {}
// Fallback : si l'historique du navigateur permet un back, on l'utilise
if (typeof window !== 'undefined' && window.history && window.history.length > 1) {
window.history.back();
} else {
// Redirection sûre vers la racine
window.location.href = '/';
window.location.href = prefix || '/';
}
}}
label="Retour"
@@ -105,4 +114,3 @@ export default function Displays({ onBack, navigate }) {
</div>
);
}