From bc0655c8e23b76b7ef31741e7adb53b7cfc6f52d Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 7 Mar 2025 16:03:10 +0900 Subject: [PATCH] =?UTF-8?q?=EC=99=B8=EB=B2=BD=EC=84=A0=20=EC=86=8D?= =?UTF-8?q?=EC=84=B1=20=EC=84=A4=EC=A0=95=20=EC=99=84=EB=A3=8C=20=EB=AC=B8?= =?UTF-8?q?=EA=B5=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/floor-plan/FloorPlan.jsx | 2 +- src/hooks/roofcover/usePropertiesSetting.js | 75 ++++++++++++--------- src/locales/ja.json | 3 +- src/locales/ko.json | 3 +- 4 files changed, 47 insertions(+), 36 deletions(-) diff --git a/src/components/floor-plan/FloorPlan.jsx b/src/components/floor-plan/FloorPlan.jsx index 775d7678..18f3ea0d 100644 --- a/src/components/floor-plan/FloorPlan.jsx +++ b/src/components/floor-plan/FloorPlan.jsx @@ -18,7 +18,7 @@ export default function FloorPlan({ children }) { const { closeAll } = usePopup() const { selectedMenu, setSelectedMenu } = useCanvasMenu() - const { fetchSettings } = useCanvasSetting(false) + const { fetchSettings } = useCanvasSetting() const resetCurrentMenu = useResetRecoilState(currentMenuState) useEffect(() => { return () => { diff --git a/src/hooks/roofcover/usePropertiesSetting.js b/src/hooks/roofcover/usePropertiesSetting.js index 564ec3e8..4cd75bf6 100644 --- a/src/hooks/roofcover/usePropertiesSetting.js +++ b/src/hooks/roofcover/usePropertiesSetting.js @@ -11,6 +11,8 @@ import PropertiesSetting from '@/components/floor-plan/modal/outerlinesetting/Pr import RoofShapeSetting from '@/components/floor-plan/modal/roofShape/RoofShapeSetting' import RoofAllocationSetting from '@/components/floor-plan/modal/roofAllocation/RoofAllocationSetting' import { settingModalFirstOptionsState } from '@/store/settingAtom' +import { useSwal } from '@/hooks/useSwal' +import { useMessage } from '@/hooks/useMessage' // 외벽선 속성 설정 export function usePropertiesSetting(id) { @@ -25,6 +27,8 @@ export function usePropertiesSetting(id) { const { addPolygonByLines } = usePolygon() const { removeLine, hideLine } = useLine() const { addPopup, closePopup } = usePopup() + const { swalFire } = useSwal() + const { getMessage } = useMessage() useEffect(() => { const lines = canvas.getObjects().filter((obj) => obj.name === 'outerLine') @@ -125,47 +129,52 @@ export function usePropertiesSetting(id) { } const handleFix = () => { - const isClose = confirm('외벽선 속성 설정을 완료하시겠습니까?') - if (isClose) { - const lines = canvas.getObjects().filter((obj) => obj.name === 'outerLine') + swalFire({ + text: getMessage('outerLine.property.fix'), + type: 'confirm', + confirmFn: async () => { + const lines = canvas.getObjects().filter((obj) => obj.name === 'outerLine') + + const notSetAttributes = lines.filter((line) => !line.attributes?.type) + if (notSetAttributes.length > 0) { + // 세팅이 하나라도 안되어있으면 초기화 + lines.forEach((line) => { + line.set({ + stroke: '#000000', + strokeWidth: 4, + }) + }) + canvas.discardActiveObject() + // closePopup(id) + addPopup(id, 1, ) + return + } - const notSetAttributes = lines.filter((line) => !line.attributes?.type) - if (notSetAttributes.length > 0) { - // 세팅이 하나라도 안되어있으면 초기화 lines.forEach((line) => { line.set({ + attributes: line.attributes ? line.attributes : { offset: 0, type: LINE_TYPE.WALLLINE.WALL }, stroke: '#000000', strokeWidth: 4, }) + + hideLine(line) }) - canvas.discardActiveObject() - // closePopup(id) - addPopup(id, 1, ) + + const wall = addPolygonByLines(lines, { name: POLYGON_TYPE.WALL, fill: 'transparent', stroke: 'black' }) + + wall.lines = [...lines] + + const roof = drawRoofPolygon(wall) + + setPoints([]) + canvas.renderAll() + roof.drawHelpLine(settingModalFirstOptions) + addPopup(id, 1, ) + }, + denyFn: async () => { return - } - - lines.forEach((line) => { - line.set({ - attributes: line.attributes ? line.attributes : { offset: 0, type: LINE_TYPE.WALLLINE.WALL }, - stroke: '#000000', - strokeWidth: 4, - }) - - hideLine(line) - }) - - const wall = addPolygonByLines(lines, { name: POLYGON_TYPE.WALL, fill: 'transparent', stroke: 'black' }) - - wall.lines = [...lines] - - const roof = drawRoofPolygon(wall) - - setPoints([]) - canvas.renderAll() - roof.drawHelpLine(settingModalFirstOptions) - addPopup(id, 1, ) - return - } + }, + }) } const closeModal = (fn) => { diff --git a/src/locales/ja.json b/src/locales/ja.json index 86baf257..b9ff2970 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -1030,5 +1030,6 @@ "roof.is.not.selected": "屋根の選択をお願いします。", "length.direction.is.required": "長さと方向を入力します。", "canvas.infomation.text": "数字は [半角] 入力のみ可能です。", - "roof.exceed.count": "屋根材は4つまで選択可能です。" + "roof.exceed.count": "屋根材は4つまで選択可能です。", + "outerLine.property.fix": "外壁線の属性設定 を完了しますか?" } diff --git a/src/locales/ko.json b/src/locales/ko.json index 9252ac19..66a59ba4 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -1030,5 +1030,6 @@ "roof.is.not.selected": "지붕을 선택해주세요.", "length.direction.is.required": "길이와 방향을 입력하세요.", "canvas.infomation.text": "숫자는 [반각] 입력만 가능합니다.", - "roof.exceed.count": "지붕재는 4개까지 선택 가능합니다." + "roof.exceed.count": "지붕재는 4개까지 선택 가능합니다.", + "outerLine.property.fix": "외벽선 속성 설정을 완료하시겠습니까?" }