asdfasdfasdfasdf
This commit is contained in:
@@ -433,12 +433,18 @@ const PropertyDetail = () => {
|
|||||||
// Convert backend sections to frontend format
|
// Convert backend sections to frontend format
|
||||||
if (propertyData.sections && propertyData.sections.length > 0) {
|
if (propertyData.sections && propertyData.sections.length > 0) {
|
||||||
const convertedSections = propertyData.sections.map(section => {
|
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 {
|
return {
|
||||||
id: section.id,
|
id: section.id,
|
||||||
name: section.name,
|
name: section.name,
|
||||||
coordinates: poly?.coordinates?.[0] || [],
|
coordinates: coords,
|
||||||
color: poly?.color || SECTION_COLORS[0],
|
color,
|
||||||
area: section.area,
|
area: section.area,
|
||||||
grassType: section.grassType || '',
|
grassType: section.grassType || '',
|
||||||
grassTypes: section.grassTypes || null
|
grassTypes: section.grassTypes || null
|
||||||
@@ -663,11 +669,17 @@ const PropertyDetail = () => {
|
|||||||
const savedSection = response.data.data.section;
|
const savedSection = response.data.data.section;
|
||||||
// Convert backend format to frontend format; parse polygonData if string
|
// Convert backend format to frontend format; parse polygonData if string
|
||||||
const poly = typeof savedSection.polygonData === 'string' ? JSON.parse(savedSection.polygonData) : savedSection.polygonData;
|
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 = {
|
const newSection = {
|
||||||
id: savedSection.id,
|
id: savedSection.id,
|
||||||
name: savedSection.name,
|
name: savedSection.name,
|
||||||
coordinates: poly?.coordinates?.[0] || [],
|
coordinates: coordsNorm,
|
||||||
color: poly?.color || currentColor,
|
color: colorNorm,
|
||||||
area: savedSection.area,
|
area: savedSection.area,
|
||||||
grassType: savedSection.grassType || '',
|
grassType: savedSection.grassType || '',
|
||||||
grassTypes: savedSection.grassTypes || []
|
grassTypes: savedSection.grassTypes || []
|
||||||
|
|||||||
Reference in New Issue
Block a user