From 246e0bcc0d5860c3e404ba4b4f91bfe52abf2627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20V=C3=A1clav=C3=ADk?= Date: Thu, 12 Dec 2024 21:22:52 +0100 Subject: [PATCH] Direction: Add another destination --- .../Directions/DirectionsAutocomplete.tsx | 3 --- src/components/Directions/DirectionsForm.tsx | 25 ++++++++++++++++--- src/components/Directions/helpers.tsx | 4 +-- .../routing/getGraphhopperResults.ts | 9 ++++--- src/components/Directions/useGetOnSubmit.tsx | 5 ++-- src/locales/vocabulary.js | 1 + 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/components/Directions/DirectionsAutocomplete.tsx b/src/components/Directions/DirectionsAutocomplete.tsx index 46e4effe6..c7c4346b0 100644 --- a/src/components/Directions/DirectionsAutocomplete.tsx +++ b/src/components/Directions/DirectionsAutocomplete.tsx @@ -263,7 +263,6 @@ export const DirectionsAutocomplete = ({ label, value, pointIndex }: Props) => { const lngLat = markerRef.current?.getLngLat(); if (lngLat) { const coordsOption = getCoordsOption([lngLat.lng, lngLat.lat]); - updatePoint(pointIndex, coordsOption); handleUpdate(coordsOption); } }; @@ -275,8 +274,6 @@ export const DirectionsAutocomplete = ({ label, value, pointIndex }: Props) => { const onChange = (_: unknown, option: Option) => { console.log('selected', option); // eslint-disable-line no-console setInputValue(getOptionLabel(option)); - updatePoint(pointIndex, option); - selectedOptionInputValue.current = getOptionLabel(option); handleUpdate(option); }; diff --git a/src/components/Directions/DirectionsForm.tsx b/src/components/Directions/DirectionsForm.tsx index 8a124c5cd..bc4a978ed 100644 --- a/src/components/Directions/DirectionsForm.tsx +++ b/src/components/Directions/DirectionsForm.tsx @@ -3,7 +3,7 @@ import { RoutingResult } from './routing/types'; import { CloseButton } from './helpers'; import React, { useEffect, useMemo, useState } from 'react'; import { StyledPaper } from './Result'; -import { Box, Stack } from '@mui/material'; +import { Box, Button, Stack } from '@mui/material'; import { ModeToggler } from './ModeToggler'; import { DirectionsAutocomplete } from './DirectionsAutocomplete'; import { t } from '../../services/intl'; @@ -12,6 +12,7 @@ import SearchIcon from '@mui/icons-material/Search'; import { getCoordsOption } from '../SearchBox/options/coords'; import { useMapStateContext } from '../utils/MapStateContext'; import { useDirectionsContext } from './DirectionsContext'; +import ControlPointIcon from '@mui/icons-material/ControlPoint'; import { useGetOnSubmitFactory, useReactToUrl, @@ -29,6 +30,7 @@ type Props = { const useGlobalMapClickOverride = ( points: Array