📌fix: fetch parameter 가져오는 방법 수정
This commit is contained in:
parent
c5aefaa457
commit
17954098cf
@ -43,18 +43,19 @@ export const FloorPlanContext = createContext({
|
||||
|
||||
const FloorPlanProvider = ({ children }) => {
|
||||
const pathname = usePathname()
|
||||
const setCurrentObjectNo = useSetRecoilState(correntObjectNoState)
|
||||
const setCorrentObjectNo = useSetRecoilState(correntObjectNoState)
|
||||
const searchParams = useSearchParams()
|
||||
const objectNo = searchParams.get('objectNo')
|
||||
const pid = searchParams.get('pid')
|
||||
useEffect(() => {
|
||||
console.log('🚀 ~ useEffect ~ objectNo:')
|
||||
if (pathname === '/floor-plan') {
|
||||
if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
|
||||
notFound()
|
||||
}
|
||||
setCurrentObjectNo(objectNo)
|
||||
setCorrentObjectNo(objectNo)
|
||||
}
|
||||
}, [pathname])
|
||||
}, [])
|
||||
|
||||
//useEffect(() => { // 오류 발생으로 useEffect 사용
|
||||
// if (pathname === '/floor-plan') {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useEffect, useState, useRef } from 'react'
|
||||
import { useEffect, useState, useRef, useContext } from 'react'
|
||||
import { useRecoilState, useRecoilValue, useResetRecoilState, useSetRecoilState } from 'recoil'
|
||||
import {
|
||||
adsorptionPointModeState,
|
||||
@ -35,6 +35,7 @@ import { ROOF_MATERIAL_LAYOUT } from '@/components/floor-plan/modal/placementSha
|
||||
import { useCanvasMenu } from '../common/useCanvasMenu'
|
||||
import { menuTypeState } from '@/store/menuAtom'
|
||||
import { usePopup } from '../usePopup'
|
||||
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
|
||||
|
||||
const defaultDotLineGridSetting = {
|
||||
INTERVAL: {
|
||||
@ -122,6 +123,8 @@ export function useCanvasSetting() {
|
||||
|
||||
const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector)
|
||||
|
||||
const { floorPlanState } = useContext(FloorPlanContext)
|
||||
|
||||
const { closeAll } = usePopup()
|
||||
|
||||
useEffect(() => {
|
||||
@ -300,7 +303,8 @@ export function useCanvasSetting() {
|
||||
// 기본설정(PlacementShapeSetting) 조회 및 초기화
|
||||
const fetchBasicSettings = async () => {
|
||||
try {
|
||||
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}` }).then((res) => {
|
||||
console.log('🚀 ~ fetchBasicSettings ~ floorPlanState:', floorPlanState)
|
||||
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${floorPlanState.objectNo}` }).then((res) => {
|
||||
console.log('🚀 ~ fetchBasicSettings ~ res >>>>>>>>>> :', res)
|
||||
|
||||
let roofsRow = {}
|
||||
@ -454,7 +458,7 @@ export function useCanvasSetting() {
|
||||
// CanvasSetting 조회 및 초기화
|
||||
const fetchSettings = async () => {
|
||||
try {
|
||||
const res = await get({ url: `/api/canvas-management/canvas-settings/by-object/${correntObjectNo}` })
|
||||
const res = await get({ url: `/api/canvas-management/canvas-settings/by-object/${floorPlanState.objectNo}` })
|
||||
console.log('res', res)
|
||||
|
||||
if (Object.keys(res).length > 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user