Better canceled trains display
This commit is contained in:
@ -141,7 +141,7 @@ function TrainRow({train, tableType, date, time}) {
|
||||
enabled: !!trip.id,
|
||||
})
|
||||
const realtimeTripData = realtimeTripQuery.data ?? {}
|
||||
const scheduleRelationship = realtimeTripData.schedule_relationship ?? 0
|
||||
const tripScheduleRelationship = realtimeTripData.schedule_relationship ?? 0
|
||||
|
||||
const realtimeQuery = useQuery({
|
||||
queryKey: ['realtime', train.id, date, time],
|
||||
@ -150,13 +150,16 @@ function TrainRow({train, tableType, date, time}) {
|
||||
enabled: !!train.id,
|
||||
})
|
||||
const realtimeData = realtimeQuery.data ?? {}
|
||||
const stopScheduleRelationship = realtimeData.schedule_relationship ?? 0
|
||||
|
||||
const canceled = tripScheduleRelationship === 3 || stopScheduleRelationship === 1
|
||||
|
||||
const delay = tableType === "departures" ? realtimeData.departure_delay : realtimeData.arrival_delay
|
||||
const prettyDelay = delay && scheduleRelationship !== 3 ? getPrettyDelay(delay) : ""
|
||||
const [prettyScheduleRelationship, scheduleRelationshipColor] = getPrettyScheduleRelationship(scheduleRelationship)
|
||||
const prettyDelay = delay && !canceled ? getPrettyDelay(delay) : ""
|
||||
const [prettyScheduleRelationship, scheduleRelationshipColor] = getPrettyScheduleRelationship(tripScheduleRelationship, stopScheduleRelationship)
|
||||
|
||||
let stopsFilter
|
||||
if (scheduleRelationship === 3)
|
||||
if (canceled)
|
||||
stopsFilter = (stop_time) => true
|
||||
else if (tableType === "departures")
|
||||
stopsFilter = (stop_time) => stop_time.stop_sequence > train.stop_sequence && stop_time.drop_off_type === 0
|
||||
@ -196,7 +199,8 @@ function TrainRow({train, tableType, date, time}) {
|
||||
<Box fontWeight="bold" color="#FFED02" fontSize={24}>
|
||||
{getDisplayTime(train, tableType)}
|
||||
</Box>
|
||||
<Box color={delay && delay !== "00:00:00" ? "#e86d2b" : "white"} fontWeight={delay && delay !== "00:00:00" ? "bold" : ""}>
|
||||
<Box color={delay && delay !== "00:00:00" ? "#e86d2b" : "white"}
|
||||
fontWeight={delay && delay !== "00:00:00" ? "bold" : ""}>
|
||||
{prettyDelay}
|
||||
</Box>
|
||||
<Box color={scheduleRelationshipColor} fontWeight="bold">
|
||||
@ -206,8 +210,10 @@ function TrainRow({train, tableType, date, time}) {
|
||||
</Box>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Typography fontSize={24} fontWeight="bold" data-stop-id={headline.id}>{headline.name}</Typography>
|
||||
<span className="stops">{stopsNames}</span>
|
||||
<Box style={{textDecoration: canceled ? 'line-through': ''}}>
|
||||
<Typography fontSize={24} fontWeight="bold" data-stop-id={headline.id}>{headline.name}</Typography>
|
||||
<span className="stops">{stopsNames}</span>
|
||||
</Box>
|
||||
</TableCell>
|
||||
</StyledTableRow>
|
||||
</>
|
||||
@ -324,14 +330,19 @@ function getPrettyDelay(delay) {
|
||||
return full_minutes ? `+${full_minutes} min` : "À l'heure"
|
||||
}
|
||||
|
||||
function getPrettyScheduleRelationship(scheduledRelationship) {
|
||||
switch (scheduledRelationship) {
|
||||
function getPrettyScheduleRelationship(tripScheduledRelationship, stopScheduledRelationship) {
|
||||
switch (tripScheduledRelationship) {
|
||||
case 1:
|
||||
return ["Ajouté", "#3ebb18"]
|
||||
case 3:
|
||||
return ["Supprimé", "#ff8701"]
|
||||
default:
|
||||
return ["", ""]
|
||||
switch (stopScheduledRelationship) {
|
||||
case 1:
|
||||
return ["Supprimé", "#ff8701"]
|
||||
default:
|
||||
return ["", ""]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user