From 86b9e970fcd7f3f0f80b3cd886f0472e5da47fdc Mon Sep 17 00:00:00 2001 From: Simo Partinen Date: Mon, 11 Nov 2024 09:15:08 +0200 Subject: [PATCH 01/11] chore: format --- app/component/itinerary/ItineraryDetails.js | 109 +++++++++++--------- 1 file changed, 61 insertions(+), 48 deletions(-) diff --git a/app/component/itinerary/ItineraryDetails.js b/app/component/itinerary/ItineraryDetails.js index 8adae18d57..115dab0cbe 100644 --- a/app/component/itinerary/ItineraryDetails.js +++ b/app/component/itinerary/ItineraryDetails.js @@ -83,7 +83,7 @@ class ItineraryDetails extends React.Component { this.context.match.params.hash !== streetHash.walk && this.context.match.params.hash !== streetHash.bike ); - }; + } getFutureText(startTime) { const refTime = Date.now(); @@ -96,7 +96,7 @@ class ItineraryDetails extends React.Component { }); } return getFormattedTimeDate(startTime, 'dd D.M.'); - }; + } getExtraProps(itinerary) { const compressedItinerary = { @@ -130,24 +130,36 @@ class ItineraryDetails extends React.Component { futureText, isMultiRow, }; - }; + } render() { - const { itinerary, currentLanguage, isMobile, bikeAndPublicItineraryCount } = this.props; + const { + itinerary, + currentLanguage, + isMobile, + bikeAndPublicItineraryCount, + } = this.props; const { config } = this.context; if (!itinerary?.legs[0]) { return null; } const fares = getFaresFromLegs(itinerary.legs, config); const extraProps = this.getExtraProps(itinerary); - const {biking, walking, driving, futureText, isMultiRow} = extraProps; + const { biking, walking, driving, futureText, isMultiRow } = extraProps; const legsWithRentalBike = compressLegs(itinerary.legs).filter(leg => legContainsRentalBike(leg), ); - const legswithBikePark = compressLegs(itinerary.legs).filter(leg => legContainsBikePark(leg)); - const legsWithScooter = compressLegs(itinerary.legs).some(leg => leg.mode === 'SCOOTER'); + const legswithBikePark = compressLegs(itinerary.legs).filter(leg => + legContainsBikePark(leg), + ); + const legsWithScooter = compressLegs(itinerary.legs).some( + leg => leg.mode === 'SCOOTER', + ); const containsBiking = biking.duration > 0 && biking.distance > 0; - const showBikeBoardingInformation = containsBiking && bikeAndPublicItineraryCount > 0 && legswithBikePark.length === 0; + const showBikeBoardingInformation = + containsBiking && + bikeAndPublicItineraryCount > 0 && + legswithBikePark.length === 0; const rentalBikeNetworks = new Set(); let showRentalBikeDurationWarning = false; if (legsWithRentalBike.length > 0) { @@ -183,7 +195,10 @@ class ItineraryDetails extends React.Component { const externalOperatorJourneys = legsWithScooter; - if (shouldShowFareInfo(config) && (fares.some(fare => fare.isUnknown) || externalOperatorJourneys) ) { + if ( + shouldShowFareInfo(config) && + (fares.some(fare => fare.isUnknown) || externalOperatorJourneys) + ) { const found = {}; itinerary.legs.forEach(leg => { if (config.modeDisclaimers?.[leg.mode] && !found[leg.mode]) { @@ -201,13 +216,10 @@ class ItineraryDetails extends React.Component { }); const info = config.callAgencyInfo?.[currentLanguage]; - if ( - info && - itinerary.legs.some(leg => isCallAgencyPickupType(leg)) - ) { + if (info && itinerary.legs.some(leg => isCallAgencyPickupType(leg))) { disclaimers.push( , ); @@ -238,10 +252,10 @@ class ItineraryDetails extends React.Component { number: itineraryIndex, }} /> - + {breakpoint => [ - breakpoint === 'large' && !this.props.hideTitle && ( + breakpoint === 'large' && !this.props.hideTitle && (
), - , showRentalBikeDurationWarning && ( @@ -283,28 +296,28 @@ class ItineraryDetails extends React.Component { shouldShowFareInfo(config) && (shouldShowFarePurchaseInfo(config, breakpoint, fares) ? ( ) : ( )), - this.props.setNavigation && ( - - ), + this.props.setNavigation && ( + + ), config.showCO2InItinerarySummary && !legsWithScooter && ( @@ -319,11 +332,11 @@ class ItineraryDetails extends React.Component { className={cx('itinerary-main', { 'bp-large': breakpoint === 'large', })} - key="legwrapper" + key="legwrapper" > {disclaimers} {config.showCO2InItinerarySummary && !legsWithScooter && (
)} -
+
, ]} @@ -447,14 +460,14 @@ const withRelay = createFragmentContainer( lat lon name - vehicleParking { + vehicleParking { name vehicleParkingId } vehicleRentalStation { rentalNetwork { - networkId - } + networkId + } availableVehicles { total } @@ -469,7 +482,7 @@ const withRelay = createFragmentContainer( lon rentalUris { android - ios + ios web } rentalNetwork { @@ -507,7 +520,7 @@ const withRelay = createFragmentContainer( lon stationId rentalNetwork { - networkId + networkId } availableVehicles { total @@ -542,13 +555,13 @@ const withRelay = createFragmentContainer( } } } - vehicleParking { - vehicleParkingId - name + vehicleParking { + vehicleParkingId + name } } intermediatePlaces { - arrival { + arrival { scheduledTime estimated { time From e0a93cbc6c64d6f406b4a703504f7847ec028fa2 Mon Sep 17 00:00:00 2001 From: Simo Partinen Date: Tue, 12 Nov 2024 23:02:57 +0200 Subject: [PATCH 02/11] chore: moved navigator itinerary storage to more appropriate place --- app/component/itinerary/ItineraryDetails.js | 1 + app/component/itinerary/ItineraryPage.js | 6 ----- app/component/itinerary/StartNavi.js | 26 +++++++++++++++++---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/component/itinerary/ItineraryDetails.js b/app/component/itinerary/ItineraryDetails.js index 115dab0cbe..4a3ed6e6b4 100644 --- a/app/component/itinerary/ItineraryDetails.js +++ b/app/component/itinerary/ItineraryDetails.js @@ -312,6 +312,7 @@ class ItineraryDetails extends React.Component { this.props.setNavigation && ( ), diff --git a/app/component/itinerary/ItineraryPage.js b/app/component/itinerary/ItineraryPage.js index 06ea3eef92..bd8c2ee491 100644 --- a/app/component/itinerary/ItineraryPage.js +++ b/app/component/itinerary/ItineraryPage.js @@ -17,7 +17,6 @@ import { getDialogState, getLatestNavigatorItinerary, setDialogState, - setLatestNavigatorItinerary, } from '../../store/localStorage'; import { addAnalyticsEvent } from '../../util/analyticsUtils'; import { getWeatherData } from '../../util/apiUtils'; @@ -650,11 +649,6 @@ export default function ItineraryPage(props, context) { setMapState({ center: undefined, zoom: undefined, bounds: undefined }); navigateMap(); clearLatestNavigatorItinerary(); - } else { - const { combinedEdges, selectedIndex } = getItinerarySelection(); - if (combinedEdges[selectedIndex]?.node) { - setLatestNavigatorItinerary(combinedEdges[selectedIndex]?.node); - } } setNaviMode(isEnabled); }; diff --git a/app/component/itinerary/StartNavi.js b/app/component/itinerary/StartNavi.js index f29a104a1c..52aae69d3e 100644 --- a/app/component/itinerary/StartNavi.js +++ b/app/component/itinerary/StartNavi.js @@ -1,18 +1,34 @@ +import { matchShape } from 'found'; import PropTypes from 'prop-types'; import React from 'react'; import { FormattedMessage, intlShape } from 'react-intl'; -import { configShape } from '../../util/shapes'; +import { setLatestNavigatorItinerary } from '../../store/localStorage'; +import { configShape, itineraryShape } from '../../util/shapes'; import Icon from '../Icon'; -const StartNavi = ({ setNavigation }, context) => { - const { config, intl } = context; +const StartNavi = ({ setNavigation, itinerary }, context) => { + const { config, intl, match } = context; const color = config.colors?.accessiblePrimary || config.colors?.primary || 'black'; + const handleClick = () => { + setNavigation(true); + setLatestNavigatorItinerary({ + itinerary, + params: { + from: match.params.from, + to: match.params.to, + arriveBy: match.location.query.arriveBy, + time: match.location.query.time, + index: match.params.hash, + }, + }); + }; + return (
-