diff --git a/lib/components/form/call-taker/date-time-picker.tsx b/lib/components/form/call-taker/date-time-picker.tsx index 47ae53ba7..07df1b808 100644 --- a/lib/components/form/call-taker/date-time-picker.tsx +++ b/lib/components/form/call-taker/date-time-picker.tsx @@ -14,7 +14,11 @@ import React, { } from 'react' import { AppReduxState, FilterType, SortType } from '../../../util/state-types' -import { DepartArriveTypeMap, DepartArriveValue } from '../date-time-modal' +import { + DepartArriveDefaultSortDirectionMap, + DepartArriveTypeMap, + DepartArriveValue +} from '../date-time-modal' import { updateItineraryFilter } from '../../../actions/narrative' const { getCurrentDate, OTP_API_DATE_FORMAT, OTP_API_TIME_FORMAT } = @@ -220,6 +224,9 @@ const DateTimeOptions = ({ importedUpdateItineraryFilter({ sort: { ...sort, + direction: + DepartArriveDefaultSortDirectionMap[departArrive] || + sort.direction, type: DepartArriveTypeMap[newValue] } }) diff --git a/lib/components/form/date-time-modal.tsx b/lib/components/form/date-time-modal.tsx index bd7082eef..8bbe2a2a2 100644 --- a/lib/components/form/date-time-modal.tsx +++ b/lib/components/form/date-time-modal.tsx @@ -32,6 +32,15 @@ export const DepartArriveTypeMap: Record< NOW: 'DURATION' } +export const DepartArriveDefaultSortDirectionMap: Record< + DepartArriveValue, + FilterType['sort']['direction'] +> = { + ARRIVE: 'ASC', + DEPART: 'DESC', + NOW: 'DESC' +} + function DateTimeModal({ config, date, @@ -57,6 +66,10 @@ function DateTimeModal({ updateItineraryFilter({ sort: { ...sort, + direction: + DepartArriveDefaultSortDirectionMap[ + params.departArrive as DepartArriveValue + ] || sort.direction, type: DepartArriveTypeMap[params.departArrive as DepartArriveValue] } })