fix: 물건번호 recoil 추가

This commit is contained in:
yoosangwook 2024-11-25 10:32:48 +09:00
parent ee2888b7a8
commit 1ba86c3369
3 changed files with 459 additions and 159 deletions

View File

@ -1,9 +1,11 @@
'ues client' 'ues client'
import { correntObjectNoState } from '@/store/settingAtom'
import { notFound, usePathname, useSearchParams } from 'next/navigation' 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'
import { useSetRecoilState } from 'recoil'
const reducer = (prevState, nextState) => { const reducer = (prevState, nextState) => {
return { ...prevState, ...nextState } return { ...prevState, ...nextState }
@ -32,6 +34,7 @@ export const FloorPlanContext = createContext({
const FloorPlanProvider = ({ children }) => { const FloorPlanProvider = ({ children }) => {
const pathname = usePathname() const pathname = usePathname()
const setCurrentObjectNo = 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')
@ -40,6 +43,7 @@ const FloorPlanProvider = ({ children }) => {
if (pid === undefined || pid === '' || objectNo === undefined || objectNo === '') { if (pid === undefined || pid === '' || objectNo === undefined || objectNo === '') {
notFound() notFound()
} }
setCurrentObjectNo(objectNo)
} }
const [floorPlanState, setFloorPlanState] = useState({ const [floorPlanState, setFloorPlanState] = useState({

View File

@ -217,3 +217,11 @@ export const basicSettingState = atom({
], ],
}, },
}) })
/**
* 현재 선택된 물건 번호
*/
export const correntObjectNoState = atom({
key: 'correntObjectNoState',
default: '',
})

606
yarn.lock

File diff suppressed because it is too large Load Diff