Fix: Handle undefined designElements in design spec SVG rendering
The SVG element markers were trying to map over designElements without checking if it was defined first. Now safely checks for array existence before calling .map() to prevent errors when generating spec sheets.
This commit is contained in:
@@ -126,10 +126,10 @@ export async function GET(req: Request, { params }: { params: { id: string } })
|
||||
<text x="${printAreaStartX - 25}" y="${printAreaStartY + 15}" font-size="12" fill="green" font-weight="bold">Y (0cm)</text>
|
||||
|
||||
<!-- Design elements with markers -->
|
||||
${designElements.map((el, idx) => `
|
||||
${designElements && designElements.length > 0 ? designElements.map((el, idx) => `
|
||||
<circle cx="${el.x}" cy="${el.y}" r="5" fill="orange" opacity="0.9" stroke="white" stroke-width="1"/>
|
||||
<text x="${el.x + 10}" y="${el.y - 10}" font-size="12" fill="orange" font-weight="bold" font-family="monospace">E${idx + 1}</text>
|
||||
`).join('')}
|
||||
`).join('') : ''}
|
||||
</svg>
|
||||
</div>
|
||||
<div style="margin-top: 15px; font-size: 12px; color: #666; text-align: left; max-width: 400px;">
|
||||
|
||||
Reference in New Issue
Block a user