From bb6dc070de7e75c45574e6d6f2998a22ed510b2d Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Fri, 5 Sep 2025 12:39:15 -0400 Subject: [PATCH] asdfasdfasdfasdf --- .../src/pages/Properties/PropertyDetail.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/Properties/PropertyDetail.js b/frontend/src/pages/Properties/PropertyDetail.js index a2224ec..5387612 100644 --- a/frontend/src/pages/Properties/PropertyDetail.js +++ b/frontend/src/pages/Properties/PropertyDetail.js @@ -433,12 +433,18 @@ const PropertyDetail = () => { // Convert backend sections to frontend format if (propertyData.sections && propertyData.sections.length > 0) { const convertedSections = propertyData.sections.map(section => { - const poly = typeof section.polygonData === 'string' ? JSON.parse(section.polygonData) : section.polygonData; + const polyRaw = typeof section.polygonData === 'string' ? JSON.parse(section.polygonData) : section.polygonData; + const ring = Array.isArray(polyRaw?.coordinates?.[0]) ? polyRaw.coordinates[0] : []; + const coords = ring.map(pt => [Number(pt[0]), Number(pt[1])]); + const colorRaw = polyRaw?.color; + const color = (colorRaw && typeof colorRaw === 'object' && 'value' in colorRaw) + ? colorRaw + : (typeof colorRaw === 'string' ? { name: 'Custom', value: colorRaw } : SECTION_COLORS[0]); return { id: section.id, name: section.name, - coordinates: poly?.coordinates?.[0] || [], - color: poly?.color || SECTION_COLORS[0], + coordinates: coords, + color, area: section.area, grassType: section.grassType || '', grassTypes: section.grassTypes || null @@ -663,11 +669,17 @@ const PropertyDetail = () => { const savedSection = response.data.data.section; // Convert backend format to frontend format; parse polygonData if string const poly = typeof savedSection.polygonData === 'string' ? JSON.parse(savedSection.polygonData) : savedSection.polygonData; + const ring = Array.isArray(poly?.coordinates?.[0]) ? poly.coordinates[0] : []; + const coordsNorm = ring.map(pt => [Number(pt[0]), Number(pt[1])]); + const colorRaw = poly?.color; + const colorNorm = (colorRaw && typeof colorRaw === 'object' && 'value' in colorRaw) + ? colorRaw + : (typeof colorRaw === 'string' ? { name: 'Custom', value: colorRaw } : currentColor); const newSection = { id: savedSection.id, name: savedSection.name, - coordinates: poly?.coordinates?.[0] || [], - color: poly?.color || currentColor, + coordinates: coordsNorm, + color: colorNorm, area: savedSection.area, grassType: savedSection.grassType || '', grassTypes: savedSection.grassTypes || []