diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
index 539dbdf1..2052bff9 100644
--- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
+++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
@@ -19,7 +19,7 @@ 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 } = useRefFiles()
+ const { refImage, setRefImage, handleRefFile } = useRefFiles()
const { getMessage } = useMessage()
const { get, post } = useAxios()
@@ -490,7 +490,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
{getMessage('common.input.file.load')}
- setRefImage(e.target.files[0])} />
+ handleRefFile(e.target.files[0])} />
diff --git a/src/hooks/common/useRefFiles.js b/src/hooks/common/useRefFiles.js
index 8cb046d5..c241b1e0 100644
--- a/src/hooks/common/useRefFiles.js
+++ b/src/hooks/common/useRefFiles.js
@@ -1,11 +1,39 @@
import { useState } from 'react'
+import { convertDwgToPng } from '@/lib/cadAction'
+import { useSwal } from '@/hooks/useSwal'
export default function useRefFiles() {
- const [refImage, setRefImage] = useState(null)
const converterUrl = process.env.NEXT_PUBLIC_CONVERTER_API_URL
+ const [refImage, setRefImage] = useState(null)
+
+ const { swalFire } = useSwal()
+
+ 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 handleUploadRefFile = async (file) => {
+ const formData = new FormData()
+ formData.append('file', file)
+
+ await promisePost({ url: converterUrl, data: formData })
+ .then((res) => {
+ convertDwgToPng(res.data.Files[0].FileName, res.data.Files[0].FileData)
+ swalFire({ text: 'ํ์ผ ๋ณํ ์ฑ๊ณต' })
+ })
+ .catch((err) => {
+ swalFire({ text: 'ํ์ผ ๋ณํ ์คํจ', icon: 'error' })
+ })
+ }
return {
refImage,
setRefImage,
+ handleRefFile,
}
}