diff --git a/ticket_form/frontend/src/components/form/StepWizardPlan.tsx b/ticket_form/frontend/src/components/form/StepWizardPlan.tsx index 8e70a040..b8e53240 100644 --- a/ticket_form/frontend/src/components/form/StepWizardPlan.tsx +++ b/ticket_form/frontend/src/components/form/StepWizardPlan.tsx @@ -379,6 +379,36 @@ export default function StepWizardPlan({ }); }, [formValues, plan, questions, documentGroups, questionFileBlocks, handleDocumentBlocksChange, skippedDocuments]); + // Автоматически создаём блоки для ВСЕХ документов из плана при загрузке + useEffect(() => { + if (!plan || !documents || documents.length === 0) return; + + documents.forEach((doc) => { + const docKey = doc.id || doc.name || `doc_${Math.random()}`; + + // Не создаём блок, если документ пропущен + if (skippedDocuments.has(docKey)) return; + + const existingBlocks = questionFileBlocks[docKey] || []; + + // Если блока ещё нет, создаём его автоматически + if (existingBlocks.length === 0) { + const category = doc.id && !doc.id.includes('_exist') ? doc.id : docKey; + handleDocumentBlocksChange(docKey, (blocks) => [ + ...blocks, + { + id: generateBlockId(docKey), + fieldName: docKey, + description: '', + category: category, + docLabel: doc.name, + files: [], + }, + ]); + } + }); + }, [plan, documents, questionFileBlocks, handleDocumentBlocksChange, skippedDocuments]); + useEffect(() => { if (!isWaiting || !formData.session_id || plan) { console.log('⏭️ StepWizardPlan: пропускаем подписку SSE', {