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