From 079f3a7ff2f002db998ec3faa974704a0574c400 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Wed, 9 Jul 2025 18:13:53 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B3=B4=EC=A1=B0=EC=84=A0=20=EC=A7=80?= =?UTF-8?q?=EB=B6=95=EC=9E=AC=20=ED=95=A0=EB=8B=B9=20=EC=8B=9C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roofcover/useRoofAllocationSetting.js | 49 ++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index dfe4c87d..db39ac3a 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -1,28 +1,25 @@ -import { useRecoilState, useRecoilValue, useResetRecoilState, useSetRecoilState } from 'recoil' -import { canvasState, currentAngleTypeSelector, currentMenuState, currentObjectState } from '@/store/canvasAtom' -import { useContext, useEffect, useRef, useState } from 'react' +import { useRecoilState, useRecoilValue, useResetRecoilState } from 'recoil' +import { canvasState, currentAngleTypeSelector, currentObjectState } from '@/store/canvasAtom' +import { useContext, useEffect, useState } from 'react' import { useAxios } from '@/hooks/useAxios' import { useSwal } from '@/hooks/useSwal' import { usePolygon } from '@/hooks/usePolygon' import { - correntObjectNoState, addedRoofsState, basicSettingState, + correntObjectNoState, + corridorDimensionSelector, roofDisplaySelector, roofMaterialsSelector, selectedRoofMaterialSelector, - settingModalFirstOptionsState, - corridorDimensionSelector, } from '@/store/settingAtom' import { usePopup } from '@/hooks/usePopup' import { POLYGON_TYPE } from '@/common/common' import { v4 as uuidv4 } from 'uuid' import ActualSizeSetting from '@/components/floor-plan/modal/roofAllocation/ActualSizeSetting' import { useMessage } from '@/hooks/useMessage' -import useMenu from '@/hooks/common/useMenu' import { useCanvasMenu } from '@/hooks/common/useCanvasMenu' import { useRoofFn } from '@/hooks/common/useRoofFn' -import { ROOF_MATERIAL_LAYOUT } from '@/components/floor-plan/modal/placementShape/PlacementShapeSetting' import { globalLocaleStore } from '@/store/localeAtom' import { getChonByDegree, getDegreeByChon } from '@/util/canvas-util' import { moduleSelectionDataState } from '@/store/selectedModuleOptions' @@ -44,8 +41,10 @@ export function useRoofAllocationSetting(id) { const roofMaterials = useRecoilValue(roofMaterialsSelector) const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector) const [basicSetting, setBasicSetting] = useRecoilState(basicSettingState) - const [currentRoofMaterial, setCurrentRoofMaterial] = useState(roofMaterials[0]) /** 팝업 내 기준 지붕재 */ - const [roofList, setRoofList] = useRecoilState(addedRoofsState) /** 배치면 초기설정에서 선택한 지붕재 배열 */ + const [currentRoofMaterial, setCurrentRoofMaterial] = useState(roofMaterials[0]) + /** 팝업 내 기준 지붕재 */ + const [roofList, setRoofList] = useRecoilState(addedRoofsState) + /** 배치면 초기설정에서 선택한 지붕재 배열 */ const [editingLines, setEditingLines] = useState([]) const [currentRoofList, setCurrentRoofList] = useState([]) const currentAngleType = useRecoilValue(currentAngleTypeSelector) @@ -178,7 +177,11 @@ export function useRoofAllocationSetting(id) { selectedRoofMaterial: selectRoofs.find((roof) => roof.selected), }) - setBasicInfo({ planNo: '' + res[0].planNo, roofSizeSet: '' + res[0].roofSizeSet, roofAngleSet: '' + res[0].roofAngleSet }) + setBasicInfo({ + planNo: '' + res[0].planNo, + roofSizeSet: '' + res[0].roofSizeSet, + roofAngleSet: '' + res[0].roofAngleSet, + }) }) } catch (error) { console.error('Data fetching error:', error) @@ -339,11 +342,18 @@ export function useRoofAllocationSetting(id) { * 지붕면 할당 */ const handleAlloc = () => { - if (!checkInnerLines()) { - apply() - } else { - swalFire({ type: 'alert', icon: 'error', text: getMessage('modal.roof.allocation.auxiliary.size.form') }) - } + const roofBases = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF) // roofPolygon.innerLines + roofBases.forEach((roof) => { + if (roof.separatePolygon.length === 0) { + roof.innerLines.forEach((line) => { + if ((!line.attributes.actualSize || line.attributes?.actualSize === 0) && line.length > 1) { + line.set({ attributes: { ...line.attributes, actualSize: line.attributes.planeSize } }) + } + }) + } + }) + + apply() } /** @@ -546,7 +556,12 @@ export function useRoofAllocationSetting(id) { const newRoofList = currentRoofList.map((roof, idx) => { if (idx === index) { const result = - currentAngleType === 'slope' ? { pitch: value, angle: getDegreeByChon(value) } : { pitch: getChonByDegree(value), angle: value } + currentAngleType === 'slope' + ? { + pitch: value, + angle: getDegreeByChon(value), + } + : { pitch: getChonByDegree(value), angle: value } return { ...roof, ...result } } return roof