Recreate station screen with ReactJS

This commit is contained in:
2024-01-28 20:06:55 +01:00
parent 0890460ba7
commit 6317c900ef
24 changed files with 18813 additions and 12 deletions

View File

@ -0,0 +1,32 @@
import './sncf.scss'
import {useParams} from "react-router-dom"
import TrainsTable from "./TrainsTable"
import {useEffect, useState} from "react";
function Station() {
let {stopId} = useParams()
let [stop, setStop] = useState({'name': "Chargement…"})
useEffect(() => {
fetch(`http://localhost:8000/api/gtfs/stop/${stopId}/`)
.then(response => response.json())
.then(data => {
setStop(data)
})
}, [stopId])
return (
<div className="Station">
<header className="App-header">
<h1>Horaires en gare de {stop.name}</h1>
</header>
<main>
<TrainsTable stop={stop} tableType="departures" />
<TrainsTable stop={stop} tableType="arrivals" />
</main>
</div>
)
}
export default Station;