Блоки загрузки документов сразу развёрнуты при загрузке плана

This commit is contained in:
Fedor
2025-11-25 23:28:36 +03:00
parent 2ce0c585ff
commit f3b5771c09

View File

@@ -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', {