From f3b5771c09581e5a385a5d4a69f64be0248789bc Mon Sep 17 00:00:00 2001 From: Fedor Date: Tue, 25 Nov 2025 23:28:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BB=D0=BE=D0=BA=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D0=B4=D0=BE=D0=BA=D1=83?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D1=81=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D1=83=20=D1=80=D0=B0=D0=B7=D0=B2=D1=91=D1=80=D0=BD=D1=83=D1=82?= =?UTF-8?q?=D1=8B=20=D0=BF=D1=80=D0=B8=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B7=D0=BA=D0=B5=20=D0=BF=D0=BB=D0=B0=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/form/StepWizardPlan.tsx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) 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', {