fix: scope template edit — read scope_template_sections from API response

API returns scope_template_sections (Prisma relation name) but
frontend was reading sections. Now checks both field names.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-03-24 18:59:21 +01:00
parent 6497933c3e
commit 19912ecbe6

View File

@@ -360,10 +360,11 @@ function ScopeTemplatesTab() {
const result = await response.json()
if (result.success) {
setEditingTemplate(result.data)
const templateSections = result.data.scope_template_sections || result.data.sections || []
setForm({
name: result.data.name || '',
sections: result.data.sections?.length
? result.data.sections.map((s: { title?: string; title_cz?: string; content?: string }) => ({ _key: `sc-${++sectionKeyCounter.current}`, title: s.title || '', title_cz: s.title_cz || '', content: s.content || '' }))
sections: templateSections.length
? templateSections.map((s: { title?: string; title_cz?: string; content?: string }) => ({ _key: `sc-${++sectionKeyCounter.current}`, title: s.title || '', title_cz: s.title_cz || '', content: s.content || '' }))
: [{ _key: `sc-${++sectionKeyCounter.current}`, title: '', title_cz: '', content: '' }]
})
setShowModal(true)