feat: floor-plan 링크 수정
This commit is contained in:
parent
0f0643adc1
commit
f3b19f85a2
@ -1,5 +1,6 @@
|
|||||||
'ues client'
|
'ues client'
|
||||||
|
|
||||||
|
import { notFound, usePathname, useSearchParams } from 'next/navigation'
|
||||||
// import { ErrorBoundary } from 'next/dist/client/components/error-boundary'
|
// import { ErrorBoundary } from 'next/dist/client/components/error-boundary'
|
||||||
// import ServerError from '../error'
|
// import ServerError from '../error'
|
||||||
import { createContext, useEffect, useReducer, useState } from 'react'
|
import { createContext, useEffect, useReducer, useState } from 'react'
|
||||||
@ -30,19 +31,34 @@ export const FloorPlanContext = createContext({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const FloorPlanProvider = ({ children }) => {
|
const FloorPlanProvider = ({ children }) => {
|
||||||
|
const pathname = usePathname()
|
||||||
|
const searchParams = useSearchParams()
|
||||||
|
const objectNo = searchParams.get('objectNo')
|
||||||
|
const pid = searchParams.get('pid')
|
||||||
|
|
||||||
|
if (pathname === '/floor-plan') {
|
||||||
|
if (pid === undefined || pid === '' || objectNo === undefined || objectNo === '') {
|
||||||
|
notFound()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const [floorPlanState, setFloorPlanState] = useState({
|
const [floorPlanState, setFloorPlanState] = useState({
|
||||||
// 플랜 파일 업로드 모달 오픈 제어
|
// 플랜 파일 업로드 모달 오픈 제어
|
||||||
refFileModalOpen: false,
|
refFileModalOpen: false,
|
||||||
// 플랜 회전 모드 제어
|
// 플랜 회전 모드 제어
|
||||||
toggleRotate: false,
|
toggleRotate: false,
|
||||||
|
// 물건 번호
|
||||||
|
objectNo,
|
||||||
|
// 플랜 번호
|
||||||
|
pid,
|
||||||
})
|
})
|
||||||
|
|
||||||
const [estimateContextState, setEstimateContextState] = useReducer(reducer, defaultEstimateData)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('🚀 ~ floorPlanState:', floorPlanState)
|
console.log('🚀 ~ FloorPlanProvider ~ floorPlanState:', floorPlanState)
|
||||||
}, [floorPlanState])
|
}, [floorPlanState])
|
||||||
|
|
||||||
|
const [estimateContextState, setEstimateContextState] = useReducer(reducer, defaultEstimateData)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FloorPlanContext.Provider value={{ floorPlanState, setFloorPlanState, estimateContextState, setEstimateContextState }}>
|
<FloorPlanContext.Provider value={{ floorPlanState, setFloorPlanState, estimateContextState, setEstimateContextState }}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import FloorPlan from '@/components/floor-plan/FloorPlan'
|
|
||||||
import FloorPlanProvider from './FloorPlanProvider'
|
import FloorPlanProvider from './FloorPlanProvider'
|
||||||
|
import FloorPlan from '@/components/floor-plan/FloorPlan'
|
||||||
import CanvasLayout from '@/components/floor-plan/CanvasLayout'
|
import CanvasLayout from '@/components/floor-plan/CanvasLayout'
|
||||||
|
|
||||||
export default function FloorPlanLayout({ children }) {
|
export default function FloorPlanLayout({ children }) {
|
||||||
console.log('FloorPlanLayout')
|
console.log('🚀 ~ FloorPlanLayout ~ FloorPlanLayout:')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FloorPlanProvider>
|
<FloorPlanProvider>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user