📌chore: setCorrentObjectNo 위치 변경
This commit is contained in:
parent
87fba29717
commit
dd45849c75
@ -1,6 +1,9 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
|
import { correntObjectNoState } from '@/store/settingAtom'
|
||||||
|
import { usePathname, useSearchParams } from 'next/navigation'
|
||||||
import { createContext, useEffect, useState } from 'react'
|
import { createContext, useEffect, useState } from 'react'
|
||||||
|
import { useSetRecoilState } from 'recoil'
|
||||||
import { useLocalStorage } from 'usehooks-ts'
|
import { useLocalStorage } from 'usehooks-ts'
|
||||||
|
|
||||||
// export const GlobalDataContext = createContext({
|
// export const GlobalDataContext = createContext({
|
||||||
@ -15,6 +18,20 @@ const GlobalDataProvider = ({ children }) => {
|
|||||||
// TODO: 임시 조치이며 개발 완료시 삭제 예정 -> 잊지말기...
|
// 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)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (managementState !== null) {
|
if (managementState !== null) {
|
||||||
setManagementStateLoaded(managementState)
|
setManagementStateLoaded(managementState)
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
'ues client'
|
'ues client'
|
||||||
|
|
||||||
import { correntObjectNoState } from '@/store/settingAtom'
|
// import { correntObjectNoState } from '@/store/settingAtom'
|
||||||
import { notFound, usePathname, useSearchParams } from 'next/navigation'
|
import { notFound, usePathname, useSearchParams } from 'next/navigation'
|
||||||
import { createContext, useReducer, useState, useEffect } from 'react'
|
import { createContext, useReducer, useState, useEffect } from 'react'
|
||||||
import { useSetRecoilState } from 'recoil'
|
// import { useSetRecoilState } from 'recoil'
|
||||||
|
|
||||||
const reducer = (prevState, nextState) => {
|
const reducer = (prevState, nextState) => {
|
||||||
return { ...prevState, ...nextState }
|
return { ...prevState, ...nextState }
|
||||||
@ -42,20 +42,20 @@ export const FloorPlanContext = createContext({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const FloorPlanProvider = ({ children }) => {
|
const FloorPlanProvider = ({ children }) => {
|
||||||
const pathname = usePathname()
|
// const pathname = usePathname()
|
||||||
const setCorrentObjectNo = useSetRecoilState(correntObjectNoState)
|
// const setCorrentObjectNo = useSetRecoilState(correntObjectNoState)
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const objectNo = searchParams.get('objectNo')
|
const objectNo = searchParams.get('objectNo')
|
||||||
const pid = searchParams.get('pid')
|
const pid = searchParams.get('pid')
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
console.log('🚀 ~ useEffect ~ objectNo:')
|
// console.log('🚀 ~ useEffect ~ objectNo:')
|
||||||
if (pathname === '/floor-plan') {
|
// if (pathname === '/floor-plan') {
|
||||||
if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
|
// if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
|
||||||
notFound()
|
// notFound()
|
||||||
}
|
// }
|
||||||
setCorrentObjectNo(objectNo)
|
// setCorrentObjectNo(objectNo)
|
||||||
}
|
// }
|
||||||
}, [])
|
// }, [])
|
||||||
|
|
||||||
//useEffect(() => { // 오류 발생으로 useEffect 사용
|
//useEffect(() => { // 오류 발생으로 useEffect 사용
|
||||||
// if (pathname === '/floor-plan') {
|
// if (pathname === '/floor-plan') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user