diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
index 2052bff9..e6f80941 100644
--- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
+++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
@@ -1,15 +1,20 @@
-import SizeGuide from '@/components/floor-plan/modal/placementShape/SizeGuide'
-import MaterialGuide from '@/components/floor-plan/modal/placementShape/MaterialGuide'
-import WithDraggable from '@/components/common/draggable/WithDraggable'
+import { useContext, useEffect, useState } from 'react'
import { useRecoilState } from 'recoil'
-import { Fragment, useEffect, useState } from 'react'
+
import { canvasSettingState } from '@/store/canvasAtom'
+import { basicSettingState } from '@/store/settingAtom'
+
import { useMessage } from '@/hooks/useMessage'
import { useAxios } from '@/hooks/useAxios'
import { useSwal } from '@/hooks/useSwal'
import { usePopup } from '@/hooks/usePopup'
-import { basicSettingState } from '@/store/settingAtom'
import useRefFiles from '@/hooks/common/useRefFiles'
+import { usePlan } from '@/hooks/usePlan'
+
+import SizeGuide from '@/components/floor-plan/modal/placementShape/SizeGuide'
+import MaterialGuide from '@/components/floor-plan/modal/placementShape/MaterialGuide'
+import WithDraggable from '@/components/common/draggable/WithDraggable'
+import { SessionContext } from '@/app/SessionProvider'
export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, setShowPlaceShapeModal }) {
const [objectNo, setObjectNo] = useState('test123241008001') // 후에 삭제 필요
@@ -19,7 +24,18 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
const [canvasSetting, setCanvasSetting] = useRecoilState(canvasSettingState)
const { closePopup } = usePopup()
const [basicSetting, setBasicSettings] = useRecoilState(basicSettingState)
- const { refImage, setRefImage, handleRefFile } = useRefFiles()
+ const {
+ refImage,
+ setRefImage,
+ handleRefFile,
+ refFileMethod,
+ setRefFileMethod,
+ handleRefFileMethod,
+ mapPositionAddress,
+ setMapPositionAddress,
+ handleFileDelete,
+ } = useRefFiles()
+ const { currentCanvasPlan } = usePlan()
const { getMessage } = useMessage()
const { get, post } = useAxios()
@@ -484,7 +500,70 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
| {getMessage('common.input.file')} |
-
+
+
+ {/* 파일 불러오기 */}
+ {refFileMethod === '1' && (
+
+ )}
+
+ {/* 주소 불러오기 */}
+ {refFileMethod === '2' && (
+
+ setMapPositionAddress(e.target.value)}
+ />
+
+
+
+
+
+
+ )}
+ {/*
+ */}
|
diff --git a/src/hooks/common/useRefFiles.js b/src/hooks/common/useRefFiles.js
index c241b1e0..a1971f7b 100644
--- a/src/hooks/common/useRefFiles.js
+++ b/src/hooks/common/useRefFiles.js
@@ -1,22 +1,46 @@
import { useState } from 'react'
-import { convertDwgToPng } from '@/lib/cadAction'
import { useSwal } from '@/hooks/useSwal'
+import { usePlan } from '@/hooks/usePlan'
+import { convertDwgToPng } from '@/lib/cadAction'
export default function useRefFiles() {
const converterUrl = process.env.NEXT_PUBLIC_CONVERTER_API_URL
const [refImage, setRefImage] = useState(null)
+ const [refFileMethod, setRefFileMethod] = useState('1')
+ const [mapPositionAddress, setMapPositionAddress] = useState('')
const { swalFire } = useSwal()
+ const { currentCanvasPlan, setCurrentCanvasPlan } = usePlan()
+ /**
+ * 파일 불러오기 버튼 컨트롤
+ * @param {*} file
+ */
const handleRefFile = (file) => {
setRefImage(file)
- console.log('🚀 ~ handleRefFile ~ file:', file)
file.name.split('.').pop() === 'dwg' ? handleUploadRefFile(file) : () => {}
- console.log("🚀 ~ handleRefFile ~ file.name.split('.').pop():", file.name.split('.').pop())
// handleUploadRefFile(file)
}
- // RefFile이 캐드 도면 파일일 경우 변환하여 이미지로 저장
+ /**
+ * 파일 삭제
+ */
+ const handleFileDelete = () => {
+ setRefImage(null)
+ setCurrentCanvasPlan((prev) => ({ ...prev, bgFileName: null }))
+ }
+
+ /**
+ * 주소 삭제
+ */
+ const handleAddressDelete = () => {
+ setCurrentCanvasPlan((prev) => ({ ...prev, mapPositionAddress: null }))
+ }
+
+ /**
+ * RefFile이 캐드 도면 파일일 경우 변환하여 이미지로 저장
+ * @param {*} file
+ */
const handleUploadRefFile = async (file) => {
const formData = new FormData()
formData.append('file', file)
@@ -31,9 +55,24 @@ export default function useRefFiles() {
})
}
+ /**
+ * 라디오 버튼 컨트롤
+ * @param {*} e
+ */
+ const handleRefFileMethod = (e) => {
+ setRefFileMethod(e.target.value)
+ }
+
return {
refImage,
setRefImage,
handleRefFile,
+ refFileMethod,
+ setRefFileMethod,
+ mapPositionAddress,
+ setMapPositionAddress,
+ handleRefFileMethod,
+ handleFileDelete,
+ handleAddressDelete,
}
}
diff --git a/src/hooks/usePlan.js b/src/hooks/usePlan.js
index c1708a37..5b78fd7c 100644
--- a/src/hooks/usePlan.js
+++ b/src/hooks/usePlan.js
@@ -190,7 +190,7 @@ export function usePlan() {
canvasStatus: dbToCanvasFormat(item.canvasStatus),
isCurrent: false,
bgImageName: item.bgImageName,
- bgCadfileName: item.bgCadfileName,
+ mapPositionAddress: item.mapPositionAddress,
})),
)
}