Compare commits

...

2 Commits

Author SHA1 Message Date
Emmy D'Anello f0964d8fb7
Better datetime handle 2024-11-11 22:28:05 +01:00
Emmy D'Anello e58ad34e43
Update logo for CTS 2024-11-11 22:05:00 +01:00
2 changed files with 13 additions and 7 deletions

View File

@ -26,7 +26,6 @@ function DateTimeSelector({datetime, setDatetime}) {
Modifier la date et l'heure de recherche : Modifier la date et l'heure de recherche :
</FormLabel> </FormLabel>
<DateTimePicker name="date" label="Date" onChange={setDatetime} value={datetime} /> <DateTimePicker name="date" label="Date" onChange={setDatetime} value={datetime} />
<Button type="submit">Rechercher</Button>
</Box> </Box>
</> </>
} }
@ -36,7 +35,11 @@ function Station() {
let {theme, stationId} = useParams() let {theme, stationId} = useParams()
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
let [searchParams, setSearchParams] = useSearchParams() let [searchParams, setSearchParams] = useSearchParams()
const [datetime, setDatetime] = useState(dayjs()) const [datetime, setDatetime] = useState(dayjs(searchParams.get('time') || undefined))
if (datetime.format() !== searchParams.get('time')) {
searchParams.set('time', datetime.format())
window.history.replaceState({}, '', '?' + searchParams.toString())
}
useQueryClient() useQueryClient()
const stationQuery = useQuery({ const stationQuery = useQuery({

View File

@ -69,10 +69,10 @@ function TrainsTableBody({station, datetime, tableType}) {
.then(response => response.json()) .then(response => response.json())
.then(data => data.stopTimes) .then(data => data.stopTimes)
.then(data => [...data]) .then(data => [...data])
}, [station.stopId, datetime, tableType]) }, [station.stopId, tableType, datetime])
const trainsQuery = useQuery({ const trainsQuery = useQuery({
queryKey: ['trains', station.stopId, tableType], queryKey: ['trains', station.stopId, tableType, datetime],
queryFn: updateTrains, queryFn: updateTrains,
enabled: !!station.stopId, enabled: !!station.stopId,
}) })
@ -202,9 +202,13 @@ function getTrainType(train) {
default: default:
return trainType return trainType
} }
case "FR-IDF-IDFM": case "FR-IDFM":
const route_split = train.routeShortName.split(" ")
if (route_split[0] === "Bus")
return route_split[1]
return route_split[0]
case "FR-GES-CTS": case "FR-GES-CTS":
return "A" return train.routeShortName.split(" ")[1]
case "FR-EUROSTAR": case "FR-EUROSTAR":
return "Eurostar" return "Eurostar"
case "IT-FRA-TI": case "IT-FRA-TI":
@ -216,7 +220,6 @@ function getTrainType(train) {
return "NJ" return "NJ"
return "ÖBB" return "ÖBB"
case "CH-ALL": case "CH-ALL":
return "A"
default: default:
return train.routeShortName?.split(" ")[0] return train.routeShortName?.split(" ")[0]
} }