From a9c432bddd6a500037141b69a0dd0ddfa55cb1d4 Mon Sep 17 00:00:00 2001 From: Daniel Heppner Date: Tue, 17 Sep 2024 17:12:47 -0700 Subject: [PATCH] change default to false --- lib/components/form/date-time-modal.tsx | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/components/form/date-time-modal.tsx b/lib/components/form/date-time-modal.tsx index f97450ec2..bf11a0806 100644 --- a/lib/components/form/date-time-modal.tsx +++ b/lib/components/form/date-time-modal.tsx @@ -25,6 +25,15 @@ type Props = { type DepartArriveValue = 'NOW' | 'DEPART' | 'ARRIVE' +const DepartArriveTypeMap: Record< + DepartArriveValue, + FilterType['sort']['type'] +> = { + ARRIVE: 'ARRIVALTIME', + DEPART: 'DEPARTURETIME', + NOW: 'DURATION' +} + function DateTimeModal(props: Props) { const { config, @@ -45,18 +54,13 @@ function DateTimeModal(props: Props) { const syncSortWithDepartArrive = config?.itinerary?.syncSortWithDepartArrive const setQueryParamMiddleware = useCallback( (params: any) => { - if (syncSortWithDepartArrive !== false) { - switch (params.departArrive) { - case 'NOW': - updateItineraryFilter({ sort: { ...sort, type: 'DURATION' } }) - break - case 'DEPART': - updateItineraryFilter({ sort: { ...sort, type: 'DEPARTURETIME' } }) - break - case 'ARRIVE': - updateItineraryFilter({ sort: { ...sort, type: 'ARRIVALTIME' } }) - break - } + if (syncSortWithDepartArrive) { + updateItineraryFilter({ + sort: { + ...sort, + type: DepartArriveTypeMap[params.departArrive as DepartArriveValue] + } + }) } setQueryParam(params) },