diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/pages/Dashboard.tsx index ff57e8c..1983879 100644 --- a/frontend/src/pages/Dashboard.tsx +++ b/frontend/src/pages/Dashboard.tsx @@ -33,8 +33,19 @@ function CanvasPreview({ project, token }: { project: Project; token: string }) try { const drawings = await getDrawings(token, project.id); if (drawings.length === 0) { if (!cancelled) setElements([]); return; } - const els = await getElements(token, drawings[0].id); - if (!cancelled) setElements(els); + const rawEls = await getElements(token, drawings[0].id); + // API may return DBElement with properties_json (string) instead of properties (object) + const transformed: CADElement[] = rawEls.map((el: any) => ({ + id: el.id, + type: el.type, + layerId: el.layer_id ?? el.layerId ?? '', + x: el.x ?? 0, + y: el.y ?? 0, + width: el.width ?? 0, + height: el.height ?? 0, + properties: typeof el.properties_json === 'string' ? JSON.parse(el.properties_json || '{}') : (el.properties ?? {}), + })); + if (!cancelled) setElements(transformed); } catch { if (!cancelled) setElements([]); } finally {