правка добавления строки в 4 форме

This commit is contained in:
PotapovaA 2026-07-29 16:47:07 +03:00
parent 5498bf4935
commit ea6a6471e4

View File

@ -238,9 +238,13 @@ const useRealtimeData = (formId, sheetName, direction, formType, year) => {
}); });
}); });
const unsubscribeProgramAdds = subscribeToProgramAdds((data) => { const unsubscribeProgramAdds = subscribeToProgramAdds((msg) => {
const newRow = data.result[1][0]; let newRow = msg.result[1][0];
setData((prevData) => { setData((prevData) => {
const hasRoot = prevData.length > 0 && prevData[0].row_type === "ROOT";
if (hasRoot) {
newRow = msg.result[1][1];
}
const updateData = structuredClone(prevData); const updateData = structuredClone(prevData);
const [row_type, depth, sort_order, dataRow] = newRow; const [row_type, depth, sort_order, dataRow] = newRow;
const newRowObject = { const newRowObject = {
@ -250,8 +254,11 @@ const useRealtimeData = (formId, sheetName, direction, formType, year) => {
subRows: [], subRows: [],
data: dataRow, data: dataRow,
}; };
const newData = [...updateData, newRowObject]; if (hasRoot) {
return newData; updateData[0].subRows.push(newRowObject);
return updateData;
}
return [...updateData, newRowObject];
}); });
}); });