From 0d3d2f48ebb217acfbadfe491360118c92373cf4 Mon Sep 17 00:00:00 2001 From: Simon Nitz <62117895+wdcsimon@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:44:55 +1300 Subject: [PATCH 1/2] Update route summary tooltip with correct time Time is reported wrong in route summary tooltip when hovering over route. Apply same fix as used in Issue #12 --- src/Map/Map.jsx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Map/Map.jsx b/src/Map/Map.jsx index e50accd..94fdf16 100644 --- a/src/Map/Map.jsx +++ b/src/Map/Map.jsx @@ -15,6 +15,7 @@ import PropTypes from 'prop-types' import axios from 'axios' import * as R from 'ramda' +import { intervalToDuration } from 'date-fns' import ExtraMarkers from './extraMarkers' import { Button, Label, Icon, Popup } from 'semantic-ui-react' import { CopyToClipboard } from 'react-copy-to-clipboard' @@ -526,11 +527,25 @@ class Map extends React.Component { } formatDuration = (durationInSeconds) => { - const date = new Date(durationInSeconds * 1000) - const days = date.getDate() - 1 > 0 ? date.getDate() - 1 + 'd ' : '' - const hours = date.getHours() > 0 ? date.getHours() + 'h ' : '' - const minutes = date.getMinutes() > 0 ? date.getMinutes() + 'min' : '' - return days + hours + minutes + const duration = intervalToDuration({ + start: 0, + end: durationInSeconds * 1000, + }) + + let durationStr = '' + if (duration.days > 0) { + durationStr += duration.days + 'd ' + } + if (duration.hours > 0) { + durationStr += duration.hours + 'h ' + } + if (duration.minutes > 0) { + durationStr += duration.minutes + 'min ' + } + if (duration.seconds > 0) { + durationStr += duration.seconds + 'sec' + } + return durationStr } getRouteToolTip = (summary, provider) => { From 6e3d2f150fc1f4c95c4335eaf3e43c155477bb88 Mon Sep 17 00:00:00 2001 From: Simon Nitz <62117895+wdcsimon@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:56:00 +1300 Subject: [PATCH 2/2] Correct URL routing for directions and isochrones Use # instead of / for correct URL routing --- src/actions/commonActions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions/commonActions.js b/src/actions/commonActions.js index 94352f4..6ee3ee3 100644 --- a/src/actions/commonActions.js +++ b/src/actions/commonActions.js @@ -63,7 +63,7 @@ export const updatePermalink = () => (dispatch, getState) => { const queryParams = new URLSearchParams() queryParams.set('profile', profile) - let path = '/directions?' + let path = '#directions?' if (activeTab === 0) { const wps = [] for (const wp of waypoints) { @@ -77,7 +77,7 @@ export const updatePermalink = () => (dispatch, getState) => { queryParams.set('wps', wps.toString()) } } else { - path = '/isochrones?' + path = '#isochrones?' let center for (const result of geocodeResults) {