asdfasdfasdfasdf

This commit is contained in:
Jake Kasper
2025-09-05 12:39:15 -04:00
parent e5605f0868
commit bb6dc070de

View File

@@ -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 || []