правка добавления строки в 4 форме #57
@ -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];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user