From dac346775d65855169a21229e310312554af3f8a Mon Sep 17 00:00:00 2001 From: suryac Date: Thu, 6 Aug 2026 16:27:13 +0530 Subject: [PATCH] added geolocation input difference --- src/components/dv/CallDetail.tsx | 6 +++--- src/components/dv/StoreDetail.tsx | 4 ++-- src/components/forms/DynamicForm.tsx | 2 +- .../forms/fields/GeolocationInput.tsx | 10 +++++----- src/components/maps/DailyLogMap.tsx | 18 ++++++++++-------- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/components/dv/CallDetail.tsx b/src/components/dv/CallDetail.tsx index 7d42bbb..f6fbcbc 100644 --- a/src/components/dv/CallDetail.tsx +++ b/src/components/dv/CallDetail.tsx @@ -147,9 +147,9 @@ export function CallDetail({ const locStr = selectStore.store_location; if (locStr) { const loc = typeof locStr === 'string' ? JSON.parse(locStr) : locStr; - if (loc?.latitude && loc?.longitude) { - lat = loc.latitude; - lng = loc.longitude; + if ((loc?.lat || loc?.latitude) && (loc?.lng || loc?.longitude)) { + lat = loc.lat ?? loc.latitude; + lng = loc.lng ?? loc.longitude; } } } catch (e) { } diff --git a/src/components/dv/StoreDetail.tsx b/src/components/dv/StoreDetail.tsx index 29b2957..444011f 100644 --- a/src/components/dv/StoreDetail.tsx +++ b/src/components/dv/StoreDetail.tsx @@ -122,8 +122,8 @@ export function StoreDetail({ instanceId, onBack, onEdit }: StoreDetailProps) { try { locObj = JSON.parse(locObj); } catch (e) { } } if (locObj && typeof locObj === 'object') { - lat = (locObj as any).latitude; - lng = (locObj as any).longitude; + lat = (locObj as any).lat ?? (locObj as any).latitude; + lng = (locObj as any).lng ?? (locObj as any).longitude; } } diff --git a/src/components/forms/DynamicForm.tsx b/src/components/forms/DynamicForm.tsx index 5526a15..eafd102 100644 --- a/src/components/forms/DynamicForm.tsx +++ b/src/components/forms/DynamicForm.tsx @@ -951,7 +951,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId: handleFieldChange(f.id, newVal)} /> ); diff --git a/src/components/forms/fields/GeolocationInput.tsx b/src/components/forms/fields/GeolocationInput.tsx index 4fbb92f..dc1b8e8 100644 --- a/src/components/forms/fields/GeolocationInput.tsx +++ b/src/components/forms/fields/GeolocationInput.tsx @@ -22,7 +22,7 @@ export function GeolocationInput({ label: string; required?: boolean; value: { latitude?: number; longitude?: number; lat?: number; lng?: number; accuracy?: number } | null; - onChange: (val: { latitude: number; longitude: number; accuracy?: number } | null) => void; + onChange: (val: { lat: number; lng: number; accuracy?: number } | null) => void; }) { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -53,8 +53,8 @@ export function GeolocationInput({ navigator.geolocation.getCurrentPosition( (pos) => { onChange({ - latitude: pos.coords.latitude, - longitude: pos.coords.longitude, + lat: pos.coords.latitude, + lng: pos.coords.longitude, accuracy: pos.coords.accuracy, }); setLoading(false); @@ -96,8 +96,8 @@ export function GeolocationInput({ const confirmMapSelection = () => { if (mapMarkerPos) { onChange({ - latitude: mapMarkerPos.lat, - longitude: mapMarkerPos.lng, + lat: mapMarkerPos.lat, + lng: mapMarkerPos.lng, accuracy: 10, }); setIsMapModalOpen(false); diff --git a/src/components/maps/DailyLogMap.tsx b/src/components/maps/DailyLogMap.tsx index c54f138..d6712b1 100644 --- a/src/components/maps/DailyLogMap.tsx +++ b/src/components/maps/DailyLogMap.tsx @@ -8,8 +8,10 @@ import { CustomAdvancedMarker } from './CustomAdvancedMarker'; const libraries: ("marker")[] = ["marker"]; interface StoreLocation { - latitude: number; - longitude: number; + latitude?: number; + longitude?: number; + lat?: number; + lng?: number; } interface Store { @@ -141,8 +143,8 @@ export function DailyLogMap({ bounds.extend(userLocation); stores.forEach(store => { if (store.location) { - const lat = Number(store.location.latitude); - const lng = Number(store.location.longitude); + const lat = Number(store.location.lat ?? store.location.latitude); + const lng = Number(store.location.lng ?? store.location.longitude); if (!isNaN(lat) && !isNaN(lng)) { bounds.extend({ lat, lng }); } @@ -193,8 +195,8 @@ export function DailyLogMap({ {/* Stores Markers */} {stores.map((store, index) => { if (!store.location) return null; - const lat = Number(store.location.latitude); - const lng = Number(store.location.longitude); + const lat = Number(store.location.lat ?? store.location.latitude); + const lng = Number(store.location.lng ?? store.location.longitude); if (isNaN(lat) || isNaN(lng)) return null; return ( @@ -208,9 +210,9 @@ export function DailyLogMap({ })} {/* Info Window for Selected Store */} - {selectedStore && selectedStore.location && !isNaN(Number(selectedStore.location.latitude)) && ( + {selectedStore && selectedStore.location && !isNaN(Number(selectedStore.location.lat ?? selectedStore.location.latitude)) && ( setSelectedStore(null)} >