👽chore: 소스코드 정리
- 사용하지 않는 코드 삭제 - 사용되지 않은 임포트 구문 삭제
This commit is contained in:
parent
dce3a65ba2
commit
12ff356640
@ -3,32 +3,12 @@
|
|||||||
import { createContext, useEffect, useState } from 'react'
|
import { createContext, useEffect, useState } from 'react'
|
||||||
import { useLocalStorage } from 'usehooks-ts'
|
import { useLocalStorage } from 'usehooks-ts'
|
||||||
|
|
||||||
// export const GlobalDataContext = createContext({
|
|
||||||
// managementState: {},
|
|
||||||
// setManagementState: () => {},
|
|
||||||
// managementStateLoaded: null,
|
|
||||||
// })
|
|
||||||
export const GlobalDataContext = createContext(null)
|
export const GlobalDataContext = createContext(null)
|
||||||
|
|
||||||
const GlobalDataProvider = ({ children }) => {
|
const GlobalDataProvider = ({ children }) => {
|
||||||
const [managementState, setManagementState] = useState(null)
|
const [managementState, setManagementState] = useState(null)
|
||||||
// TODO: 임시 조치이며 개발 완료시 삭제 예정 -> 잊지말기...
|
|
||||||
const [managementStateLoaded, setManagementStateLoaded] = useLocalStorage('managementStateLoaded', null)
|
const [managementStateLoaded, setManagementStateLoaded] = useLocalStorage('managementStateLoaded', null)
|
||||||
|
|
||||||
// const pathname = usePathname()
|
|
||||||
// const setCorrentObjectNo = useSetRecoilState(correntObjectNoState)
|
|
||||||
// const searchParams = useSearchParams()
|
|
||||||
// const objectNo = searchParams.get('objectNo')
|
|
||||||
// const pid = searchParams.get('pid')
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (pathname === '/floor-plan') {
|
|
||||||
// if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
|
|
||||||
// notFound()
|
|
||||||
// }
|
|
||||||
// setCorrentObjectNo(objectNo)
|
|
||||||
// }
|
|
||||||
// }, [pathname])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (managementState !== null) {
|
if (managementState !== null) {
|
||||||
setManagementStateLoaded(managementState)
|
setManagementStateLoaded(managementState)
|
||||||
|
|||||||
@ -15,9 +15,7 @@ export const QcastContext = createContext({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const QcastProvider = ({ children }) => {
|
export const QcastProvider = ({ children }) => {
|
||||||
const [planSave, setPlanSave] = useState(false)
|
|
||||||
const [isGlobalLoading, setIsGlobalLoading] = useState(true)
|
const [isGlobalLoading, setIsGlobalLoading] = useState(true)
|
||||||
const { commonCode, findCommonCode } = useCommonCode()
|
|
||||||
|
|
||||||
const [qcastState, setQcastState] = useState({
|
const [qcastState, setQcastState] = useState({
|
||||||
saleStoreId: '',
|
saleStoreId: '',
|
||||||
@ -27,11 +25,6 @@ export const QcastProvider = ({ children }) => {
|
|||||||
businessChargerMail: null,
|
businessChargerMail: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// console.log('commonCode', commonCode)
|
|
||||||
// console.log(findCommonCode(113600))
|
|
||||||
// }, [commonCode, findCommonCode])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<QcastContext.Provider value={{ qcastState, setQcastState, isGlobalLoading, setIsGlobalLoading }}>
|
<QcastContext.Provider value={{ qcastState, setQcastState, isGlobalLoading, setIsGlobalLoading }}>
|
||||||
|
|||||||
@ -26,8 +26,6 @@ export default function InitSettingsModal(props) {
|
|||||||
|
|
||||||
const { get, post } = useAxios()
|
const { get, post } = useAxios()
|
||||||
|
|
||||||
//const { get, post } = useAxios()
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${objectNo}` }).then((res) => {
|
get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${objectNo}` }).then((res) => {
|
||||||
if (res.length == 0) return
|
if (res.length == 0) return
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||||
import useSWR from 'swr'
|
|
||||||
import useSWRMutation from 'swr/mutation'
|
import useSWRMutation from 'swr/mutation'
|
||||||
import { useAxios } from '../useAxios'
|
import { useAxios } from '../useAxios'
|
||||||
import { unescapeString } from '@/util/common-utils'
|
import { unescapeString } from '@/util/common-utils'
|
||||||
import { moduleSelectionDataState, moduleSelectionTotalState, selectedModuleOptionsState, selectedModuleState } from '@/store/selectedModuleOptions'
|
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
|
||||||
import { compasDegAtom } from '@/store/orientationAtom'
|
import { compasDegAtom } from '@/store/orientationAtom'
|
||||||
import { canvasState, currentCanvasPlanState } from '@/store/canvasAtom'
|
import { canvasState, currentCanvasPlanState } from '@/store/canvasAtom'
|
||||||
import { POLYGON_TYPE } from '@/common/common'
|
import { POLYGON_TYPE } from '@/common/common'
|
||||||
import { DateRangePickerField } from '@nextui-org/react'
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 캔버스 팝업 상태 관리
|
||||||
|
* @param {*} param
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function useCanvasPopupStatusController(param = 1) {
|
export function useCanvasPopupStatusController(param = 1) {
|
||||||
const popupType = parseInt(param)
|
const popupType = parseInt(param)
|
||||||
|
|
||||||
@ -20,7 +23,6 @@ export function useCanvasPopupStatusController(param = 1) {
|
|||||||
const { get, promiseGet, getFetcher, postFetcher } = useAxios()
|
const { get, promiseGet, getFetcher, postFetcher } = useAxios()
|
||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
const currentCanvasPlan = useRecoilValue(currentCanvasPlanState)
|
const currentCanvasPlan = useRecoilValue(currentCanvasPlanState)
|
||||||
// console.log('🚀 ~ Orientation ~ currentCanvasPlan:', currentCanvasPlan)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 팝업 상태 조회
|
* 팝업 상태 조회
|
||||||
@ -28,15 +30,6 @@ export function useCanvasPopupStatusController(param = 1) {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const getModuleSelection = async (popupTypeParam) => {
|
const getModuleSelection = async (popupTypeParam) => {
|
||||||
// const {
|
|
||||||
// data: popupStatus,
|
|
||||||
// error,
|
|
||||||
// isLoading,
|
|
||||||
// } = useSWR(
|
|
||||||
// `/api/v1/canvas-popup-status?objectNo=${currentCanvasPlan.objectNo}&planNo=${currentCanvasPlan.planNo}&popupType=${popupTypeParam}`,
|
|
||||||
// getFetcher,
|
|
||||||
// )
|
|
||||||
|
|
||||||
const result = await promiseGet({
|
const result = await promiseGet({
|
||||||
url: `/api/v1/canvas-popup-status?objectNo=${currentCanvasPlan.objectNo}&planNo=${currentCanvasPlan.planNo}&popupType=${popupTypeParam}`,
|
url: `/api/v1/canvas-popup-status?objectNo=${currentCanvasPlan.objectNo}&planNo=${currentCanvasPlan.planNo}&popupType=${popupTypeParam}`,
|
||||||
})
|
})
|
||||||
@ -59,7 +52,6 @@ export function useCanvasPopupStatusController(param = 1) {
|
|||||||
for (let i = 1; i < 3; i++) {
|
for (let i = 1; i < 3; i++) {
|
||||||
const result = await getModuleSelection(i)
|
const result = await getModuleSelection(i)
|
||||||
console.log('🚀 ~ handleModuleSelectionTotal ~ result:', result)
|
console.log('🚀 ~ handleModuleSelectionTotal ~ result:', result)
|
||||||
// setModuleSelectionTotal((prev) => ({ ...prev, [i]: JSON.parse(unescapeString(result.popupStatus)) }))
|
|
||||||
if (!result.objectNo) return
|
if (!result.objectNo) return
|
||||||
if (i === 1) {
|
if (i === 1) {
|
||||||
setCompasDeg(result.popupStatus)
|
setCompasDeg(result.popupStatus)
|
||||||
@ -77,49 +69,6 @@ export function useCanvasPopupStatusController(param = 1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (popupStatus) {
|
|
||||||
// switch (parseInt(popupStatus?.popupType)) {
|
|
||||||
// case 1:
|
|
||||||
// setCompasDeg(popupStatus.popupStatus)
|
|
||||||
// break
|
|
||||||
// case 2:
|
|
||||||
// setModuleSelectionDataStore(JSON.parse(unescapeString(popupStatus.popupStatus)))
|
|
||||||
// break
|
|
||||||
// case 3:
|
|
||||||
// break
|
|
||||||
// case 4:
|
|
||||||
// break
|
|
||||||
// case 5:
|
|
||||||
// break
|
|
||||||
// case 6:
|
|
||||||
// break
|
|
||||||
// default:
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// switch (popupType) {
|
|
||||||
// case 1:
|
|
||||||
// setCompasDeg(0)
|
|
||||||
// break
|
|
||||||
// case 2:
|
|
||||||
// setModuleSelectionDataStore({
|
|
||||||
// common: {},
|
|
||||||
// roofConstructions: [],
|
|
||||||
// })
|
|
||||||
// break
|
|
||||||
// case 3:
|
|
||||||
// break
|
|
||||||
// case 4:
|
|
||||||
// break
|
|
||||||
// case 5:
|
|
||||||
// break
|
|
||||||
// case 6:
|
|
||||||
// break
|
|
||||||
// default:
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }, [popupStatus])
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 팝업 상태 저장
|
* 팝업 상태 저장
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -15,7 +15,6 @@ export function useCommonUtils() {
|
|||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
const wordDisplay = useRecoilValue(wordDisplaySelector)
|
const wordDisplay = useRecoilValue(wordDisplaySelector)
|
||||||
const { addCanvasMouseEventListener, addDocumentEventListener, initEvent } = useEvent()
|
const { addCanvasMouseEventListener, addDocumentEventListener, initEvent } = useEvent()
|
||||||
// const { addCanvasMouseEventListener, addDocumentEventListener, initEvent } = useContext(EventContext)
|
|
||||||
const dimensionSettings = useRecoilValue(dimensionLineSettingsState)
|
const dimensionSettings = useRecoilValue(dimensionLineSettingsState)
|
||||||
const dimensionLineTextFont = useRecoilValue(fontSelector('dimensionLineText'))
|
const dimensionLineTextFont = useRecoilValue(fontSelector('dimensionLineText'))
|
||||||
const commonTextFont = useRecoilValue(fontSelector('commonText'))
|
const commonTextFont = useRecoilValue(fontSelector('commonText'))
|
||||||
@ -24,7 +23,6 @@ export function useCommonUtils() {
|
|||||||
const { drawDirectionArrow, addLengthText } = usePolygon()
|
const { drawDirectionArrow, addLengthText } = usePolygon()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// initEvent()
|
|
||||||
if (commonUtils.text) {
|
if (commonUtils.text) {
|
||||||
commonTextMode()
|
commonTextMode()
|
||||||
} else if (commonUtils.dimension) {
|
} else if (commonUtils.dimension) {
|
||||||
@ -247,15 +245,12 @@ export function useCommonUtils() {
|
|||||||
name: 'extendLine',
|
name: 'extendLine',
|
||||||
id: uuid,
|
id: uuid,
|
||||||
})
|
})
|
||||||
// canvas.add(extendLine)
|
|
||||||
groupObjects.push(extendLine)
|
groupObjects.push(extendLine)
|
||||||
})
|
})
|
||||||
|
|
||||||
const dimensionPosition = calcDimensionPosition(lineDirection, p1CenterX, p1CenterY, p2CenterX, p2CenterY)
|
const dimensionPosition = calcDimensionPosition(lineDirection, p1CenterX, p1CenterY, p2CenterX, p2CenterY)
|
||||||
const arrow1 = createDimensionArrow(dimensionPosition.paddingX, dimensionPosition.paddingY, dimensionPosition.angle1, uuid) // 반대 방향 화살표
|
const arrow1 = createDimensionArrow(dimensionPosition.paddingX, dimensionPosition.paddingY, dimensionPosition.angle1, uuid) // 반대 방향 화살표
|
||||||
const arrow2 = createDimensionArrow(dimensionPosition.paddingX2, dimensionPosition.paddingY2, dimensionPosition.angle2, uuid) // 정방향 화살표
|
const arrow2 = createDimensionArrow(dimensionPosition.paddingX2, dimensionPosition.paddingY2, dimensionPosition.angle2, uuid) // 정방향 화살표
|
||||||
// canvas.add(arrow1)
|
|
||||||
// canvas.add(arrow2)
|
|
||||||
|
|
||||||
groupObjects.push(arrow1, arrow2)
|
groupObjects.push(arrow1, arrow2)
|
||||||
|
|
||||||
@ -310,23 +305,6 @@ export function useCommonUtils() {
|
|||||||
// 캔버스 다시 그리기
|
// 캔버스 다시 그리기
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
// addCanvasMouseEventListener('object:moving', function (e) {
|
|
||||||
// const obj = e.target
|
|
||||||
|
|
||||||
// if (obj.left < minX) {
|
|
||||||
// obj.left = minX
|
|
||||||
// }
|
|
||||||
// if (obj.left + obj.width > maxX) {
|
|
||||||
// obj.left = maxX - obj.width
|
|
||||||
// }
|
|
||||||
// if (obj.top < minY) {
|
|
||||||
// obj.top = minY
|
|
||||||
// }
|
|
||||||
// if (obj.top + obj.height > maxY) {
|
|
||||||
// obj.top = maxY - obj.height
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,16 @@
|
|||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
import { useRecoilState } from 'recoil'
|
||||||
|
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import { useAxios } from '../useAxios'
|
import { useAxios } from '../useAxios'
|
||||||
import { canvasState, currentCanvasPlanState } from '@/store/canvasAtom'
|
import { currentCanvasPlanState } from '@/store/canvasAtom'
|
||||||
import { convertDwgToPng, removeImage, writeImageBuffer, readImage } from '@/lib/fileAction'
|
|
||||||
import { useCanvas } from '@/hooks/useCanvas'
|
import { useCanvas } from '@/hooks/useCanvas'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 배경 이미지 관리
|
||||||
|
* 도면에 배경이미지를 로딩하는 기능을 제공
|
||||||
|
* @returns {object}
|
||||||
|
*/
|
||||||
export function useRefFiles() {
|
export function useRefFiles() {
|
||||||
const converterUrl = process.env.NEXT_PUBLIC_CONVERTER_API_URL
|
const converterUrl = process.env.NEXT_PUBLIC_CONVERTER_API_URL
|
||||||
const [refImage, setRefImage] = useState(null)
|
const [refImage, setRefImage] = useState(null)
|
||||||
@ -15,33 +19,18 @@ export function useRefFiles() {
|
|||||||
const [currentBgImage, setCurrentBgImage] = useState(null)
|
const [currentBgImage, setCurrentBgImage] = useState(null)
|
||||||
const queryRef = useRef(null)
|
const queryRef = useRef(null)
|
||||||
const [currentCanvasPlan, setCurrentCanvasPlan] = useRecoilState(currentCanvasPlanState)
|
const [currentCanvasPlan, setCurrentCanvasPlan] = useRecoilState(currentCanvasPlanState)
|
||||||
// const canvas = useRecoilValue(canvasState)
|
const { handleBackImageLoadToCanvas } = useCanvas()
|
||||||
const { canvas, handleBackImageLoadToCanvas } = useCanvas()
|
|
||||||
const { swalFire } = useSwal()
|
const { swalFire } = useSwal()
|
||||||
const { get, post, promisePost } = useAxios()
|
const { get, post } = useAxios()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (refFileMethod === '1') {
|
if (refFileMethod === '1') {
|
||||||
// 파일 불러오기
|
|
||||||
setMapPositionAddress('')
|
setMapPositionAddress('')
|
||||||
} else {
|
} else {
|
||||||
setRefImage(null)
|
setRefImage(null)
|
||||||
}
|
}
|
||||||
}, [refFileMethod])
|
}, [refFileMethod])
|
||||||
|
|
||||||
/**
|
|
||||||
* 현재 플랜이 변경되면 플랜 상태 저장
|
|
||||||
*/
|
|
||||||
useEffect(() => {
|
|
||||||
// console.log('🚀 ~ useRefFiles ~ currentCanvasPlan:', currentCanvasPlan)
|
|
||||||
// const handleCurrentPlan = async () => {
|
|
||||||
// await promisePut({ url: '/api/canvas-management/canvas-statuses', data: currentCanvasPlan }).then((res) => {
|
|
||||||
// console.log('🚀 ~ awaitpromisePut ~ res:', res)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// handleCurrentPlan()
|
|
||||||
}, [currentCanvasPlan])
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 파일 불러오기 버튼 컨트롤
|
* 파일 불러오기 버튼 컨트롤
|
||||||
* @param {*} file
|
* @param {*} file
|
||||||
@ -56,8 +45,6 @@ export function useRefFiles() {
|
|||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
confirmFn: () => {
|
confirmFn: () => {
|
||||||
refFileSetting(file)
|
refFileSetting(file)
|
||||||
// setRefImage(file)
|
|
||||||
// file.name.split('.').pop() === 'dwg' ? handleUploadConvertRefFile(file) : handleUploadImageRefFile(file)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -71,7 +58,6 @@ export function useRefFiles() {
|
|||||||
handleUploadConvertRefFile(file)
|
handleUploadConvertRefFile(file)
|
||||||
} else {
|
} else {
|
||||||
if (file && ['image/png', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/gif'].includes(file.type)) {
|
if (file && ['image/png', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/gif'].includes(file.type)) {
|
||||||
// file.name.split('.').pop() === 'dwg' ? handleUploadConvertRefFile(file) : handleUploadImageRefFile(file)
|
|
||||||
handleUploadImageRefFile(file)
|
handleUploadImageRefFile(file)
|
||||||
} else {
|
} else {
|
||||||
swalFire({
|
swalFire({
|
||||||
@ -82,6 +68,7 @@ export function useRefFiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 파일 삭제
|
* 파일 삭제
|
||||||
*/
|
*/
|
||||||
@ -92,9 +79,6 @@ export function useRefFiles() {
|
|||||||
confirmFn: () => {
|
confirmFn: () => {
|
||||||
setRefImage(null)
|
setRefImage(null)
|
||||||
setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: null }))
|
setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: null }))
|
||||||
// removeImage(currentCanvasPlan.id).then((res) => {
|
|
||||||
// console.log(res)
|
|
||||||
// })
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -110,9 +94,6 @@ export function useRefFiles() {
|
|||||||
setMapPositionAddress('')
|
setMapPositionAddress('')
|
||||||
setCurrentBgImage(null)
|
setCurrentBgImage(null)
|
||||||
setCurrentCanvasPlan((prev) => ({ ...prev, mapPositionAddress: null }))
|
setCurrentCanvasPlan((prev) => ({ ...prev, mapPositionAddress: null }))
|
||||||
// removeImage(currentCanvasPlan.id).then((res) => {
|
|
||||||
// console.log(res)
|
|
||||||
// })
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -130,9 +111,6 @@ export function useRefFiles() {
|
|||||||
url: `${process.env.NEXT_PUBLIC_HOST_URL}/map/convert?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`,
|
url: `${process.env.NEXT_PUBLIC_HOST_URL}/map/convert?q=${queryRef.current.value}&fileNm=${currentCanvasPlan.id}&zoom=20`,
|
||||||
})
|
})
|
||||||
console.log('🚀 ~ handleMapImageDown ~ res:', res)
|
console.log('🚀 ~ handleMapImageDown ~ res:', res)
|
||||||
// const file = await readImage(res.fileNm)
|
|
||||||
// console.log('🚀 ~ handleMapImageDown ~ file:', file)
|
|
||||||
// setCurrentBgImage(file)
|
|
||||||
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +122,6 @@ export function useRefFiles() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('🚀 ~ useEffect ~ currentBgImage:', currentBgImage)
|
console.log('🚀 ~ useEffect ~ currentBgImage:', currentBgImage)
|
||||||
// handleBackImageLoadToCanvas(`plan-images/${currentCanvasPlan.id}.png`)
|
|
||||||
handleBackImageLoadToCanvas(currentBgImage)
|
handleBackImageLoadToCanvas(currentBgImage)
|
||||||
setCurrentCanvasPlan((prev) => ({
|
setCurrentCanvasPlan((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
@ -160,16 +137,12 @@ export function useRefFiles() {
|
|||||||
const handleUploadImageRefFile = async (file) => {
|
const handleUploadImageRefFile = async (file) => {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
// formData.append('fileName', currentCanvasPlan.id)
|
|
||||||
|
|
||||||
// const res = await post({ url: `${process.env.NEXT_PUBLIC_API_SERVER_PATH}/api/image-upload`, data: formData })
|
|
||||||
const res = await post({
|
const res = await post({
|
||||||
url: `${process.env.NEXT_PUBLIC_HOST_URL}/image/upload`,
|
url: `${process.env.NEXT_PUBLIC_HOST_URL}/image/upload`,
|
||||||
data: formData,
|
data: formData,
|
||||||
})
|
})
|
||||||
console.log('🚀 ~ handleUploadImageRefFile ~ res:', res)
|
console.log('🚀 ~ handleUploadImageRefFile ~ res:', res)
|
||||||
// const image = await readImage(res.filePath)
|
|
||||||
// console.log('🚀 ~ handleUploadImageRefFile ~ file:', image)
|
|
||||||
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`)
|
||||||
setRefImage(file)
|
setRefImage(file)
|
||||||
}
|
}
|
||||||
@ -191,15 +164,6 @@ export function useRefFiles() {
|
|||||||
console.log('🚀 ~ handleUploadConvertRefFile ~ result:', result)
|
console.log('🚀 ~ handleUploadConvertRefFile ~ result:', result)
|
||||||
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${result.filePath}`)
|
setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${result.filePath}`)
|
||||||
setRefImage(res.Files[0].FileData)
|
setRefImage(res.Files[0].FileData)
|
||||||
// await promisePost({ url: converterUrl, data: formData })
|
|
||||||
// .then((res) => {
|
|
||||||
// convertDwgToPng(res.data.Files[0].FileName, res.data.Files[0].FileData)
|
|
||||||
// swalFire({ text: '파일 변환 성공' })
|
|
||||||
// setRefImage(res.data.Files[0].FileData)
|
|
||||||
// })
|
|
||||||
// .catch((err) => {
|
|
||||||
// swalFire({ text: '파일 변환 실패', icon: 'error' })
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { useRecoilValue } from 'recoil'
|
import { useRecoilValue } from 'recoil'
|
||||||
import { canvasState } from '@/store/canvasAtom'
|
import { canvasState } from '@/store/canvasAtom'
|
||||||
import { useCanvas } from '../useCanvas'
|
|
||||||
import { useAxios } from '../useAxios'
|
import { useAxios } from '../useAxios'
|
||||||
import { usePlan } from '../usePlan'
|
import { usePlan } from '../usePlan'
|
||||||
import { POLYGON_TYPE } from '@/common/common'
|
import { POLYGON_TYPE } from '@/common/common'
|
||||||
@ -9,6 +8,8 @@ import { useContext } from 'react'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 이미지 로더 hook
|
* 이미지 로더 hook
|
||||||
|
* 캔버스를 바이너리로 변환하고 이미지 객체에 붙여서 다시 이미지를 바이너리로 전달
|
||||||
|
* 캔버스 데이터가 바이너리로 변경되면 용량이 너무 커서 post전송에 실패할 수 있음
|
||||||
* @returns {function} handleCanvasToPng
|
* @returns {function} handleCanvasToPng
|
||||||
*/
|
*/
|
||||||
export function useImgLoader() {
|
export function useImgLoader() {
|
||||||
@ -67,7 +68,7 @@ export function useImgLoader() {
|
|||||||
formData.append('objectNo', currentCanvasPlan.objectNo)
|
formData.append('objectNo', currentCanvasPlan.objectNo)
|
||||||
formData.append('planNo', currentCanvasPlan.planNo)
|
formData.append('planNo', currentCanvasPlan.planNo)
|
||||||
formData.append('type', type)
|
formData.append('type', type)
|
||||||
// formData.append('coordinates', getImageCoordinates())
|
/** 이미지 크롭 좌표 계산 */
|
||||||
const positionObj = getImageCoordinates()
|
const positionObj = getImageCoordinates()
|
||||||
console.log('🚀 ~ handleCanvasToPng ~ positionObj:', positionObj)
|
console.log('🚀 ~ handleCanvasToPng ~ positionObj:', positionObj)
|
||||||
formData.append('width', Math.round(positionObj[1].x - positionObj[0].x + 100))
|
formData.append('width', Math.round(positionObj[1].x - positionObj[0].x + 100))
|
||||||
@ -76,7 +77,7 @@ export function useImgLoader() {
|
|||||||
formData.append('top', Math.round(positionObj[0].y))
|
formData.append('top', Math.round(positionObj[0].y))
|
||||||
console.log('🚀 ~ handleCanvasToPng ~ formData:', formData)
|
console.log('🚀 ~ handleCanvasToPng ~ formData:', formData)
|
||||||
|
|
||||||
// 이미지 크롭 요청
|
/** 이미지 크롭 요청 */
|
||||||
const result = await post({
|
const result = await post({
|
||||||
url: `${process.env.NEXT_PUBLIC_HOST_URL}/image/canvas`,
|
url: `${process.env.NEXT_PUBLIC_HOST_URL}/image/canvas`,
|
||||||
data: formData,
|
data: formData,
|
||||||
|
|||||||
@ -1,14 +1,3 @@
|
|||||||
// import { createI18nMiddleware } from 'next-international/middleware'
|
|
||||||
|
|
||||||
// const I18nMiddleware = createI18nMiddleware({
|
|
||||||
// locales: ['ko', 'ja'],
|
|
||||||
// defaultLocale: 'ko',
|
|
||||||
// })
|
|
||||||
|
|
||||||
// export function middleware(request) {
|
|
||||||
// return I18nMiddleware(request)
|
|
||||||
// }
|
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: ['/((?!api|static|.*\\..*|_next|favicon.ico|robots.txt).*)'],
|
matcher: ['/((?!api|static|.*\\..*|_next|favicon.ico|robots.txt).*)'],
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user