moduleSelectionData trestleDetail 없는 버그 수정

This commit is contained in:
김민식 2025-04-08 14:19:03 +09:00
parent 468c7fda6f
commit c35f3c1adb
3 changed files with 33 additions and 14 deletions

View File

@ -95,15 +95,15 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
}), }),
) )
console.log(roofsStore)
setModuleSelectionData({ setModuleSelectionData({
...moduleSelectionData, ...moduleSelectionData,
roofConstructions: roofsStore.map((roof) => { roofConstructions: roofsStore.map((roof) => {
return { return {
roofIndex: roof.index, roofIndex: roof.roofIndex,
addRoof: roof.addRoof, addRoof: roof.addRoof,
construction: roof.construction, construction: roof.construction,
trestle: roof.trestle, trestle: roof.trestle,
trestleDetail: roof.trestleDetail,
} }
}), }),
}) })

View File

@ -87,30 +87,48 @@ const Trestle = forwardRef((props, ref) => {
roof: { common: moduleSelectionData.common, module: moduleSelectionData.module, construction, trestle, trestleDetail, ...selectedRoof }, roof: { common: moduleSelectionData.common, module: moduleSelectionData.module, construction, trestle, trestleDetail, ...selectedRoof },
}) })
} else { } else {
dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, ...moduleSelectionData } }) dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, common: moduleSelectionData.common, module: moduleSelectionData.module } })
} }
} }
}, [selectedRoof]) }, [selectedRoof])
useEffect(() => { useEffect(() => {
if (raftBaseList.length > 0) setSelectedRaftBase(raftBaseList.find((raft) => raft.clCode === trestleState?.raftBaseCd) ?? null) if (raftBaseList.length > 0) {
setSelectedRaftBase(raftBaseList.find((raft) => raft.clCode === trestleState?.raftBaseCd) ?? null)
} else {
setSelectedRaftBase(null)
}
}, [raftBaseList]) }, [raftBaseList])
useEffect(() => { useEffect(() => {
if (trestleList.length > 0) setSelectedTrestle(trestleList.find((trestle) => trestle.trestleMkrCd === trestleState?.trestleMkrCd) ?? null) if (trestleList.length > 0) {
setSelectedTrestle(trestleList.find((trestle) => trestle.trestleMkrCd === trestleState?.trestleMkrCd) ?? null)
} else {
setSelectedTrestle(null)
}
}, [trestleList]) }, [trestleList])
useEffect(() => { useEffect(() => {
if (roofBaseList.length > 0) setSelectedRoofBase(roofBaseList.find((roofBase) => roofBase.roofBaseCd === trestleState?.roofBaseCd) ?? null) if (roofBaseList.length > 0) {
setSelectedRoofBase(roofBaseList.find((roofBase) => roofBase.roofBaseCd === trestleState?.roofBaseCd) ?? null)
} else {
setSelectedRoofBase(null)
}
}, [roofBaseList]) }, [roofBaseList])
useEffect(() => { useEffect(() => {
if (constMthdList.length > 0) setSelectedConstMthd(constMthdList.find((constMthd) => constMthd.constMthdCd === trestleState?.constMthdCd) ?? null) if (constMthdList.length > 0) {
setSelectedConstMthd(constMthdList.find((constMthd) => constMthd.constMthdCd === trestleState?.constMthdCd) ?? null)
} else {
setSelectedConstMthd(null)
}
}, [constMthdList]) }, [constMthdList])
useEffect(() => { useEffect(() => {
if (constructionList.length > 0) { if (constructionList.length > 0) {
setSelectedConstruction(constructionList.find((construction) => construction.constTp === trestleState?.construction?.constTp) ?? null) setSelectedConstruction(constructionList.find((construction) => construction.constTp === trestleState?.construction?.constTp) ?? null)
} else {
setSelectedConstruction(null)
} }
}, [constructionList]) }, [constructionList])
@ -301,7 +319,7 @@ const Trestle = forwardRef((props, ref) => {
setModuleSelectionData({ setModuleSelectionData({
...moduleSelectionData, ...moduleSelectionData,
roofConstructions: newAddedRoofs.map((roof, index) => ({ roofConstructions: newAddedRoofs.map((roof, index) => ({
roofIndex: roof.index, roofIndex: newRoofs[index].index,
trestle: roof.trestle, trestle: roof.trestle,
addRoof: newRoofs[index], addRoof: newRoofs[index],
construction: roof.construction, construction: roof.construction,
@ -312,7 +330,7 @@ const Trestle = forwardRef((props, ref) => {
tempModuleSelectionData.current = { tempModuleSelectionData.current = {
...moduleSelectionData, ...moduleSelectionData,
roofConstructions: newAddedRoofs.map((roof, index) => ({ roofConstructions: newAddedRoofs.map((roof, index) => ({
roofIndex: roof.index, roofIndex: newRoofs[index].index,
trestle: roof.trestle, trestle: roof.trestle,
addRoof: newRoofs[index], addRoof: newRoofs[index],
construction: roof.construction, construction: roof.construction,
@ -330,7 +348,7 @@ const Trestle = forwardRef((props, ref) => {
new Promise((resolve) => { new Promise((resolve) => {
const roofConstruction = newAddedRoofs.map((roof, index) => ({ const roofConstruction = newAddedRoofs.map((roof, index) => ({
roofIndex: roof.index, roofIndex: newRoofs[index].index,
addRoof: newRoofs[index], addRoof: newRoofs[index],
trestle: { trestle: {
...roof.trestle, ...roof.trestle,
@ -343,6 +361,7 @@ const Trestle = forwardRef((props, ref) => {
setupSnowCover: roof.snowGdYn === 'Y', setupSnowCover: roof.snowGdYn === 'Y',
selectedIndex: roof.index, selectedIndex: roof.index,
}, },
trestleDetail: roof.trestleDetail,
})) }))
trestleTrigger({ trestleTrigger({
roofConstruction, roofConstruction,

View File

@ -29,10 +29,10 @@ const trestleReducer = (state, action) => {
roofBaseCd: action.roof.trestle?.roofBaseCd ?? null, roofBaseCd: action.roof.trestle?.roofBaseCd ?? null,
workingWidth: action.roof.workingWidth ?? 0, workingWidth: action.roof.workingWidth ?? 0,
lengthBase: action.roof?.length ?? 0, lengthBase: action.roof?.length ?? 0,
illuminationTp: action.roof.common.illuminationTp ?? null, illuminationTp: action.roof.common?.illuminationTp ?? null,
instHt: action.roof.common.instHt ?? null, instHt: action.roof.common?.instHt ?? null,
stdWindSpeed: action.roof.common.stdWindSpeed ?? null, stdWindSpeed: action.roof.common?.stdWindSpeed ?? null,
stdSnowLd: action.roof.common.stdSnowLd ?? null, stdSnowLd: action.roof.common?.stdSnowLd ?? null,
inclCd: action.roof?.pitch ?? null, inclCd: action.roof?.pitch ?? null,
roofPitch: action.roof?.roofPchBase ?? 0, roofPitch: action.roof?.roofPchBase ?? 0,
eavesMargin: action.roof?.eavesMargin ?? null, eavesMargin: action.roof?.eavesMargin ?? null,