From ac8bc1ccc5642ce721f3b3b18bc880b8ecbeb5a2 Mon Sep 17 00:00:00 2001 From: Dvun Date: Tue, 12 Dec 2023 10:00:29 +0200 Subject: [PATCH] fix: update propTypes and defaultProps --- app/component/Availability.js | 9 ++++++-- app/component/DepartureRow.js | 3 ++- .../StopsNearYouFavouritesContainer.js | 6 ++--- app/component/VehicleStopNearYou.js | 23 ++++++++++++++++--- app/component/map/StopsNearYouMap.js | 11 ++++++--- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/app/component/Availability.js b/app/component/Availability.js index 673e298633..70aa4eaabe 100644 --- a/app/component/Availability.js +++ b/app/component/Availability.js @@ -63,10 +63,15 @@ Availability.displayName = 'Availability'; Availability.propTypes = { available: PropTypes.number.isRequired, total: PropTypes.number.isRequired, - fewAvailableCount: PropTypes.number.isRequired, - fewerAvailableCount: PropTypes.number.isRequired, + fewAvailableCount: PropTypes.number, + fewerAvailableCount: PropTypes.number, text: PropTypes.node.isRequired, showStatusBar: PropTypes.bool.isRequired, }; +Availability.defaultProps = { + fewAvailableCount: undefined, + fewerAvailableCount: undefined, +}; + export default Availability; diff --git a/app/component/DepartureRow.js b/app/component/DepartureRow.js index e6dda66c34..54b29ebabc 100644 --- a/app/component/DepartureRow.js +++ b/app/component/DepartureRow.js @@ -259,7 +259,8 @@ DepartureRow.propTypes = { showPlatformCode: PropTypes.bool, canceled: PropTypes.bool, className: PropTypes.string, - onCapacityClick: PropTypes.func.isRequired, + // eslint-disable-next-line react/require-default-props + onCapacityClick: PropTypes.func, }; DepartureRow.contextTypes = { diff --git a/app/component/StopsNearYouFavouritesContainer.js b/app/component/StopsNearYouFavouritesContainer.js index b25250652b..a21f6402c9 100644 --- a/app/component/StopsNearYouFavouritesContainer.js +++ b/app/component/StopsNearYouFavouritesContainer.js @@ -79,9 +79,9 @@ StopsNearYouFavouritesContainer.propTypes = { stations: PropTypes.array, vehicleStations: PropTypes.array, searchPosition: dtLocationShape, - relay: PropTypes.shape({ - refetch: PropTypes.func.isRequired, - }).isRequired, + // relay: PropTypes.shape({ + // refetch: PropTypes.func.isRequired, + // }).isRequired, }; const refetchContainer = createFragmentContainer( diff --git a/app/component/VehicleStopNearYou.js b/app/component/VehicleStopNearYou.js index 98309cba65..afe44f719f 100644 --- a/app/component/VehicleStopNearYou.js +++ b/app/component/VehicleStopNearYou.js @@ -64,12 +64,29 @@ const VehicleStopNearYou = ({ stop, relay, currentTime, currentMode }) => { ); }; VehicleStopNearYou.propTypes = { - stop: PropTypes.object.isRequired, - currentTime: PropTypes.number.isRequired, - currentMode: PropTypes.string.isRequired, + stop: PropTypes.shape({ + capacity: PropTypes.number, + distance: PropTypes.number, + lat: PropTypes.number, + lon: PropTypes.number, + name: PropTypes.string, + network: PropTypes.string, + operative: PropTypes.bool, + spacesAvailable: PropTypes.number, + stationId: PropTypes.string, + type: PropTypes.string, + vehiclesAvailable: PropTypes.number, + }).isRequired, + currentTime: PropTypes.number, + currentMode: PropTypes.string, relay: PropTypes.any, }; +VehicleStopNearYou.defaultProps = { + currentTime: undefined, + currentMode: undefined, +}; + const containerComponent = createRefetchContainer( VehicleStopNearYou, { diff --git a/app/component/map/StopsNearYouMap.js b/app/component/map/StopsNearYouMap.js index bcdd174f26..851360e641 100644 --- a/app/component/map/StopsNearYouMap.js +++ b/app/component/map/StopsNearYouMap.js @@ -488,9 +488,13 @@ function StopsNearYouMap( StopsNearYouMap.propTypes = { currentTime: PropTypes.number.isRequired, - stopsNearYou: PropTypes.object, + stopsNearYou: PropTypes.shape({ + nearest: PropTypes.shape({ + edges: PropTypes.arrayOf(PropTypes.object).isRequired, + }).isRequired, + }), prioritizedStopsNearYou: PropTypes.array, - favouriteIds: PropTypes.objectOf(PropTypes.string.isRequired), + favouriteIds: PropTypes.object, mapLayers: PropTypes.object.isRequired, mapLayerOptions: mapLayerOptionsShape, position: dtLocationShape.isRequired, @@ -510,9 +514,10 @@ StopsNearYouMap.propTypes = { }; StopsNearYouMap.defaultProps = { + stopsNearYou: null, showWalkRoute: false, loading: false, - favouriteIds: {}, + favouriteIds: undefined, }; StopsNearYouMap.contextTypes = {