diff --git a/src/components/cards/StoreCard.tsx b/src/components/cards/StoreCard.tsx index 0525276..96c0f2b 100644 --- a/src/components/cards/StoreCard.tsx +++ b/src/components/cards/StoreCard.tsx @@ -28,12 +28,12 @@ export function StoreCard({ row, isDetailView = false, onEdit }: { row: Record | null; - const latRaw = locObj?.latitude || row.latitude; - const lngRaw = locObj?.longitude || row.longitude; + const locObj = typeof row.store_location === 'string' ? (() => { try { return JSON.parse(row.store_location); } catch (e) { return null; } })() : (row.store_location as Record | null); + const latRaw = locObj?.latitude ?? locObj?.lat ?? row.latitude ?? row.lat; + const lngRaw = locObj?.longitude ?? locObj?.lng ?? row.longitude ?? row.lng; const lat = formatValue(latRaw || '—'); const lng = formatValue(lngRaw || '—'); - const hasLocation = lat !== '—' && lng !== '—' && latRaw !== undefined && lngRaw !== undefined; + const hasLocation = lat !== '—' && lng !== '—' && latRaw !== undefined && lngRaw !== undefined && latRaw !== null && lngRaw !== null; const areaName = formatValue(row.area || row.area_name || '—'); diff --git a/src/components/dv/StoreDetail.tsx b/src/components/dv/StoreDetail.tsx index 8ff3f9a..aa3c00f 100644 --- a/src/components/dv/StoreDetail.tsx +++ b/src/components/dv/StoreDetail.tsx @@ -135,8 +135,10 @@ export function StoreDetail({ instanceId, onBack, onEdit, refreshKey }: StoreDet try { locObj = JSON.parse(locObj); } catch (e) { } } if (locObj && typeof locObj === 'object') { - lat = (locObj as any).latitude || (locObj as any).lat; - lng = (locObj as any).longitude || (locObj as any).lng; + const rawLat = (locObj as any).latitude ?? (locObj as any).lat; + const rawLng = (locObj as any).longitude ?? (locObj as any).lng; + lat = rawLat != null && rawLat !== '' ? Number(rawLat) : null; + lng = rawLng != null && rawLng !== '' ? Number(rawLng) : null; } } diff --git a/src/components/forms/DynamicForm.tsx b/src/components/forms/DynamicForm.tsx index be23cdd..abea98a 100644 --- a/src/components/forms/DynamicForm.tsx +++ b/src/components/forms/DynamicForm.tsx @@ -608,7 +608,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 bde9137..bffa014 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);