fix: promise.all 형태로 변경

This commit is contained in:
yoosangwook 2025-04-04 13:15:21 +09:00
parent a316664b20
commit b8f05a6ff0

View File

@ -217,7 +217,7 @@ const Trestle = forwardRef((props, ref) => {
} }
} }
const isComplete = () => { const isComplete = async () => {
const newAddedRoofs = roofs.map((roof, i) => { const newAddedRoofs = roofs.map((roof, i) => {
if (i === selectedRoof?.index) { if (i === selectedRoof?.index) {
return { return {
@ -263,51 +263,60 @@ const Trestle = forwardRef((props, ref) => {
console.log('newAddedRoofs', newAddedRoofs) console.log('newAddedRoofs', newAddedRoofs)
if (result) { if (result) {
setRoofs(newAddedRoofs) const updatePromises = [
setModuleSelectionData({ new Promise((resolve) => {
...moduleSelectionData, setRoofs(newAddedRoofs)
roofConstructions: newAddedRoofs.map((roof, index) => { resolve()
return {
roofIndex: roof.index,
addRoof: {
...moduleSelectionData.roofConstructions[index]?.addRoof,
...roof.addRoof,
},
trestle: {
...moduleSelectionData.roofConstructions[index]?.trestle,
...roof.trestle,
},
construction: {
...roof.construction,
...moduleSelectionData.roofConstructions[index]?.construction,
},
trestleDetail: {
...roof.trestleDetail,
},
}
}), }),
}) new Promise((resolve) => {
trestleTrigger({ setModuleSelectionData({
roofConstruction: newAddedRoofs.map((roof) => { ...moduleSelectionData,
return { roofConstructions: newAddedRoofs.map((roof, index) => ({
roofIndex: roof.index,
addRoof: {
...roof,
},
trestle: {
...selectedTrestle,
raftBaseCd: roof.raftBaseCd,
},
construction: {
...constructionList.find((construction) => trestleState.constTp === construction.constTp),
roofIndex: roof.index, roofIndex: roof.index,
setupCover: roof.cvrYn === 'Y', addRoof: {
setupSnowCover: roof.snowGdYn === 'Y', ...moduleSelectionData.roofConstructions[index]?.addRoof,
selectedIndex: roof.index, ...roof.addRoof,
}, },
} trestle: {
...moduleSelectionData.roofConstructions[index]?.trestle,
...roof.trestle,
},
construction: {
...roof.construction,
...moduleSelectionData.roofConstructions[index]?.construction,
},
trestleDetail: {
...roof.trestleDetail,
},
})),
})
resolve()
}), }),
}) new Promise((resolve) => {
trestleTrigger({
roofConstruction: newAddedRoofs.map((roof) => ({
roofIndex: roof.index,
addRoof: {
...roof,
},
trestle: {
...selectedTrestle,
raftBaseCd: roof.raftBaseCd,
},
construction: {
...constructionList.find((construction) => trestleState.constTp === construction.constTp),
roofIndex: roof.index,
setupCover: roof.cvrYn === 'Y',
setupSnowCover: roof.snowGdYn === 'Y',
selectedIndex: roof.index,
},
})),
})
resolve()
}),
]
await Promise.all(updatePromises)
} }
return result return result