📌물건 및 도면관리 메뉴 url 처리 수정

- pid 파라미터에 따른 url 이동 수정
This commit is contained in:
yoosangwook 2025-01-10 11:12:28 +09:00
parent 32f6319388
commit 5c0d5bb884
3 changed files with 33 additions and 11 deletions

View File

@ -23,6 +23,17 @@ const defaultEstimateData = {
priceCd: '',
}
/**
* 모듈,회로 구성 상태 데이터
* 설정 팝업 상태를 저장하는 데이터
*/
const defaultProcessStep = {
gnbStep: 0,
processStep: 0,
moduleCofigureData: {},
pcsConfigureData: {},
}
export const FloorPlanContext = createContext({
floorPlanState: {},
setFloorPlanState: () => {},
@ -57,8 +68,12 @@ const FloorPlanProvider = ({ children }) => {
const [estimateContextState, setEstimateContextState] = useReducer(reducer, defaultEstimateData)
const [processStepState, setProcessStepState] = useReducer(reducer, defaultProcessStep)
return (
<FloorPlanContext.Provider value={{ floorPlanState, setFloorPlanState, estimateContextState, setEstimateContextState }}>
<FloorPlanContext.Provider
value={{ floorPlanState, setFloorPlanState, estimateContextState, setEstimateContextState, processStepState, setProcessStepState }}
>
{children}
</FloorPlanContext.Provider>
)

View File

@ -1,9 +1,9 @@
'use client'
import { usePathname } from 'next/navigation'
import FloorPlanProvider from './FloorPlanProvider'
import FloorPlan from '@/components/floor-plan/FloorPlan'
import CanvasLayout from '@/components/floor-plan/CanvasLayout'
import { usePathname } from 'next/navigation'
export default function FloorPlanLayout({ children }) {
console.log('🚀 ~ FloorPlanLayout ~ FloorPlanLayout:')

View File

@ -1,7 +1,7 @@
'use client'
import { useEffect, useState } from 'react'
import { useRouter } from 'next/navigation'
import { useContext, useEffect, useState } from 'react'
import { usePathname, useRouter } from 'next/navigation'
import { useRecoilState } from 'recoil'
import { v4 as uuidv4 } from 'uuid'
@ -13,8 +13,12 @@ import { useSwal } from '@/hooks/useSwal'
import { useCanvas } from '@/hooks/useCanvas'
import { SAVE_KEY } from '@/common/common'
import { readImage, removeImage } from '@/lib/fileAction'
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
export function usePlan(params = {}) {
const pObjectNo = params.objectNo
const { floorPlanState } = useContext(FloorPlanContext)
const [planNum, setPlanNum] = useState(0)
const [selectedPlan, setSelectedPlan] = useState(null)
@ -24,6 +28,7 @@ export function usePlan(params = {}) {
const [plans, setPlans] = useRecoilState(plansState) // 전체 plan
const router = useRouter()
const pathname = usePathname()
const { swalFire } = useSwal()
const { getMessage } = useMessage()
@ -199,10 +204,12 @@ export function usePlan(params = {}) {
* 현재 plan의 작업상태를 저장 이동
*/
const handleCurrentPlan = async (newCurrentId) => {
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
await saveCanvas()
updateCurrentPlan(newCurrentId)
if (pathname === '/floor-plan') {
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
await saveCanvas()
}
}
updateCurrentPlan(newCurrentId)
}
const updateCurrentPlan = (newCurrentId) => {
@ -219,9 +226,9 @@ export function usePlan(params = {}) {
}, [plans])
// 현재 plan이 변경될 때 마다 현재 plan의 링크로 이동
// useEffect(() => {
// handlePlanMove()
// }, [currentCanvasPlan])
useEffect(() => {
handlePlanMove()
}, [currentCanvasPlan])
const setBgImage = () => {
// readImage(selectedPlan?.id)
@ -312,7 +319,7 @@ export function usePlan(params = {}) {
* 현재 plan 이동 -> 새로운 링크로 이동
*/
const handlePlanMove = () => {
router.push(`/floor-plan?objectNo=${params?.objectNo}&pid=${currentCanvasPlan?.ordering}`)
router.push(`${pathname}?objectNo=${floorPlanState.objectNo}&pid=${currentCanvasPlan?.ordering}`)
}
return {