diff --git a/src/components/StationTimeTable.tsx b/src/components/StationTimeTable.tsx index 4a09b7eb..d8eb55c1 100644 --- a/src/components/StationTimeTable.tsx +++ b/src/components/StationTimeTable.tsx @@ -20,7 +20,7 @@ type StationTimeTableProps = { stationCode: string; timeTableType: TimeTableRowType; trains: TrainByStationFragment[]; - tableRowOnClick: (trainNumber: number, scheduledTime: Date) => void; + tableRowOnClick: (trainNumber: number, departureDate: string) => void; }; function StationTimeTable({ diff --git a/src/components/StationTimeTableRow.tsx b/src/components/StationTimeTableRow.tsx index d12857a6..3d82a356 100644 --- a/src/components/StationTimeTableRow.tsx +++ b/src/components/StationTimeTableRow.tsx @@ -15,12 +15,8 @@ import { TimeTableRowType, TrainByStationFragment, } from '../graphql/generated/digitraffic'; -import { formatEET } from '../utils/date'; import getTimeTableRowForStation from '../utils/getTimeTableRowForStation'; -import { - getTrainDestinationStationName, - getTrainScheduledDepartureTime, -} from '../utils/train'; +import { getTrainDestinationStationName } from '../utils/train'; import TimeTableRowTime from './TimeTableRowTime'; import VehicleTrackingIcon from './VehicleTrackingIcon'; @@ -29,7 +25,7 @@ type StationTimeTableRowProps = { train: TrainByStationFragment; stationCode: string; timeTableType: TimeTableRowType; - tableRowOnClick: (trainNumber: number, scheduledTime: Date) => void; + tableRowOnClick: (trainNumber: number, departureDate: string) => void; }; function StationTimeTableRow({ @@ -41,11 +37,11 @@ function StationTimeTableRow({ const handleStationClick = (e: React.MouseEvent) => e.stopPropagation(); const trainNumber = train.trainNumber; + const departureDate = train.departureDate; const trainName = train.commuterLineid ? train.commuterLineid : train.trainType.name + train.trainNumber; const destinationStationName = getTrainDestinationStationName(train); - const departureTime = getTrainScheduledDepartureTime(train); const stationRow = getTimeTableRowForStation( stationCode, train, @@ -59,11 +55,7 @@ function StationTimeTableRow({ sx={{ cursor: 'pointer', }} - onClick={() => { - if (departureTime) { - tableRowOnClick(trainNumber, departureTime); - } - }} + onClick={() => tableRowOnClick(trainNumber, departureDate)} > diff --git a/src/pages/[station].tsx b/src/pages/[station].tsx index 9afeec86..a02ad661 100644 --- a/src/pages/[station].tsx +++ b/src/pages/[station].tsx @@ -71,12 +71,9 @@ const Station: NextPageWithLayout = () => { }, []); const handleTimeTableRowClick = useCallback( - (trainNumber: number, scheduledTime: Date) => { + (trainNumber: number, departureDate: string) => { router.push( - `/train/${trainNumber}/${formatEET( - scheduledTime, - 'yyyy-MM-dd' - )}?station=${stationCode}` + `/train/${trainNumber}/${departureDate}?station=${stationCode}` ); }, [router, stationCode]