Skip to content

Commit

Permalink
runnable for TA test
Browse files Browse the repository at this point in the history
  • Loading branch information
NishilJ committed Nov 15, 2024
1 parent 8793793 commit 2f3a6fa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/components/Departures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
Divider,
useAsyncList,
} from '@adobe/react-spectrum';
import moment from 'moment';

interface Stop {
id: string;
Expand Down Expand Up @@ -54,7 +53,7 @@ const fetchNearbyStations = async (latitude: number, longitude: number) => {
// Function to fetch departures for a given stop
const fetchDepartures = async (stopId: string) => {
const res = await fetch(
`http://motis.metroll.live/api/v1/stoptimes?stopId=${stopId}&time=${new Date().toISOString()}&arriveBy=false&n=10`
`http://motis.metroll.live/api/v1/stoptimes?stopId=${stopId}&arriveBy=false&n=10`
);
const data = await res.json();
return data.stopTimes || [];
Expand Down Expand Up @@ -108,7 +107,7 @@ const Departures: React.FC = () => {
}
};

const formatTime = (time: string) => moment.utc(time).local().format('DD/MM/YYYY HH:mm:ss');
//const formatTime = (time: string) => utc(time).local().format('DD/MM/YYYY HH:mm:ss');

return (
<Flex direction="column" alignItems="center" gap="size-200">
Expand Down Expand Up @@ -150,7 +149,7 @@ const Departures: React.FC = () => {
<Text>
<strong>Route:</strong> {departure.routeShortName} <br />
<strong>Headsign:</strong> {departure.headsign} <br />
<strong>Departure:</strong> {formatTime(departure.departure)}
<strong>Departure:</strong> {departure.departure}
</Text>
<Divider size="S" marginTop="size-150" />
</View>
Expand Down

0 comments on commit 2f3a6fa

Please sign in to comment.