added lat and lng in cards
This commit is contained in:
parent
0a432f751c
commit
3d79125127
@ -28,12 +28,12 @@ export function StoreCard({ row, isDetailView = false, onEdit }: { row: Record<s
|
||||
const email = formatValue(emailObj?.email || row.email || row.store_email || row.business_email || '—');
|
||||
|
||||
// Location
|
||||
const locObj = row.store_location as Record<string, unknown> | 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<string, unknown> | 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 || '—');
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -608,7 +608,7 @@ export function DynamicForm({ client, activityId: initialActivityId, instanceId:
|
||||
<GeolocationInput
|
||||
label={f.name}
|
||||
required={f.mandatory}
|
||||
value={(val as { latitude: number; longitude: number }) || null}
|
||||
value={(val as { lat: number; lng: number }) || null}
|
||||
onChange={(newVal) => handleFieldChange(f.id, newVal)}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -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<string | null>(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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user