From 74ec3a0edac6632ae17a45a27bc6bea45ebc6799 Mon Sep 17 00:00:00 2001 From: Lixian Zhou Date: Mon, 9 Mar 2026 16:19:11 -0400 Subject: [PATCH] fix --- .../src/components/trans-routes/RoutesDashboard.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/client/src/components/trans-routes/RoutesDashboard.js b/client/src/components/trans-routes/RoutesDashboard.js index 8f14802..fd21264 100644 --- a/client/src/components/trans-routes/RoutesDashboard.js +++ b/client/src/components/trans-routes/RoutesDashboard.js @@ -108,6 +108,15 @@ const RoutesDashboard = () => { .trim(); }; + // Match route addresses against stored structured addresses without state/zip sensitivity. + const normalizeAddressForMismatchCheck = (address) => { + return normalizeAddress(address) + .replace(/\b\d{5}(?:\s*\d{4})?\b/g, ' ') + .replace(/\b(maryland|md|virginia|va)\b/g, ' ') + .replace(/\s+/g, ' ') + .trim(); + }; + const formatStructuredAddress = (line1, line2, city, state, zipCode, note) => { const cityState = [city, state].filter(Boolean).join(', '); const mainAddress = [line1, line2, cityState, zipCode] @@ -331,12 +340,12 @@ const RoutesDashboard = () => { if (!customerProfile) return; const routeAddress = customerInRoute?.customer_address_override || customerInRoute?.customer_address || ''; - const normalizedRouteAddress = normalizeAddress(routeAddress); + const normalizedRouteAddress = normalizeAddressForMismatchCheck(routeAddress); if (!normalizedRouteAddress) return; const storedAddressSet = new Set( getStoredCustomerAddresses(customerProfile) - .map((address) => normalizeAddress(address)) + .map((address) => normalizeAddressForMismatchCheck(address)) .filter(Boolean) ); if (storedAddressSet.size === 0) return;