From 61fff8c2e18481856571a19c07189f68cf62d56e Mon Sep 17 00:00:00 2001 From: andrei Date: Sat, 5 Oct 2024 17:38:05 +0500 Subject: [PATCH] ._. --- src/pages/DeliveryOrderDetails.jsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/pages/DeliveryOrderDetails.jsx b/src/pages/DeliveryOrderDetails.jsx index f1b840c..79ca0af 100644 --- a/src/pages/DeliveryOrderDetails.jsx +++ b/src/pages/DeliveryOrderDetails.jsx @@ -12,6 +12,12 @@ import { import polyline from "@mapbox/polyline"; import "./DeliveryOrderDetails.css"; +const DELIVERY_CITY = { + name: "Челябинск", + latitude: 55.159902, + longitude: 61.402554, +}; + const DeliveryOrderDetails = () => { const { id: deliveryOrderId } = useParams(); const [deliveryAccessories, setDeliveryAccessories] = useState([]); @@ -36,8 +42,10 @@ const DeliveryOrderDetails = () => { ); setCoordinates(coords); - if (coords.length > 1) { - const waypoints = coords + const fullCoordinates = [...coords, DELIVERY_CITY]; + + if (fullCoordinates.length > 1) { + const waypoints = fullCoordinates .map(({ longitude, latitude }) => `${longitude},${latitude}`) .join(";"); const routeUrl = `https://router.project-osrm.org/route/v1/driving/${waypoints}?overview=full`; @@ -62,7 +70,7 @@ const DeliveryOrderDetails = () => {
{loading ? (
- Загрузка... +
) : (
@@ -104,6 +112,11 @@ const DeliveryOrderDetails = () => { {coord.city} ))} + + {DELIVERY_CITY.name} + {route.length > 0 && ( )}