From c35f3c1adb8f081ac5da430b0c7d5efd2119e73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=8B=9D?= <43837214+Minsiki@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:19:03 +0900 Subject: [PATCH] =?UTF-8?q?moduleSelectionData=20trestleDetail=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../floor-plan/modal/basic/BasicSetting.jsx | 4 +-- .../floor-plan/modal/basic/step/Trestle.jsx | 35 ++++++++++++++----- src/hooks/module/useModuleTrestle.js | 8 ++--- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/components/floor-plan/modal/basic/BasicSetting.jsx b/src/components/floor-plan/modal/basic/BasicSetting.jsx index 3dce3409..7245f7b2 100644 --- a/src/components/floor-plan/modal/basic/BasicSetting.jsx +++ b/src/components/floor-plan/modal/basic/BasicSetting.jsx @@ -95,15 +95,15 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) { }), ) - console.log(roofsStore) setModuleSelectionData({ ...moduleSelectionData, roofConstructions: roofsStore.map((roof) => { return { - roofIndex: roof.index, + roofIndex: roof.roofIndex, addRoof: roof.addRoof, construction: roof.construction, trestle: roof.trestle, + trestleDetail: roof.trestleDetail, } }), }) diff --git a/src/components/floor-plan/modal/basic/step/Trestle.jsx b/src/components/floor-plan/modal/basic/step/Trestle.jsx index 180807e4..fdfc8db1 100644 --- a/src/components/floor-plan/modal/basic/step/Trestle.jsx +++ b/src/components/floor-plan/modal/basic/step/Trestle.jsx @@ -87,30 +87,48 @@ const Trestle = forwardRef((props, ref) => { roof: { common: moduleSelectionData.common, module: moduleSelectionData.module, construction, trestle, trestleDetail, ...selectedRoof }, }) } else { - dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, ...moduleSelectionData } }) + dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, common: moduleSelectionData.common, module: moduleSelectionData.module } }) } } }, [selectedRoof]) 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]) 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]) 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]) 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]) useEffect(() => { if (constructionList.length > 0) { setSelectedConstruction(constructionList.find((construction) => construction.constTp === trestleState?.construction?.constTp) ?? null) + } else { + setSelectedConstruction(null) } }, [constructionList]) @@ -301,7 +319,7 @@ const Trestle = forwardRef((props, ref) => { setModuleSelectionData({ ...moduleSelectionData, roofConstructions: newAddedRoofs.map((roof, index) => ({ - roofIndex: roof.index, + roofIndex: newRoofs[index].index, trestle: roof.trestle, addRoof: newRoofs[index], construction: roof.construction, @@ -312,7 +330,7 @@ const Trestle = forwardRef((props, ref) => { tempModuleSelectionData.current = { ...moduleSelectionData, roofConstructions: newAddedRoofs.map((roof, index) => ({ - roofIndex: roof.index, + roofIndex: newRoofs[index].index, trestle: roof.trestle, addRoof: newRoofs[index], construction: roof.construction, @@ -330,7 +348,7 @@ const Trestle = forwardRef((props, ref) => { new Promise((resolve) => { const roofConstruction = newAddedRoofs.map((roof, index) => ({ - roofIndex: roof.index, + roofIndex: newRoofs[index].index, addRoof: newRoofs[index], trestle: { ...roof.trestle, @@ -343,6 +361,7 @@ const Trestle = forwardRef((props, ref) => { setupSnowCover: roof.snowGdYn === 'Y', selectedIndex: roof.index, }, + trestleDetail: roof.trestleDetail, })) trestleTrigger({ roofConstruction, diff --git a/src/hooks/module/useModuleTrestle.js b/src/hooks/module/useModuleTrestle.js index 70a57481..ff6acb17 100644 --- a/src/hooks/module/useModuleTrestle.js +++ b/src/hooks/module/useModuleTrestle.js @@ -29,10 +29,10 @@ const trestleReducer = (state, action) => { roofBaseCd: action.roof.trestle?.roofBaseCd ?? null, workingWidth: action.roof.workingWidth ?? 0, lengthBase: action.roof?.length ?? 0, - illuminationTp: action.roof.common.illuminationTp ?? null, - instHt: action.roof.common.instHt ?? null, - stdWindSpeed: action.roof.common.stdWindSpeed ?? null, - stdSnowLd: action.roof.common.stdSnowLd ?? null, + illuminationTp: action.roof.common?.illuminationTp ?? null, + instHt: action.roof.common?.instHt ?? null, + stdWindSpeed: action.roof.common?.stdWindSpeed ?? null, + stdSnowLd: action.roof.common?.stdSnowLd ?? null, inclCd: action.roof?.pitch ?? null, roofPitch: action.roof?.roofPchBase ?? 0, eavesMargin: action.roof?.eavesMargin ?? null,