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