From 468c7fda6fb11253c41087f8408e6eb641549098 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 13:03:23 +0900
Subject: [PATCH] =?UTF-8?q?moduleSelectionData=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/Placement.jsx | 4 +-
.../floor-plan/modal/basic/step/Trestle.jsx | 112 ++++++++++--------
src/hooks/module/useModuleTrestle.js | 20 ++--
4 files changed, 76 insertions(+), 64 deletions(-)
diff --git a/src/components/floor-plan/modal/basic/BasicSetting.jsx b/src/components/floor-plan/modal/basic/BasicSetting.jsx
index 2e8c471e..3dce3409 100644
--- a/src/components/floor-plan/modal/basic/BasicSetting.jsx
+++ b/src/components/floor-plan/modal/basic/BasicSetting.jsx
@@ -77,7 +77,7 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
const { trigger: orientationTrigger } = useCanvasPopupStatusController(1)
const { trigger: trestleTrigger } = useCanvasPopupStatusController(2)
const { trigger: placementTrigger } = useCanvasPopupStatusController(3)
- const roofsStore = useRecoilValue(roofsState)
+ const [roofsStore, setRoofsStore] = useRecoilState(roofsState)
// const { initEvent } = useContext(EventContext)
const { manualModuleSetup, autoModuleSetup, manualFlatroofModuleSetup, autoFlatroofModuleSetup, manualModuleLayoutSetup } =
@@ -95,6 +95,7 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
}),
)
+ console.log(roofsStore)
setModuleSelectionData({
...moduleSelectionData,
roofConstructions: roofsStore.map((roof) => {
@@ -255,6 +256,7 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
const trestleProps = {
roofs,
setRoofs,
+ setRoofsStore,
tabNum,
setTabNum,
moduleSelectionData,
diff --git a/src/components/floor-plan/modal/basic/step/Placement.jsx b/src/components/floor-plan/modal/basic/step/Placement.jsx
index 726d3c24..9e4fe5b8 100644
--- a/src/components/floor-plan/modal/basic/step/Placement.jsx
+++ b/src/components/floor-plan/modal/basic/step/Placement.jsx
@@ -352,8 +352,8 @@ const Placement = forwardRef((props, refs) => {
|
-
- {item.addRoof.roofMatlNmJp}
+
+ {item.addRoof?.roofMatlNmJp}
|
{moduleRowColArray[index]?.map((item) => (
diff --git a/src/components/floor-plan/modal/basic/step/Trestle.jsx b/src/components/floor-plan/modal/basic/step/Trestle.jsx
index a4ab7c27..180807e4 100644
--- a/src/components/floor-plan/modal/basic/step/Trestle.jsx
+++ b/src/components/floor-plan/modal/basic/step/Trestle.jsx
@@ -6,12 +6,11 @@ import { useMessage } from '@/hooks/useMessage'
import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom'
import { roofsState } from '@/store/roofAtom'
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
-import { isObjectNotEmpty } from '@/util/common-utils'
import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react'
import { useRecoilState, useRecoilValue } from 'recoil'
const Trestle = forwardRef((props, ref) => {
- const { tabNum, setTabNum, trestleTrigger, roofs, setRoofs, moduleSelectionData, setModuleSelectionData } = props
+ const { tabNum, setTabNum, trestleTrigger, roofs, setRoofs, moduleSelectionData, setModuleSelectionData, setRoofsStore } = props
const { getMessage } = useMessage()
// const [selectedTrestle, setSelectedTrestle] = useState()
const currentAngleType = useRecoilValue(currentAngleTypeSelector)
@@ -66,8 +65,6 @@ const Trestle = forwardRef((props, ref) => {
restoreModuleInstArea()
}, [roofs])
- useEffect(() => {}, [moduleSelectionData])
-
useEffect(() => {
if (flag && moduleSelectionData) {
if (JSON.stringify(tempModuleSelectionData.current) === JSON.stringify(moduleSelectionData)) {
@@ -82,7 +79,16 @@ const Trestle = forwardRef((props, ref) => {
setEavesMargin(selectedRoof?.eavesMargin ?? 0)
setRidgeMargin(selectedRoof?.ridgeMargin ?? 0)
setKerabaMargin(selectedRoof?.kerabaMargin ?? 0)
- dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, ...moduleSelectionData } })
+ setLengthBase(Math.round(selectedRoof?.lenBase ?? 0))
+ if (moduleSelectionData?.roofConstructions?.length >= selectedRoof.index + 1) {
+ const { construction, trestle, trestleDetail } = moduleSelectionData?.roofConstructions[selectedRoof.index]
+ dispatch({
+ type: 'SET_INITIALIZE',
+ roof: { common: moduleSelectionData.common, module: moduleSelectionData.module, construction, trestle, trestleDetail, ...selectedRoof },
+ })
+ } else {
+ dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, ...moduleSelectionData } })
+ }
}
}, [selectedRoof])
@@ -180,33 +186,6 @@ const Trestle = forwardRef((props, ref) => {
},
})
}
- const handleChangeRoofMaterial = (index) => {
- const newAddedRoofs = roofs.map((roof, i) => {
- if (i === selectedRoof.index) {
- return {
- ...selectedRoof,
- eavesMargin,
- ridgeMargin,
- kerabaMargin,
- roofIndex: roof.index,
- trestle: {
- lengthBase: lengthBase,
- ...selectedRaftBase,
- ...selectedTrestle,
- ...selectedConstMthd,
- ...selectedRoofBase,
- },
- construction: {
- ...constructionList.find((data) => data.constTp === trestleState.constTp),
- },
- trestleDetail: trestleDetail,
- }
- }
- return roof
- })
- setRoofs(newAddedRoofs)
- setSelectedRoof(newAddedRoofs[index])
- }
const handleConstruction = (index) => {
if (constructionList[index]?.constPossYn === 'Y') {
@@ -227,7 +206,7 @@ const Trestle = forwardRef((props, ref) => {
roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0),
constTp: constructionList[index].constTp,
mixMatlNo: selectedModules.mixMatlNo,
- workingWidth: selectedRoof?.length.toString() ?? '',
+ workingWidth: selectedRoof?.length?.toString() ?? '',
// snowGdPossYn: constructionList[index].snowGdPossYn,
// cvrYn: constructionList[index].cvrYn,
},
@@ -240,9 +219,38 @@ const Trestle = forwardRef((props, ref) => {
}
}
+ const handleChangeRoofMaterial = (index) => {
+ const newAddedRoofs = roofs.map((roof, i) => {
+ if (i === selectedRoof.index) {
+ return {
+ ...selectedRoof,
+ eavesMargin,
+ ridgeMargin,
+ kerabaMargin,
+ roofIndex: selectedRoof.index,
+ trestle: {
+ lengthBase: lengthBase,
+ ...selectedRaftBase,
+ ...selectedTrestle,
+ ...selectedConstMthd,
+ ...selectedRoofBase,
+ },
+ construction: {
+ ...constructionList.find((data) => data.constTp === trestleState.constTp),
+ },
+ trestleDetail: trestleDetail,
+ }
+ }
+ return roof
+ })
+ setRoofs(newAddedRoofs)
+ setSelectedRoof(newAddedRoofs[index])
+ console.log(newAddedRoofs)
+ }
+
const isComplete = async () => {
const newAddedRoofs = roofs.map((roof, i) => {
- if (i === selectedRoof?.roofIndex) {
+ if (i === selectedRoof?.index) {
return {
...selectedRoof,
eavesMargin,
@@ -286,7 +294,7 @@ const Trestle = forwardRef((props, ref) => {
})
const newRoofs = newAddedRoofs.map((roof) => {
- const { addRoof, trestle, construction, ...rest } = roof
+ const { addRoof, construction, trestle, trestleDetail, roofConstructions, ...rest } = roof
return rest
})
if (result) {
@@ -321,23 +329,25 @@ const Trestle = forwardRef((props, ref) => {
}),
new Promise((resolve) => {
- trestleTrigger({
- roofConstruction: newAddedRoofs.map((roof, index) => ({
+ const roofConstruction = newAddedRoofs.map((roof, index) => ({
+ roofIndex: roof.index,
+ addRoof: newRoofs[index],
+ trestle: {
+ ...roof.trestle,
+ raftBaseCd: roof.raftBaseCd,
+ },
+ construction: {
+ ...constructionList.find((construction) => newAddedRoofs[index].construction.constTp === construction.constTp),
roofIndex: roof.index,
- addRoof: newRoofs[index],
- 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,
- },
- })),
+ setupCover: roof.cvrYn === 'Y',
+ setupSnowCover: roof.snowGdYn === 'Y',
+ selectedIndex: roof.index,
+ },
+ }))
+ trestleTrigger({
+ roofConstruction,
})
+ setRoofsStore(roofConstruction)
resolve()
}),
]
@@ -383,7 +393,7 @@ const Trestle = forwardRef((props, ref) => {
setLengthBase(e.target.value)}
disabled={selectedRoof.lenAuth === 'R'}
/>
diff --git a/src/hooks/module/useModuleTrestle.js b/src/hooks/module/useModuleTrestle.js
index b6462887..70a57481 100644
--- a/src/hooks/module/useModuleTrestle.js
+++ b/src/hooks/module/useModuleTrestle.js
@@ -23,21 +23,21 @@ const trestleReducer = (state, action) => {
moduleTpCd: action.roof.module?.itemTp ?? '',
roofMatlCd: action.roof?.roofMatlCd ?? '',
raftBaseCd: action.roof?.raftBaseCd ?? null,
- trestleMkrCd: action.roof.roofConstructions[action.roof.index].trestle?.trestleMkrCd ?? null,
- constMthdCd: action.roof.roofConstructions[action.roof.index].trestle?.constMthdCd ?? null,
- constTp: action.roof.roofConstructions[action.roof.index].construction?.constTp ?? null,
- roofBaseCd: action.roof.roofConstructions[action.roof.index].trestle?.roofBaseCd ?? null,
+ trestleMkrCd: action.roof.trestle?.trestleMkrCd ?? null,
+ constMthdCd: action.roof.trestle?.constMthdCd ?? null,
+ constTp: action.roof.construction?.constTp ?? null,
+ roofBaseCd: action.roof.trestle?.roofBaseCd ?? null,
workingWidth: action.roof.workingWidth ?? 0,
- lengthBase: action.roof.roofConstructions[action.roof.index].addRoof?.length ?? 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,
- inclCd: action.roof.roofConstructions[action.roof.index].addRoof?.pitch ?? null,
- roofPitch: action.roof.roofConstructions[action.roof.index].addRoof?.roofPchBase ?? 0,
- eavesMargin: action.roof.roofConstructions[action.roof.index].addRoof?.eavesMargin ?? null,
- ridgeMargin: action.roof.roofConstructions[action.roof.index].addRoof?.ridgeMargin ?? null,
- kerabaMargin: action.roof.roofConstructions[action.roof.index].addRoof?.kerabaMargin ?? null,
+ inclCd: action.roof?.pitch ?? null,
+ roofPitch: action.roof?.roofPchBase ?? 0,
+ eavesMargin: action.roof?.eavesMargin ?? null,
+ ridgeMargin: action.roof?.ridgeMargin ?? null,
+ kerabaMargin: action.roof?.kerabaMargin ?? null,
}
default:
return state