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:
@@ -360,10 +360,11 @@ function ScopeTemplatesTab() {
|
|||||||
const result = await response.json()
|
const result = await response.json()
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
setEditingTemplate(result.data)
|
setEditingTemplate(result.data)
|
||||||
|
const templateSections = result.data.scope_template_sections || result.data.sections || []
|
||||||
setForm({
|
setForm({
|
||||||
name: result.data.name || '',
|
name: result.data.name || '',
|
||||||
sections: result.data.sections?.length
|
sections: templateSections.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 || '' }))
|
? 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: '' }]
|
: [{ _key: `sc-${++sectionKeyCounter.current}`, title: '', title_cz: '', content: '' }]
|
||||||
})
|
})
|
||||||
setShowModal(true)
|
setShowModal(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user