From d7b179638b3aa3383d853b7bea220eddf4c655da Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Tue, 7 Jan 2025 10:05:34 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A7=80=EB=B6=95=EB=A9=B4=20=ED=95=A0?= =?UTF-8?q?=EB=8B=B9=20=EC=8B=9C=20index=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/roofcover/useRoofAllocationSetting.js | 17 ++++++++++++----- src/store/settingAtom.js | 4 +--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index 0840dc2d..05a76e9b 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -108,15 +108,18 @@ export function useRoofAllocationSetting(id) { // 지붕재 오른쪽 마우스 클릭 후 단일로 지붕재 변경 필요한 경우 const handleSaveContext = () => { + const newRoofList = currentRoofList.map((roof, idx) => { + return { ...roof, index: idx } + }) setBasicSetting((prev) => { return { ...prev, - selectedRoofMaterial: currentRoofList.find((roof) => roof.selected), + selectedRoofMaterial: newRoofList.find((roof) => roof.selected), } }) - setRoofList(currentRoofList) - const selectedRoofMaterial = currentRoofList.find((roof) => roof.selected) + setRoofList(newRoofList) + const selectedRoofMaterial = newRoofList.find((roof) => roof.selected) setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial) closeAll() } @@ -180,14 +183,18 @@ export function useRoofAllocationSetting(id) { canvas.remove(wallLine) }) + const newRoofList = currentRoofList.map((roof, idx) => { + return { ...roof, index: idx } + }) + setBasicSetting((prev) => { return { ...prev, - selectedRoofMaterial: currentRoofList.find((roof) => roof.selected), + selectedRoofMaterial: newRoofList.find((roof) => roof.selected), } }) - setRoofList(currentRoofList) + setRoofList(newRoofList) const roofs = canvas.getObjects().filter((obj) => obj.name === 'roof') diff --git a/src/store/settingAtom.js b/src/store/settingAtom.js index 1b837fdd..305bcb57 100644 --- a/src/store/settingAtom.js +++ b/src/store/settingAtom.js @@ -224,9 +224,7 @@ export const roofMaterialsAtom = atom({ export const selectedRoofMaterialSelector = selector({ key: 'selectedRoofMaterialSelector', get: ({ get }) => { - const addedRoofs = get(addedRoofsState) - - return addedRoofs.find((roof) => roof.selected) + return get(basicSettingState).selectedRoofMaterial }, })