-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
44 lines (42 loc) · 1.22 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as React from 'react';
import './style.css';
import _ from 'lodash';
import { Bar } from 'react-chartjs-2';
import RentedPerHour from './Components/RentedPerHour';
import AvgAgeByLocation from './Components/AvgAgeByLocation';
export type TripData = {
tripduration: number;
start_time: string;
stop_time: string;
start_station_id: number;
start_station_name: string;
// 'start station latitude': string;
start_station_longitude: string;
end_station_id: number;
end_station_name: string;
end_station_latitude: string;
end_station_longitude: string;
bike_id: number;
usertype: string;
'birth year': number;
gender: number;
};
export default function App() {
const [tripData, setTripData] = React.useState([]);
React.useEffect(() => {
const getTripData = async () => {
const res = await fetch(
'https://lo-interview.s3.us-west-2.amazonaws.com/trips.json'
);
const tripData: TripData[] = await res.json();
setTripData(tripData);
};
getTripData();
}, []);
return (
<div className={'dashboard'}>
<div>{<RentedPerHour tripData={tripData}></RentedPerHour>}</div>
<div>{<AvgAgeByLocation tripData={tripData}></AvgAgeByLocation>}</div>
</div>
);
}