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' }, { id: 'afl', label: 'AFL' }, { id: 'transilien', label: 'TRANSILIEN' } ]; // 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])) { try { gare = decodeURIComponent(parts.slice(1).join('/')); } catch (e) { gare = parts.slice(1).join('/'); } } else { const paramsForGare = new URLSearchParams(window.location.search || ''); const g = paramsForGare.get('gare'); if (g) { try { gare = decodeURIComponent(String(g).replace(/\+/g, ' ')).replace(/-/g, ' '); } catch (e) { gare = String(g).replace(/-/g, ' '); } } } // 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) {} } if (!mode) mode = 'departs'; return (
Gare sélectionnée : {gare}
}Mode sélectionné : {mode === 'arrivees' ? 'Arrivées' : 'Départs'}
Afficher le style {t.label} pour la gare {gare || ''}.