Skip to content

Commit 1d03b14

Browse files
committed
Add support for change history date in defaultSerializer
Previously this caused error: - A non-serializable value was detected in the state
1 parent f1cafb3 commit 1d03b14

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

ui/src/graphql/route.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
GetScheduledStopsOnRouteQuery,
77
InsertLineOneMutation,
88
RouteLine,
9+
RouteLineChangeHistory,
910
RouteRoute,
1011
RouteWithJourneyPatternStopsFragment,
1112
ServicePatternScheduledStopPoint,
@@ -358,3 +359,10 @@ export const isLine = (
358359
// eslint-disable-next-line no-underscore-dangle
359360
return isGqlEntity(input) && input.__typename === 'route_line';
360361
};
362+
363+
export const isChangeHistory = (
364+
input: unknown,
365+
): input is Pick<RouteLineChangeHistory, '__typename'> => {
366+
// eslint-disable-next-line no-underscore-dangle
367+
return isGqlEntity(input) && input.__typename === 'route_line_change_history';
368+
};

ui/src/redux/mappers/storeType.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import isArray from 'lodash/isArray';
22
import { DateTime } from 'luxon';
3-
import { isLine, isRoute, isStop, isValidBetween } from '../../graphql';
3+
import {
4+
isChangeHistory,
5+
isLine,
6+
isRoute,
7+
isStop,
8+
isValidBetween,
9+
} from '../../graphql';
410
import { isDateLike, parseDate } from '../../time';
511
import {
612
PlainObject,
@@ -49,8 +55,15 @@ const defaultSerializer: SerializerFunction = <
4955
(isStop(parentObject) ||
5056
isRoute(parentObject) ||
5157
isLine(parentObject) ||
52-
isValidBetween(parentObject)) &&
53-
['validity_start', 'validity_end', 'fromDate', 'toDate'].includes(key) &&
58+
isValidBetween(parentObject) ||
59+
isChangeHistory(parentObject)) &&
60+
[
61+
'validity_start',
62+
'validity_end',
63+
'fromDate',
64+
'toDate',
65+
'changed',
66+
].includes(key) &&
5467
DateTime.isDateTime(value)
5568
) {
5669
return value.toISO();

0 commit comments

Comments
 (0)