📌물건 및 도면관리 메뉴 url 처리 수정
- pid 파라미터에 따른 url 이동 수정
This commit is contained in:
parent
32f6319388
commit
5c0d5bb884
@ -23,6 +23,17 @@ const defaultEstimateData = {
|
|||||||
priceCd: '',
|
priceCd: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 모듈,회로 구성 상태 데이터
|
||||||
|
* 각 설정 팝업 상태를 저장하는 데이터
|
||||||
|
*/
|
||||||
|
const defaultProcessStep = {
|
||||||
|
gnbStep: 0,
|
||||||
|
processStep: 0,
|
||||||
|
moduleCofigureData: {},
|
||||||
|
pcsConfigureData: {},
|
||||||
|
}
|
||||||
|
|
||||||
export const FloorPlanContext = createContext({
|
export const FloorPlanContext = createContext({
|
||||||
floorPlanState: {},
|
floorPlanState: {},
|
||||||
setFloorPlanState: () => {},
|
setFloorPlanState: () => {},
|
||||||
@ -57,8 +68,12 @@ const FloorPlanProvider = ({ children }) => {
|
|||||||
|
|
||||||
const [estimateContextState, setEstimateContextState] = useReducer(reducer, defaultEstimateData)
|
const [estimateContextState, setEstimateContextState] = useReducer(reducer, defaultEstimateData)
|
||||||
|
|
||||||
|
const [processStepState, setProcessStepState] = useReducer(reducer, defaultProcessStep)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FloorPlanContext.Provider value={{ floorPlanState, setFloorPlanState, estimateContextState, setEstimateContextState }}>
|
<FloorPlanContext.Provider
|
||||||
|
value={{ floorPlanState, setFloorPlanState, estimateContextState, setEstimateContextState, processStepState, setProcessStepState }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</FloorPlanContext.Provider>
|
</FloorPlanContext.Provider>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
|
import { usePathname } from 'next/navigation'
|
||||||
import FloorPlanProvider from './FloorPlanProvider'
|
import FloorPlanProvider from './FloorPlanProvider'
|
||||||
import FloorPlan from '@/components/floor-plan/FloorPlan'
|
import FloorPlan from '@/components/floor-plan/FloorPlan'
|
||||||
import CanvasLayout from '@/components/floor-plan/CanvasLayout'
|
import CanvasLayout from '@/components/floor-plan/CanvasLayout'
|
||||||
import { usePathname } from 'next/navigation'
|
|
||||||
|
|
||||||
export default function FloorPlanLayout({ children }) {
|
export default function FloorPlanLayout({ children }) {
|
||||||
console.log('🚀 ~ FloorPlanLayout ~ FloorPlanLayout:')
|
console.log('🚀 ~ FloorPlanLayout ~ FloorPlanLayout:')
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useEffect, useState } from 'react'
|
import { useContext, useEffect, useState } from 'react'
|
||||||
import { useRouter } from 'next/navigation'
|
import { usePathname, useRouter } from 'next/navigation'
|
||||||
|
|
||||||
import { useRecoilState } from 'recoil'
|
import { useRecoilState } from 'recoil'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
@ -13,8 +13,12 @@ import { useSwal } from '@/hooks/useSwal'
|
|||||||
import { useCanvas } from '@/hooks/useCanvas'
|
import { useCanvas } from '@/hooks/useCanvas'
|
||||||
import { SAVE_KEY } from '@/common/common'
|
import { SAVE_KEY } from '@/common/common'
|
||||||
import { readImage, removeImage } from '@/lib/fileAction'
|
import { readImage, removeImage } from '@/lib/fileAction'
|
||||||
|
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
|
||||||
|
|
||||||
export function usePlan(params = {}) {
|
export function usePlan(params = {}) {
|
||||||
|
const pObjectNo = params.objectNo
|
||||||
|
const { floorPlanState } = useContext(FloorPlanContext)
|
||||||
|
|
||||||
const [planNum, setPlanNum] = useState(0)
|
const [planNum, setPlanNum] = useState(0)
|
||||||
const [selectedPlan, setSelectedPlan] = useState(null)
|
const [selectedPlan, setSelectedPlan] = useState(null)
|
||||||
|
|
||||||
@ -24,6 +28,7 @@ export function usePlan(params = {}) {
|
|||||||
const [plans, setPlans] = useRecoilState(plansState) // 전체 plan
|
const [plans, setPlans] = useRecoilState(plansState) // 전체 plan
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const pathname = usePathname()
|
||||||
|
|
||||||
const { swalFire } = useSwal()
|
const { swalFire } = useSwal()
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
@ -199,10 +204,12 @@ export function usePlan(params = {}) {
|
|||||||
* 현재 plan의 작업상태를 저장 후 이동
|
* 현재 plan의 작업상태를 저장 후 이동
|
||||||
*/
|
*/
|
||||||
const handleCurrentPlan = async (newCurrentId) => {
|
const handleCurrentPlan = async (newCurrentId) => {
|
||||||
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
|
if (pathname === '/floor-plan') {
|
||||||
await saveCanvas()
|
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
|
||||||
updateCurrentPlan(newCurrentId)
|
await saveCanvas()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
updateCurrentPlan(newCurrentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateCurrentPlan = (newCurrentId) => {
|
const updateCurrentPlan = (newCurrentId) => {
|
||||||
@ -219,9 +226,9 @@ export function usePlan(params = {}) {
|
|||||||
}, [plans])
|
}, [plans])
|
||||||
|
|
||||||
// 현재 plan이 변경될 때 마다 현재 plan의 링크로 이동
|
// 현재 plan이 변경될 때 마다 현재 plan의 링크로 이동
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// handlePlanMove()
|
handlePlanMove()
|
||||||
// }, [currentCanvasPlan])
|
}, [currentCanvasPlan])
|
||||||
|
|
||||||
const setBgImage = () => {
|
const setBgImage = () => {
|
||||||
// readImage(selectedPlan?.id)
|
// readImage(selectedPlan?.id)
|
||||||
@ -312,7 +319,7 @@ export function usePlan(params = {}) {
|
|||||||
* 현재 plan 이동 -> 새로운 링크로 이동
|
* 현재 plan 이동 -> 새로운 링크로 이동
|
||||||
*/
|
*/
|
||||||
const handlePlanMove = () => {
|
const handlePlanMove = () => {
|
||||||
router.push(`/floor-plan?objectNo=${params?.objectNo}&pid=${currentCanvasPlan?.ordering}`)
|
router.push(`${pathname}?objectNo=${floorPlanState.objectNo}&pid=${currentCanvasPlan?.ordering}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user