From 826fd5d55645fd42bc4c245bf042eb69dba7772f Mon Sep 17 00:00:00 2001 From: Janne Antikainen Date: Mon, 11 Nov 2024 09:26:42 +0200 Subject: [PATCH 01/11] in vehicle card --- app/component/itinerary/NaviCard.js | 12 +++- app/component/itinerary/NaviCardContainer.js | 15 +++-- app/component/itinerary/NaviCardExtension.js | 42 ++++++++++++- app/component/itinerary/NaviInstructions.js | 44 ++++++++++++- app/component/itinerary/navigator.scss | 65 +++++++++++++++----- app/translations.js | 15 +++++ 6 files changed, 170 insertions(+), 23 deletions(-) diff --git a/app/component/itinerary/NaviCard.js b/app/component/itinerary/NaviCard.js index e7e89f48e3..4488794e7a 100644 --- a/app/component/itinerary/NaviCard.js +++ b/app/component/itinerary/NaviCard.js @@ -12,13 +12,19 @@ const iconMap = { SCOOTER: 'icon-icon_scooter_rider', WALK: 'icon-icon_walk', WAIT: 'icon-icon_navigation_wait', + BUS: 'icon-icon_bus', + RAIL: 'icon-icon_rail', + SUBWAY: 'icon-icon_subway', + TRAM: 'icon-icon_tram', + FERRY: 'icon-icon_ferry', }; export default function NaviCard({ leg, nextLeg, legType, cardExpanded }) { const iconName = legType === 'wait' ? iconMap.WAIT : iconMap[leg.mode]; let instructions = `navileg-${leg.mode.toLowerCase()}`; - - if (isRental(leg, nextLeg)) { + if (legType === 'in-vehicle') { + instructions = `navileg-in-vehicle`; + } else if (isRental(leg, nextLeg)) { if (leg.mode === 'WALK' && nextLeg?.mode === 'SCOOTER') { instructions = `navileg-rent-scooter`; } else { @@ -44,7 +50,7 @@ export default function NaviCard({ leg, nextLeg, legType, cardExpanded }) { - {cardExpanded && } + {cardExpanded && } ); } diff --git a/app/component/itinerary/NaviCardContainer.js b/app/component/itinerary/NaviCardContainer.js index 9d65cf630b..28cc821f5b 100644 --- a/app/component/itinerary/NaviCardContainer.js +++ b/app/component/itinerary/NaviCardContainer.js @@ -151,10 +151,10 @@ function NaviCardContainer( /> ); } else if (currentLeg) { + const nextLeg = realTimeLegs.find(leg => { + return legTime(leg.start) > legTime(currentLeg.start); + }); if (!currentLeg.transitLeg) { - const nextLeg = realTimeLegs.find(leg => { - return legTime(leg.start) > legTime(currentLeg.start); - }); let legType; if (destCountRef.current >= TIME_AT_DESTINATION) { legType = 'wait'; @@ -170,7 +170,14 @@ function NaviCardContainer( /> ); } else { - naviTopContent = `Tracking ${currentLeg?.mode} leg`; + naviTopContent = ( + + ); } } else if (time > legTime(last.end)) { naviTopContent = ; diff --git a/app/component/itinerary/NaviCardExtension.js b/app/component/itinerary/NaviCardExtension.js index f21c0466de..8c50a8f305 100644 --- a/app/component/itinerary/NaviCardExtension.js +++ b/app/component/itinerary/NaviCardExtension.js @@ -1,4 +1,7 @@ import React from 'react'; +import cx from 'classnames'; +import PropTypes from 'prop-types'; +import { FormattedMessage } from 'react-intl'; import Icon from '../Icon'; import StopCode from '../StopCode'; import PlatformNumber from '../PlatformNumber'; @@ -6,8 +9,9 @@ import { getZoneLabel } from '../../util/legUtils'; import ZoneIcon from '../ZoneIcon'; import { legShape, configShape } from '../../util/shapes'; import { getDestinationProperties } from './NaviUtils'; +import RouteNumberContainer from '../RouteNumberContainer'; -const NaviCardExtension = ({ leg }, { config }) => { +const NaviCardExtension = ({ legType, leg }, { config }) => { const { stop, name } = leg.to; const { code, platformCode, zoneId, vehicleMode } = stop || {}; const [place, address] = name?.split(/, (.+)/) || []; @@ -21,6 +25,37 @@ const NaviCardExtension = ({ leg }, { config }) => { destination.className = 'place'; destination.name = place; } + if (legType === 'in-vehicle') { + // Todo routenumbercontainer on taas hanurista, tyylittelyt ja nimet kuntoon. Rakenne on ok mutta pitää viilata + // Lasketaan interMediateplaces taulukosta arrival ajan ja nykyhetken perusteella. + // Lähijuna = juna ? Pitääköhän tuokin tehdä.. + // ei oo kommitointivalmis, pitää muutella muuttujie ja classnameja ja kattoa voisko navicardontainerin järkeistää tässä vaiheessa. + const nrStopsRemaining = 0; + return ( +
+
+
+ +
{leg.to.name}
+
+
+ +
+
+ ); + } + return (
@@ -59,6 +94,11 @@ const NaviCardExtension = ({ leg }, { config }) => { NaviCardExtension.propTypes = { leg: legShape.isRequired, + legType: PropTypes.string, +}; + +NaviCardExtension.defaultProps = { + legType: '', }; NaviCardExtension.contextTypes = { diff --git a/app/component/itinerary/NaviInstructions.js b/app/component/itinerary/NaviInstructions.js index a5becf30ce..cbc0679465 100644 --- a/app/component/itinerary/NaviInstructions.js +++ b/app/component/itinerary/NaviInstructions.js @@ -3,7 +3,7 @@ import { FormattedMessage, intlShape } from 'react-intl'; import PropTypes from 'prop-types'; import cx from 'classnames'; import { legShape, configShape } from '../../util/shapes'; -import { legDestination } from '../../util/legUtils'; +import { legDestination, legTimeStr, legTime } from '../../util/legUtils'; import RouteNumber from '../RouteNumber'; import { displayDistance } from '../../util/geo-utils'; import { durationToString } from '../../util/timeUtils'; @@ -73,6 +73,48 @@ export default function NaviInstructions( ); } + + if (legType === 'in-vehicle') { + const t = legTime(leg.end); + const stopOrStation = leg.to.stop.parentStation + ? intl.formatMessage({ id: 'navileg-from-station' }) + : intl.formatMessage({ id: 'navileg-from-stop' }); + const rt = leg.realtimeState !== 'SCHEDULED'; + const localizedMode = intl.formatMessage({ + id: `${leg.mode.toLowerCase()}`, + defaultMessage: `${leg.mode}`, + }); + const remainingDuration = Math.ceil((t - Date.now()) / 60000); // ms to minutes + const values = { + stopOrStation, + stop: leg.to.stop.name, + duration: ( + {remainingDuration} + ), + legTime: ( + {legTimeStr(leg.end)} + ), + }; + + return ( + <> +
+ +
+
+ +
+ + ); + } return null; } diff --git a/app/component/itinerary/navigator.scss b/app/component/itinerary/navigator.scss index f2defb6ce5..5839151cbe 100644 --- a/app/component/itinerary/navigator.scss +++ b/app/component/itinerary/navigator.scss @@ -103,6 +103,14 @@ display: flex; } + .vehicle-leg { + display: flex; + margin-top: var(--space-xs); + font-weight: $font-weight-book; + width: 80%; + text-align: left; + } + .wait-leg { display: flex; align-items: center; @@ -120,20 +128,6 @@ height: 25px; width: 25px; } - - .route-number { - min-width: 55px; - - .vcenter-children { - .vehicle-number { - color: white; - font-size: $font-size-large; - margin-top: 4px; - } - - display: flex; - } - } } } @@ -159,6 +153,49 @@ margin-left: 50px; } + .remaining { + display: flex; + margin-left: 48px; + font-weight: $font-weight-book; + } + + .secondary-vehicle { + display: flex; + flex-direction: row; + font-weight: $font-weight-book; + margin-left: 48px; + margin-top: var(--space-xs); + margin-bottom: var(--space-s); + text-align: left; + + .route-number { + min-width: 55px; + + .vcenter-children { + .vehicle-number { + color: white; + font-size: $font-size-large; + margin-top: 4px; + } + + display: flex; + } + } + + .line { + text-align: center; + + .icon { + font-size: 24px; + } + } + + .info { + display: flex; + flex-direction: column; + } + } + .secondary-content { display: flex; margin-left: var(--space-xxl); diff --git a/app/translations.js b/app/translations.js index 04947c9526..31611480c7 100644 --- a/app/translations.js +++ b/app/translations.js @@ -1314,6 +1314,11 @@ const translations = { 'navigation-wait-mode': 'Odota {mode}a', 'navileg-bicycle': 'Cycle to', 'navileg-car': 'Drive to', + 'navileg-from-station': 'asemalla', + 'navileg-from-stop': 'pysäkillä', + 'navileg-in-vehicle': 'TODO_{mode}matka', + 'navileg-leave-at': + 'Jää pois {stopOrStation} {stop} {duration} min päästä klo {legTime}', 'navileg-mode-citybike': 'Kaupunkipyöriä on asemalla {available} kpl', 'navileg-mode-realtime': '{mode} on aikataulussa', 'navileg-mode-schedule': 'The {mode} is on schedule', @@ -2564,6 +2569,11 @@ const translations = { 'navigation-wait-mode': 'Odota {mode}a', 'navileg-bicycle': 'Pyöräile', 'navileg-car': 'Aja', + 'navileg-from-station': 'asemalla', + 'navileg-from-stop': 'pysäkillä', + 'navileg-in-vehicle': '{mode}matka', + 'navileg-leave-at': + 'Jää pois {stopOrStation} {stop} {duration} min päästä klo {legTime}', 'navileg-mode-citybike': 'Kaupunkipyöriä on asemalla {available} kpl', 'navileg-mode-realtime': '{mode} on aikataulussa', 'navileg-mode-schedule': 'Reaaliaikaista tietoa ei ole saatavilla', @@ -5465,6 +5475,11 @@ const translations = { 'navigation-wait-mode': 'Odota {mode}a', 'navileg-bicycle': 'Cycla till', 'navileg-car': 'Kör till', + 'navileg-from-station': 'TODO_asemalla', + 'navileg-from-stop': 'TODO_pysäkillä', + 'navileg-in-vehicle': 'TODO_{mode}matka', + 'navileg-leave-at': + 'TODO_Jää pois {stopOrStation} {stop} {duration} min päästä klo {legTime}', 'navileg-mode-citybike': 'Kaupunkipyöriä on asemalla {available} kpl', 'navileg-mode-realtime': '{mode} on aikataulussa', 'navileg-mode-schedule': 'Reaaliaikaista tietoa ei ole saatavilla', From b682c01e8213ebf16bc755fbe1d743c6fc9ce9fb Mon Sep 17 00:00:00 2001 From: Janne Antikainen Date: Mon, 11 Nov 2024 15:21:41 +0200 Subject: [PATCH 02/11] vehicle card now counts remaining stops Styling of the component --- app/component/itinerary/NaviCard.js | 6 ++-- app/component/itinerary/NaviCardContainer.js | 29 ++++++++------------ app/component/itinerary/NaviCardExtension.js | 23 +++++++++++----- app/component/itinerary/NaviInstructions.js | 2 +- app/component/itinerary/NaviStack.js | 14 ++++++++-- app/component/itinerary/PlanConnection.js | 8 ++++++ app/component/itinerary/navigator.scss | 27 ++++++++++++++---- app/translations.js | 16 +++++++++-- 8 files changed, 85 insertions(+), 40 deletions(-) diff --git a/app/component/itinerary/NaviCard.js b/app/component/itinerary/NaviCard.js index 4488794e7a..5b6e237f5e 100644 --- a/app/component/itinerary/NaviCard.js +++ b/app/component/itinerary/NaviCard.js @@ -22,8 +22,8 @@ const iconMap = { export default function NaviCard({ leg, nextLeg, legType, cardExpanded }) { const iconName = legType === 'wait' ? iconMap.WAIT : iconMap[leg.mode]; let instructions = `navileg-${leg.mode.toLowerCase()}`; - if (legType === 'in-vehicle') { - instructions = `navileg-in-vehicle`; + if (legType === 'in-transit') { + instructions = `navileg-in-transit`; } else if (isRental(leg, nextLeg)) { if (leg.mode === 'WALK' && nextLeg?.mode === 'SCOOTER') { instructions = `navileg-rent-scooter`; @@ -35,7 +35,7 @@ export default function NaviCard({ leg, nextLeg, legType, cardExpanded }) {
-
+
legTime(currentLeg.start); }); if (!currentLeg.transitLeg) { - let legType; if (destCountRef.current >= TIME_AT_DESTINATION) { legType = 'wait'; } else { legType = 'move'; } - naviTopContent = ( - - ); } else { - naviTopContent = ( - - ); + legType = 'in-transit'; } + naviTopContent = ( + + ); } else if (time > legTime(last.end)) { naviTopContent = ; } else { @@ -202,6 +194,7 @@ function NaviCardContainer( messages={activeMessages} cardExpanded={cardExpanded} handleRemove={handleRemove} + legType={legType} /> )} diff --git a/app/component/itinerary/NaviCardExtension.js b/app/component/itinerary/NaviCardExtension.js index 8c50a8f305..f1593f10d4 100644 --- a/app/component/itinerary/NaviCardExtension.js +++ b/app/component/itinerary/NaviCardExtension.js @@ -25,12 +25,21 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { destination.className = 'place'; destination.name = place; } - if (legType === 'in-vehicle') { - // Todo routenumbercontainer on taas hanurista, tyylittelyt ja nimet kuntoon. Rakenne on ok mutta pitää viilata - // Lasketaan interMediateplaces taulukosta arrival ajan ja nykyhetken perusteella. - // Lähijuna = juna ? Pitääköhän tuokin tehdä.. - // ei oo kommitointivalmis, pitää muutella muuttujie ja classnameja ja kattoa voisko navicardontainerin järkeistää tässä vaiheessa. - const nrStopsRemaining = 0; + // todo translationID ei toimi + if (legType === 'in-transit') { + const arrivalTimes = + leg.intermediatePlaces?.map( + p => + new Date(p.arrival.estimated?.time) || + new Date(p.arrival.scheduledTime), + ) || []; + + const now = new Date(); + const idx = arrivalTimes.findIndex(d => d.getTime() > now.getTime()); + const count = arrivalTimes.length - idx; + const nrStopsRemaining = {count}; + const translationId = + count === 1 ? 'navileg-one-stop-remaining' : 'navileg-stops-remaining'; return (
@@ -47,7 +56,7 @@ const NaviCardExtension = ({ legType, leg }, { config }) => {
diff --git a/app/component/itinerary/NaviInstructions.js b/app/component/itinerary/NaviInstructions.js index cbc0679465..1c27ba47b7 100644 --- a/app/component/itinerary/NaviInstructions.js +++ b/app/component/itinerary/NaviInstructions.js @@ -74,7 +74,7 @@ export default function NaviInstructions( ); } - if (legType === 'in-vehicle') { + if (legType === 'in-transit') { const t = legTime(leg.end); const stopOrStation = leg.to.stop.parentStation ? intl.formatMessage({ id: 'navileg-from-station' }) diff --git a/app/component/itinerary/NaviStack.js b/app/component/itinerary/NaviStack.js index eb08da4298..43b2f02b32 100644 --- a/app/component/itinerary/NaviStack.js +++ b/app/component/itinerary/NaviStack.js @@ -3,9 +3,17 @@ import PropTypes from 'prop-types'; import cx from 'classnames'; import NaviMessage from './NaviMessage'; -const NaviStack = ({ messages, handleRemove, cardExpanded }) => { +const NaviStack = ({ messages, handleRemove, cardExpanded, legType }) => { return ( -
+
{messages.map((notification, index) => ( Date: Tue, 12 Nov 2024 08:28:39 +0200 Subject: [PATCH 03/11] show how many stops are before your stop style tweaks --- app/component/itinerary/NaviCardExtension.js | 22 ++++++++++---------- app/component/itinerary/navigator.scss | 19 ++++++++++------- app/translations.js | 16 ++++++-------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/app/component/itinerary/NaviCardExtension.js b/app/component/itinerary/NaviCardExtension.js index f1593f10d4..79305b5f4a 100644 --- a/app/component/itinerary/NaviCardExtension.js +++ b/app/component/itinerary/NaviCardExtension.js @@ -25,7 +25,7 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { destination.className = 'place'; destination.name = place; } - // todo translationID ei toimi + if (legType === 'in-transit') { const arrivalTimes = leg.intermediatePlaces?.map( @@ -37,13 +37,13 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { const now = new Date(); const idx = arrivalTimes.findIndex(d => d.getTime() > now.getTime()); const count = arrivalTimes.length - idx; - const nrStopsRemaining = {count}; + const stopCount = {count}; const translationId = count === 1 ? 'navileg-one-stop-remaining' : 'navileg-stops-remaining'; return ( -
-
-
+
+
+
{ vertical withBar /> -
{leg.to.name}
+
{leg.to.name}
-
+
@@ -66,9 +66,9 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { } return ( -
-
-
+
+
+
Date: Tue, 12 Nov 2024 08:41:28 +0200 Subject: [PATCH 04/11] navistack top value based on card sizes --- app/component/itinerary/NaviStack.js | 20 +++++++++++--------- app/component/itinerary/navigator.scss | 4 ++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/component/itinerary/NaviStack.js b/app/component/itinerary/NaviStack.js index 43b2f02b32..819a7f0f3f 100644 --- a/app/component/itinerary/NaviStack.js +++ b/app/component/itinerary/NaviStack.js @@ -4,16 +4,18 @@ import cx from 'classnames'; import NaviMessage from './NaviMessage'; const NaviStack = ({ messages, handleRemove, cardExpanded, legType }) => { + // Card has 4 sizes: first leg collapsed, expanded + // and in transit collapsed, expanded. + let classPostfix = ''; + if (legType === 'in-transit' && cardExpanded) { + classPostfix = 'expand-transit'; + } else if (legType === 'in-transit') { + classPostfix = 'in-transit'; + } else if (cardExpanded) { + classPostfix = 'expanded'; + } return ( -
+
{messages.map((notification, index) => ( Date: Tue, 12 Nov 2024 08:52:44 +0200 Subject: [PATCH 05/11] exlude the last stop where user is supposed to get off --- app/component/itinerary/NaviCardExtension.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/component/itinerary/NaviCardExtension.js b/app/component/itinerary/NaviCardExtension.js index 79305b5f4a..015382c207 100644 --- a/app/component/itinerary/NaviCardExtension.js +++ b/app/component/itinerary/NaviCardExtension.js @@ -28,7 +28,7 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { if (legType === 'in-transit') { const arrivalTimes = - leg.intermediatePlaces?.map( + leg.intermediatePlaces.map( p => new Date(p.arrival.estimated?.time) || new Date(p.arrival.scheduledTime), @@ -36,7 +36,9 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { const now = new Date(); const idx = arrivalTimes.findIndex(d => d.getTime() > now.getTime()); - const count = arrivalTimes.length - idx; + // Count the number of stops remaining, excluding the last one where + // the user is supposed to get off. + const count = arrivalTimes.length - idx - 1; const stopCount = {count}; const translationId = count === 1 ? 'navileg-one-stop-remaining' : 'navileg-stops-remaining'; From 56109e0f0d5f223d01f011f5f4ab3b5e6150c41b Mon Sep 17 00:00:00 2001 From: Janne Antikainen Date: Tue, 12 Nov 2024 10:17:12 +0200 Subject: [PATCH 06/11] refactor the calculation of stops --- app/component/itinerary/NaviCardExtension.js | 23 ++++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/component/itinerary/NaviCardExtension.js b/app/component/itinerary/NaviCardExtension.js index 015382c207..fefd6322cb 100644 --- a/app/component/itinerary/NaviCardExtension.js +++ b/app/component/itinerary/NaviCardExtension.js @@ -27,19 +27,18 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { } if (legType === 'in-transit') { - const arrivalTimes = - leg.intermediatePlaces.map( + const { intermediatePlaces } = leg; + const now = new Date(); + const idx = + intermediatePlaces.findIndex( p => - new Date(p.arrival.estimated?.time) || - new Date(p.arrival.scheduledTime), - ) || []; + new Date( + p.arrival.estimated?.time || p.arrival.scheduledTime, + ).getTime() > now.getTime(), + ) ?? -1; - const now = new Date(); - const idx = arrivalTimes.findIndex(d => d.getTime() > now.getTime()); - // Count the number of stops remaining, excluding the last one where - // the user is supposed to get off. - const count = arrivalTimes.length - idx - 1; - const stopCount = {count}; + const count = idx > -1 ? intermediatePlaces.length - idx : 0; + const stopCountElement = {count}; const translationId = count === 1 ? 'navileg-one-stop-remaining' : 'navileg-stops-remaining'; return ( @@ -59,7 +58,7 @@ const NaviCardExtension = ({ legType, leg }, { config }) => {
From 5ea27d797c965a54f7b28fcd21eb3c1196b909c0 Mon Sep 17 00:00:00 2001 From: Janne Antikainen Date: Tue, 12 Nov 2024 10:34:46 +0200 Subject: [PATCH 07/11] small tweaks --- app/component/itinerary/NaviCard.js | 2 +- app/component/itinerary/NaviInstructions.js | 2 +- app/component/itinerary/navigator.scss | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/component/itinerary/NaviCard.js b/app/component/itinerary/NaviCard.js index 5b6e237f5e..e0972d3852 100644 --- a/app/component/itinerary/NaviCard.js +++ b/app/component/itinerary/NaviCard.js @@ -34,7 +34,7 @@ export default function NaviCard({ leg, nextLeg, legType, cardExpanded }) { return (
- +
Date: Thu, 14 Nov 2024 08:58:07 +0200 Subject: [PATCH 08/11] fixes suggested in PR --- app/component/itinerary/NaviCard.js | 8 ++++--- app/component/itinerary/NaviCardContainer.js | 21 ++++++++++++++----- app/component/itinerary/NaviCardExtension.js | 22 ++++++++------------ app/component/itinerary/NaviInstructions.js | 9 ++++---- app/component/itinerary/NaviStack.js | 18 +++------------- app/component/itinerary/NaviUtils.js | 6 ++++++ app/component/itinerary/navigator.scss | 2 +- 7 files changed, 45 insertions(+), 41 deletions(-) diff --git a/app/component/itinerary/NaviCard.js b/app/component/itinerary/NaviCard.js index e0972d3852..2f2eee82f3 100644 --- a/app/component/itinerary/NaviCard.js +++ b/app/component/itinerary/NaviCard.js @@ -5,6 +5,7 @@ import Icon from '../Icon'; import { isRental } from '../../util/legUtils'; import NaviInstructions from './NaviInstructions'; import NaviCardExtension from './NaviCardExtension'; +import { LEGTYPE } from './NaviUtils'; const iconMap = { BICYCLE: 'icon-icon_cyclist', @@ -20,9 +21,9 @@ const iconMap = { }; export default function NaviCard({ leg, nextLeg, legType, cardExpanded }) { - const iconName = legType === 'wait' ? iconMap.WAIT : iconMap[leg.mode]; + const iconName = legType === LEGTYPE.WAIT ? iconMap.WAIT : iconMap[leg.mode]; let instructions = `navileg-${leg.mode.toLowerCase()}`; - if (legType === 'in-transit') { + if (legType === LEGTYPE.TRANSIT) { instructions = `navileg-in-transit`; } else if (isRental(leg, nextLeg)) { if (leg.mode === 'WALK' && nextLeg?.mode === 'SCOOTER') { @@ -57,10 +58,11 @@ export default function NaviCard({ leg, nextLeg, legType, cardExpanded }) { NaviCard.propTypes = { leg: legShape.isRequired, - nextLeg: legShape.isRequired, + nextLeg: legShape, legType: PropTypes.string.isRequired, cardExpanded: PropTypes.bool, }; NaviCard.defaultProps = { cardExpanded: false, + nextLeg: undefined, }; diff --git a/app/component/itinerary/NaviCardContainer.js b/app/component/itinerary/NaviCardContainer.js index 78807e2806..16741ef8b2 100644 --- a/app/component/itinerary/NaviCardContainer.js +++ b/app/component/itinerary/NaviCardContainer.js @@ -10,6 +10,7 @@ import { getItineraryAlerts, getTransitLegState, getAdditionalMessages, + LEGTYPE, } from './NaviUtils'; const DESTINATION_RADIUS = 20; // meters @@ -156,12 +157,12 @@ function NaviCardContainer( }); if (!currentLeg.transitLeg) { if (destCountRef.current >= TIME_AT_DESTINATION) { - legType = 'wait'; + legType = LEGTYPE.WAIT; } else { - legType = 'move'; + legType = LEGTYPE.MOVE; } } else { - legType = 'in-transit'; + legType = LEGTYPE.TRANSIT; } naviTopContent = ( ; } + + // Card has 4 sizes: first leg collapsed, expanded + // and in transit collapsed, expanded. + let classPostfix = ''; + if (legType === LEGTYPE.TRANSIT && cardExpanded) { + classPostfix = 'expand-transit'; + } else if (legType === LEGTYPE.TRANSIT) { + classPostfix = 'transit'; + } else if (cardExpanded) { + classPostfix = 'expanded'; + } const handleRemove = index => { setActiveMessages(activeMessages.filter((_, i) => i !== index)); }; @@ -192,9 +204,8 @@ function NaviCardContainer( {activeMessages.length > 0 && ( )} diff --git a/app/component/itinerary/NaviCardExtension.js b/app/component/itinerary/NaviCardExtension.js index fefd6322cb..174a20b09f 100644 --- a/app/component/itinerary/NaviCardExtension.js +++ b/app/component/itinerary/NaviCardExtension.js @@ -5,10 +5,11 @@ import { FormattedMessage } from 'react-intl'; import Icon from '../Icon'; import StopCode from '../StopCode'; import PlatformNumber from '../PlatformNumber'; -import { getZoneLabel } from '../../util/legUtils'; +import { getZoneLabel, legTime } from '../../util/legUtils'; import ZoneIcon from '../ZoneIcon'; import { legShape, configShape } from '../../util/shapes'; -import { getDestinationProperties } from './NaviUtils'; +import { getDestinationProperties, LEGTYPE } from './NaviUtils'; + import RouteNumberContainer from '../RouteNumberContainer'; const NaviCardExtension = ({ legType, leg }, { config }) => { @@ -26,19 +27,14 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { destination.name = place; } - if (legType === 'in-transit') { + if (legType === LEGTYPE.TRANSIT) { const { intermediatePlaces } = leg; - const now = new Date(); - const idx = - intermediatePlaces.findIndex( - p => - new Date( - p.arrival.estimated?.time || p.arrival.scheduledTime, - ).getTime() > now.getTime(), - ) ?? -1; + const idx = intermediatePlaces.findIndex( + p => legTime(p.arrival) > Date.now(), + ); const count = idx > -1 ? intermediatePlaces.length - idx : 0; - const stopCountElement = {count}; + const stopCount = {count} ; const translationId = count === 1 ? 'navileg-one-stop-remaining' : 'navileg-stops-remaining'; return ( @@ -58,7 +54,7 @@ const NaviCardExtension = ({ legType, leg }, { config }) => {
diff --git a/app/component/itinerary/NaviInstructions.js b/app/component/itinerary/NaviInstructions.js index 8681dad0b7..f261fb4d3c 100644 --- a/app/component/itinerary/NaviInstructions.js +++ b/app/component/itinerary/NaviInstructions.js @@ -5,6 +5,7 @@ import cx from 'classnames'; import { legShape, configShape } from '../../util/shapes'; import { legDestination, legTimeStr, legTime } from '../../util/legUtils'; import RouteNumber from '../RouteNumber'; +import { LEGTYPE } from './NaviUtils'; import { displayDistance } from '../../util/geo-utils'; import { durationToString } from '../../util/timeUtils'; @@ -25,7 +26,7 @@ export default function NaviInstructions( }; }, [leg]); - if (legType === 'move') { + if (legType === LEGTYPE.MOVE) { return ( <>
@@ -43,7 +44,7 @@ export default function NaviInstructions( ); } - if (legType === 'wait') { + if (legType === LEGTYPE.WAIT) { const { mode, headsign, route } = nextLeg; const color = route.color ? route.color : 'currentColor'; @@ -74,7 +75,7 @@ export default function NaviInstructions( ); } - if (legType === 'in-transit') { + if (legType === LEGTYPE.TRANSIT) { const t = legTime(leg.end); const stopOrStation = leg.to.stop.parentStation ? intl.formatMessage({ id: 'navileg-from-station' }) @@ -126,7 +127,7 @@ NaviInstructions.propTypes = { }; NaviInstructions.defaultProps = { - legType: 'move', + legType: LEGTYPE.MOVE, }; NaviInstructions.contextTypes = { intl: intlShape.isRequired, diff --git a/app/component/itinerary/NaviStack.js b/app/component/itinerary/NaviStack.js index 819a7f0f3f..11c06df793 100644 --- a/app/component/itinerary/NaviStack.js +++ b/app/component/itinerary/NaviStack.js @@ -3,17 +3,7 @@ import PropTypes from 'prop-types'; import cx from 'classnames'; import NaviMessage from './NaviMessage'; -const NaviStack = ({ messages, handleRemove, cardExpanded, legType }) => { - // Card has 4 sizes: first leg collapsed, expanded - // and in transit collapsed, expanded. - let classPostfix = ''; - if (legType === 'in-transit' && cardExpanded) { - classPostfix = 'expand-transit'; - } else if (legType === 'in-transit') { - classPostfix = 'in-transit'; - } else if (cardExpanded) { - classPostfix = 'expanded'; - } +const NaviStack = ({ messages, handleRemove, classPostfix }) => { return (
{messages.map((notification, index) => ( @@ -38,13 +28,11 @@ NaviStack.propTypes = { }), ).isRequired, handleRemove: PropTypes.func.isRequired, - cardExpanded: PropTypes.bool, - legType: PropTypes.string, + classPostfix: PropTypes.string, }; NaviStack.defaultProps = { - cardExpanded: false, - legType: '', + classPostfix: '', }; export default NaviStack; diff --git a/app/component/itinerary/NaviUtils.js b/app/component/itinerary/NaviUtils.js index 43ef196d8a..67c5e04e65 100644 --- a/app/component/itinerary/NaviUtils.js +++ b/app/component/itinerary/NaviUtils.js @@ -250,3 +250,9 @@ export const getDestinationProperties = (leg, stop, config) => { return destination; }; + +export const LEGTYPE = { + WAIT: 'WAIT', + MOVE: 'MOVE', + TRANSIT: 'TRANSIT', +}; diff --git a/app/component/itinerary/navigator.scss b/app/component/itinerary/navigator.scss index ef1569bb57..759879fc14 100644 --- a/app/component/itinerary/navigator.scss +++ b/app/component/itinerary/navigator.scss @@ -351,7 +351,7 @@ top: 235px; } - &.in-transit { + &.transit { top: 162px; } From 2b373e8d5422ab4e7a3796398825256cb2e8618e Mon Sep 17 00:00:00 2001 From: Janne Antikainen Date: Thu, 14 Nov 2024 09:17:22 +0200 Subject: [PATCH 09/11] moved all Navigator files to navigator folder --- app/component/itinerary/ItineraryPage.js | 2 +- .../itinerary/{ => Navigator}/NaviBottom.js | 4 ++-- .../itinerary/{ => Navigator}/NaviCard.js | 6 +++--- .../itinerary/{ => Navigator}/NaviCardContainer.js | 4 ++-- .../itinerary/{ => Navigator}/NaviCardExtension.js | 14 +++++++------- .../itinerary/{ => Navigator}/NaviContainer.js | 6 +++--- .../itinerary/{ => Navigator}/NaviInstructions.js | 10 +++++----- .../itinerary/{ => Navigator}/NaviMessage.js | 4 ++-- .../itinerary/{ => Navigator}/NaviStack.js | 0 .../itinerary/{ => Navigator}/NaviUtils.js | 8 ++++---- .../itinerary/{ => Navigator}/navigator.scss | 0 sass/_main.scss | 2 +- 12 files changed, 30 insertions(+), 30 deletions(-) rename app/component/itinerary/{ => Navigator}/NaviBottom.js (93%) rename app/component/itinerary/{ => Navigator}/NaviCard.js (93%) rename app/component/itinerary/{ => Navigator}/NaviCardContainer.js (98%) rename app/component/itinerary/{ => Navigator}/NaviCardExtension.js (89%) rename app/component/itinerary/{ => Navigator}/NaviContainer.js (90%) rename app/component/itinerary/{ => Navigator}/NaviInstructions.js (92%) rename app/component/itinerary/{ => Navigator}/NaviMessage.js (95%) rename app/component/itinerary/{ => Navigator}/NaviStack.js (100%) rename app/component/itinerary/{ => Navigator}/NaviUtils.js (97%) rename app/component/itinerary/{ => Navigator}/navigator.scss (100%) diff --git a/app/component/itinerary/ItineraryPage.js b/app/component/itinerary/ItineraryPage.js index 06ea3eef92..603f829020 100644 --- a/app/component/itinerary/ItineraryPage.js +++ b/app/component/itinerary/ItineraryPage.js @@ -73,7 +73,7 @@ import { updateClient, } from './ItineraryPageUtils'; import ItineraryTabs from './ItineraryTabs'; -import NaviContainer from './NaviContainer'; +import NaviContainer from './Navigator/NaviContainer'; import NavigatorIntroModal from './NavigatorIntro/NavigatorIntroModal'; import planConnection from './PlanConnection'; diff --git a/app/component/itinerary/NaviBottom.js b/app/component/itinerary/Navigator/NaviBottom.js similarity index 93% rename from app/component/itinerary/NaviBottom.js rename to app/component/itinerary/Navigator/NaviBottom.js index a46bac6f33..1694a6cab4 100644 --- a/app/component/itinerary/NaviBottom.js +++ b/app/component/itinerary/Navigator/NaviBottom.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; import { FormattedMessage } from 'react-intl'; -import { configShape } from '../../util/shapes'; -import { epochToTime } from '../../util/timeUtils'; +import { configShape } from '../../../util/shapes'; +import { epochToTime } from '../../../util/timeUtils'; export default function NaviBottom({ setNavigation, arrival }, { config }) { const remainingDuration = Math.ceil((arrival - Date.now()) / 60000); // ms to minutes diff --git a/app/component/itinerary/NaviCard.js b/app/component/itinerary/Navigator/NaviCard.js similarity index 93% rename from app/component/itinerary/NaviCard.js rename to app/component/itinerary/Navigator/NaviCard.js index 2f2eee82f3..b0c02dfb36 100644 --- a/app/component/itinerary/NaviCard.js +++ b/app/component/itinerary/Navigator/NaviCard.js @@ -1,8 +1,8 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { legShape } from '../../util/shapes'; -import Icon from '../Icon'; -import { isRental } from '../../util/legUtils'; +import { legShape } from '../../../util/shapes'; +import Icon from '../../Icon'; +import { isRental } from '../../../util/legUtils'; import NaviInstructions from './NaviInstructions'; import NaviCardExtension from './NaviCardExtension'; import { LEGTYPE } from './NaviUtils'; diff --git a/app/component/itinerary/NaviCardContainer.js b/app/component/itinerary/Navigator/NaviCardContainer.js similarity index 98% rename from app/component/itinerary/NaviCardContainer.js rename to app/component/itinerary/Navigator/NaviCardContainer.js index 16741ef8b2..dffac59e9a 100644 --- a/app/component/itinerary/NaviCardContainer.js +++ b/app/component/itinerary/Navigator/NaviCardContainer.js @@ -2,8 +2,8 @@ import React, { useEffect, useState, useRef } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage, intlShape } from 'react-intl'; import distance from '@digitransit-search-util/digitransit-search-util-distance'; -import { legShape, configShape } from '../../util/shapes'; -import { legTime, legTimeStr } from '../../util/legUtils'; +import { legShape, configShape } from '../../../util/shapes'; +import { legTime, legTimeStr } from '../../../util/legUtils'; import NaviCard from './NaviCard'; import NaviStack from './NaviStack'; import { diff --git a/app/component/itinerary/NaviCardExtension.js b/app/component/itinerary/Navigator/NaviCardExtension.js similarity index 89% rename from app/component/itinerary/NaviCardExtension.js rename to app/component/itinerary/Navigator/NaviCardExtension.js index 174a20b09f..70bebcafa9 100644 --- a/app/component/itinerary/NaviCardExtension.js +++ b/app/component/itinerary/Navigator/NaviCardExtension.js @@ -2,15 +2,15 @@ import React from 'react'; import cx from 'classnames'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; -import Icon from '../Icon'; -import StopCode from '../StopCode'; -import PlatformNumber from '../PlatformNumber'; -import { getZoneLabel, legTime } from '../../util/legUtils'; -import ZoneIcon from '../ZoneIcon'; -import { legShape, configShape } from '../../util/shapes'; +import Icon from '../../Icon'; +import StopCode from '../../StopCode'; +import PlatformNumber from '../../PlatformNumber'; +import { getZoneLabel, legTime } from '../../../util/legUtils'; +import ZoneIcon from '../../ZoneIcon'; +import { legShape, configShape } from '../../../util/shapes'; import { getDestinationProperties, LEGTYPE } from './NaviUtils'; -import RouteNumberContainer from '../RouteNumberContainer'; +import RouteNumberContainer from '../../RouteNumberContainer'; const NaviCardExtension = ({ legType, leg }, { config }) => { const { stop, name } = leg.to; diff --git a/app/component/itinerary/NaviContainer.js b/app/component/itinerary/Navigator/NaviContainer.js similarity index 90% rename from app/component/itinerary/NaviContainer.js rename to app/component/itinerary/Navigator/NaviContainer.js index b56d6d6ad6..04559e6050 100644 --- a/app/component/itinerary/NaviContainer.js +++ b/app/component/itinerary/Navigator/NaviContainer.js @@ -1,10 +1,10 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { legTime } from '../../util/legUtils'; -import { itineraryShape, relayShape } from '../../util/shapes'; +import { legTime } from '../../../util/legUtils'; +import { itineraryShape, relayShape } from '../../../util/shapes'; import NaviBottom from './NaviBottom'; import NaviCardContainer from './NaviCardContainer'; -import { useRealtimeLegs } from './hooks/useRealtimeLegs'; +import { useRealtimeLegs } from '../hooks/useRealtimeLegs'; function NaviContainer( { itinerary, focusToLeg, relayEnvironment, setNavigation, mapRef }, diff --git a/app/component/itinerary/NaviInstructions.js b/app/component/itinerary/Navigator/NaviInstructions.js similarity index 92% rename from app/component/itinerary/NaviInstructions.js rename to app/component/itinerary/Navigator/NaviInstructions.js index f261fb4d3c..abecbe4e8f 100644 --- a/app/component/itinerary/NaviInstructions.js +++ b/app/component/itinerary/Navigator/NaviInstructions.js @@ -2,12 +2,12 @@ import React, { useEffect, useState } from 'react'; import { FormattedMessage, intlShape } from 'react-intl'; import PropTypes from 'prop-types'; import cx from 'classnames'; -import { legShape, configShape } from '../../util/shapes'; -import { legDestination, legTimeStr, legTime } from '../../util/legUtils'; -import RouteNumber from '../RouteNumber'; +import { legShape, configShape } from '../../../util/shapes'; +import { legDestination, legTimeStr, legTime } from '../../../util/legUtils'; +import RouteNumber from '../../RouteNumber'; import { LEGTYPE } from './NaviUtils'; -import { displayDistance } from '../../util/geo-utils'; -import { durationToString } from '../../util/timeUtils'; +import { displayDistance } from '../../../util/geo-utils'; +import { durationToString } from '../../../util/timeUtils'; export default function NaviInstructions( { leg, nextLeg, instructions, legType }, diff --git a/app/component/itinerary/NaviMessage.js b/app/component/itinerary/Navigator/NaviMessage.js similarity index 95% rename from app/component/itinerary/NaviMessage.js rename to app/component/itinerary/Navigator/NaviMessage.js index 9c39b9a51f..5d5c4e73b6 100644 --- a/app/component/itinerary/NaviMessage.js +++ b/app/component/itinerary/Navigator/NaviMessage.js @@ -2,9 +2,9 @@ import React, { useState } from 'react'; import { intlShape } from 'react-intl'; import cx from 'classnames'; import PropTypes from 'prop-types'; -import { configShape } from '../../util/shapes'; +import { configShape } from '../../../util/shapes'; -import Icon from '../Icon'; +import Icon from '../../Icon'; function NaviMessage({ severity, children, index, handleRemove }, { config }) { const [removingIndex, setRemovingIndex] = useState(null); diff --git a/app/component/itinerary/NaviStack.js b/app/component/itinerary/Navigator/NaviStack.js similarity index 100% rename from app/component/itinerary/NaviStack.js rename to app/component/itinerary/Navigator/NaviStack.js diff --git a/app/component/itinerary/NaviUtils.js b/app/component/itinerary/Navigator/NaviUtils.js similarity index 97% rename from app/component/itinerary/NaviUtils.js rename to app/component/itinerary/Navigator/NaviUtils.js index 67c5e04e65..4e9c68840e 100644 --- a/app/component/itinerary/NaviUtils.js +++ b/app/component/itinerary/Navigator/NaviUtils.js @@ -1,9 +1,9 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; -import { legTime } from '../../util/legUtils'; -import { timeStr } from '../../util/timeUtils'; -import { getFaresFromLegs } from '../../util/fareUtils'; -import { ExtendedRouteTypes } from '../../constants'; +import { legTime } from '../../../util/legUtils'; +import { timeStr } from '../../../util/timeUtils'; +import { getFaresFromLegs } from '../../../util/fareUtils'; +import { ExtendedRouteTypes } from '../../../constants'; const TRANSFER_SLACK = 60000; diff --git a/app/component/itinerary/navigator.scss b/app/component/itinerary/Navigator/navigator.scss similarity index 100% rename from app/component/itinerary/navigator.scss rename to app/component/itinerary/Navigator/navigator.scss diff --git a/sass/_main.scss b/sass/_main.scss index dcf055ec56..a549f3555a 100644 --- a/sass/_main.scss +++ b/sass/_main.scss @@ -63,7 +63,7 @@ $body-font-weight: $font-weight-medium; @import '../app/component/itinerary/settings-panel'; @import '../app/component/itinerary/mobile-ticket-purchase-information'; @import 'base/button'; -@import '../app/component/itinerary/navigator'; +@import '../app/component/itinerary/Navigator/navigator'; @import '../app/component/itinerary/NavigatorIntro/navigator-intro'; /* Modal */ From d64055492923563a2f8e7f5d8fea7c312722f942 Mon Sep 17 00:00:00 2001 From: Janne Antikainen Date: Thu, 14 Nov 2024 09:38:07 +0200 Subject: [PATCH 10/11] move navi intro --- app/component/itinerary/ItineraryPage.js | 2 +- .../{ => Navigator}/NavigatorIntro/NavigatorIntro.js | 4 ++-- .../{ => Navigator}/NavigatorIntro/NavigatorIntroFeature.js | 2 +- .../{ => Navigator}/NavigatorIntro/NavigatorIntroModal.js | 4 ++-- .../{ => Navigator}/NavigatorIntro/navigator-intro.scss | 0 sass/_main.scss | 2 +- .../unit/views/ItineraryPage/component/NavigatorIntro.test.js | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) rename app/component/itinerary/{ => Navigator}/NavigatorIntro/NavigatorIntro.js (96%) rename app/component/itinerary/{ => Navigator}/NavigatorIntro/NavigatorIntroFeature.js (96%) rename app/component/itinerary/{ => Navigator}/NavigatorIntro/NavigatorIntroModal.js (89%) rename app/component/itinerary/{ => Navigator}/NavigatorIntro/navigator-intro.scss (100%) diff --git a/app/component/itinerary/ItineraryPage.js b/app/component/itinerary/ItineraryPage.js index 603f829020..70b6b67432 100644 --- a/app/component/itinerary/ItineraryPage.js +++ b/app/component/itinerary/ItineraryPage.js @@ -74,7 +74,7 @@ import { } from './ItineraryPageUtils'; import ItineraryTabs from './ItineraryTabs'; import NaviContainer from './Navigator/NaviContainer'; -import NavigatorIntroModal from './NavigatorIntro/NavigatorIntroModal'; +import NavigatorIntroModal from './Navigator/NavigatorIntro/NavigatorIntroModal'; import planConnection from './PlanConnection'; const MAX_QUERY_COUNT = 4; // number of attempts to collect enough itineraries diff --git a/app/component/itinerary/NavigatorIntro/NavigatorIntro.js b/app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntro.js similarity index 96% rename from app/component/itinerary/NavigatorIntro/NavigatorIntro.js rename to app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntro.js index 2b41622b22..4e7641ba97 100644 --- a/app/component/itinerary/NavigatorIntro/NavigatorIntro.js +++ b/app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntro.js @@ -3,8 +3,8 @@ import { connectToStores } from 'fluxible-addons-react'; import PropTypes from 'prop-types'; import React from 'react'; import { FormattedMessage, intlShape } from 'react-intl'; -import { configShape } from '../../../util/shapes'; -import Icon from '../../Icon'; +import { configShape } from '../../../../util/shapes'; +import Icon from '../../../Icon'; import NavigatorIntroFeature from './NavigatorIntroFeature'; const NavigatorIntro = ( diff --git a/app/component/itinerary/NavigatorIntro/NavigatorIntroFeature.js b/app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntroFeature.js similarity index 96% rename from app/component/itinerary/NavigatorIntro/NavigatorIntroFeature.js rename to app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntroFeature.js index aa2c19569a..26a662de28 100644 --- a/app/component/itinerary/NavigatorIntro/NavigatorIntroFeature.js +++ b/app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntroFeature.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { FormattedMessage } from 'react-intl'; -import Icon from '../../Icon'; +import Icon from '../../../Icon'; const NavigatorIntroFeature = ({ icon, diff --git a/app/component/itinerary/NavigatorIntro/NavigatorIntroModal.js b/app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntroModal.js similarity index 89% rename from app/component/itinerary/NavigatorIntro/NavigatorIntroModal.js rename to app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntroModal.js index ac12826698..5329ea6dbd 100644 --- a/app/component/itinerary/NavigatorIntro/NavigatorIntroModal.js +++ b/app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntroModal.js @@ -2,7 +2,7 @@ import Modal from '@hsl-fi/modal'; import PropTypes from 'prop-types'; import React, { useEffect, useState } from 'react'; import { intlShape } from 'react-intl'; -import { configShape } from '../../../util/shapes'; +import { configShape } from '../../../../util/shapes'; import NavigatorIntro from './NavigatorIntro'; const NavigatorIntroModal = ({ onPrimaryClick, onClose }, context) => { @@ -17,7 +17,7 @@ const NavigatorIntroModal = ({ onPrimaryClick, onClose }, context) => { const loadLogo = async () => { try { const importedLogo = await import( - /* webpackChunkName: "main" */ `../../../configurations/images/${config.navigationLogo}` + /* webpackChunkName: "main" */ `../../../../configurations/images/${config.navigationLogo}` ); setLogo(importedLogo.default); } catch (error) { diff --git a/app/component/itinerary/NavigatorIntro/navigator-intro.scss b/app/component/itinerary/Navigator/NavigatorIntro/navigator-intro.scss similarity index 100% rename from app/component/itinerary/NavigatorIntro/navigator-intro.scss rename to app/component/itinerary/Navigator/NavigatorIntro/navigator-intro.scss diff --git a/sass/_main.scss b/sass/_main.scss index a549f3555a..bf0486c825 100644 --- a/sass/_main.scss +++ b/sass/_main.scss @@ -64,7 +64,7 @@ $body-font-weight: $font-weight-medium; @import '../app/component/itinerary/mobile-ticket-purchase-information'; @import 'base/button'; @import '../app/component/itinerary/Navigator/navigator'; -@import '../app/component/itinerary/NavigatorIntro/navigator-intro'; +@import '../app/component/itinerary/Navigator/NavigatorIntro/navigator-intro'; /* Modal */ @import '~foundation-apps/scss/helpers/breakpoints'; diff --git a/test/unit/views/ItineraryPage/component/NavigatorIntro.test.js b/test/unit/views/ItineraryPage/component/NavigatorIntro.test.js index f6b68b2209..4fc5087a38 100644 --- a/test/unit/views/ItineraryPage/component/NavigatorIntro.test.js +++ b/test/unit/views/ItineraryPage/component/NavigatorIntro.test.js @@ -2,7 +2,7 @@ import { assert } from 'chai'; import { describe, it } from 'mocha'; import React from 'react'; -import NavigatorIntro from '../../../../../app/component/itinerary/NavigatorIntro/NavigatorIntro'; +import NavigatorIntro from '../../../../../app/component/itinerary/Navigator/NavigatorIntro/NavigatorIntro'; import { mockChildContextTypes, mockContext, From 653032037a824f00dcfc615086d783eac27b21a3 Mon Sep 17 00:00:00 2001 From: Janne Antikainen Date: Thu, 14 Nov 2024 10:09:13 +0200 Subject: [PATCH 11/11] date now out of the loop --- app/component/itinerary/Navigator/NaviCardExtension.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/component/itinerary/Navigator/NaviCardExtension.js b/app/component/itinerary/Navigator/NaviCardExtension.js index 70bebcafa9..4bd9fba5e9 100644 --- a/app/component/itinerary/Navigator/NaviCardExtension.js +++ b/app/component/itinerary/Navigator/NaviCardExtension.js @@ -29,9 +29,8 @@ const NaviCardExtension = ({ legType, leg }, { config }) => { if (legType === LEGTYPE.TRANSIT) { const { intermediatePlaces } = leg; - const idx = intermediatePlaces.findIndex( - p => legTime(p.arrival) > Date.now(), - ); + const now = Date.now(); + const idx = intermediatePlaces.findIndex(p => legTime(p.arrival) > now); const count = idx > -1 ? intermediatePlaces.length - idx : 0; const stopCount = {count} ;