diff --git a/src/pages/components/OperatorSelector.tsx b/src/pages/components/OperatorSelector.tsx index c3f74559..4d9b7d27 100644 --- a/src/pages/components/OperatorSelector.tsx +++ b/src/pages/components/OperatorSelector.tsx @@ -34,7 +34,7 @@ const OperatorSelector = ({ disablePortal style={{ width: '100%' }} value={value} - onChange={(e, value) => setOperatorId(value ? value.id : '0')} + onChange={(e, value) => setOperatorId(value ? value.id : '')} id="operator-select" options={operators} renderInput={(params) => } diff --git a/src/pages/dashboard/ArrivalByTimeChart/ArrivalByTimeChart.tsx b/src/pages/dashboard/ArrivalByTimeChart/ArrivalByTimeChart.tsx index 2d23df4a..77c234f1 100644 --- a/src/pages/dashboard/ArrivalByTimeChart/ArrivalByTimeChart.tsx +++ b/src/pages/dashboard/ArrivalByTimeChart/ArrivalByTimeChart.tsx @@ -10,6 +10,7 @@ import { } from 'recharts' import './ArrivalByTimeChats.scss' +import { useMemo } from 'react' const arrayGroup = function (array: T[], f: (item: T) => string) { const groups: Record = {} @@ -25,6 +26,7 @@ const arrayGroup = function (array: T[], f: (item: T) => string) { export default function ArrivalByTimeChart({ data, + operatorId, }: { data: { id: string @@ -35,7 +37,12 @@ export default function ArrivalByTimeChart({ gtfs_route_date: string gtfs_route_hour: string }[] + operatorId: string }) { + data = useMemo( + () => data.filter((item) => !operatorId || item.id === operatorId), + [data, operatorId], + ) return (
{arrayGroup(data, (item) => item.id) diff --git a/src/pages/dashboard/DashboardPage.tsx b/src/pages/dashboard/DashboardPage.tsx index 338547d2..6f7c92f7 100644 --- a/src/pages/dashboard/DashboardPage.tsx +++ b/src/pages/dashboard/DashboardPage.tsx @@ -162,7 +162,10 @@ const DashboardPage = () => { {loadingGrap ? ( ) : ( - + )}