From 10f0e63657888f8a681c4cafcb0bde44b3e0f8ed Mon Sep 17 00:00:00 2001 From: Meik Date: Mon, 10 Nov 2025 23:56:50 +0100 Subject: [PATCH] maps route link --- src/components/StoreWatchPage.js | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/components/StoreWatchPage.js b/src/components/StoreWatchPage.js index 48a14eb..4ec2f6f 100644 --- a/src/components/StoreWatchPage.js +++ b/src/components/StoreWatchPage.js @@ -480,7 +480,42 @@ const StoreWatchPage = ({ cell: ({ row }) => (

{row.original.city || 'unbekannt'}

-

{row.original.street || ''}

+
+

{row.original.street || ''}

+ {(() => { + const hasUserLocation = + userLocation && + Number.isFinite(userLocation.lat) && + Number.isFinite(userLocation.lon); + const storeLat = Number(row.original.location?.lat); + const storeLon = Number(row.original.location?.lon); + const hasStoreLocation = Number.isFinite(storeLat) && Number.isFinite(storeLon); + if (!hasUserLocation || !hasStoreLocation) { + return null; + } + const origin = encodeURIComponent(`${userLocation.lat},${userLocation.lon}`); + const destination = encodeURIComponent(`${storeLat},${storeLon}`); + const mapsUrl = `https://www.google.com/maps/dir/?api=1&origin=${origin}&destination=${destination}&travelmode=driving`; + return ( + + Route in Google Maps + + + + + ); + })()} +
), sortingFn: 'alphanumeric',