#598 이전 물건정보에서 만든 도면데이타가 새로운 물건번호로 만든 후 플랜1을 추가해도 자동으로 계속 노출됨
This commit is contained in:
parent
14fa2e5b2b
commit
53344f1788
@ -3,7 +3,7 @@
|
||||
import { useContext, useEffect, useState } from 'react'
|
||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation'
|
||||
|
||||
import { useRecoilState } from 'recoil'
|
||||
import { useRecoilState, useResetRecoilState } from 'recoil'
|
||||
|
||||
import { canvasState, currentCanvasPlanState, plansState } from '@/store/canvasAtom'
|
||||
import { useAxios } from '@/hooks/useAxios'
|
||||
@ -14,6 +14,8 @@ import { SAVE_KEY } from '@/common/common'
|
||||
import { readImage, removeImage } from '@/lib/fileAction'
|
||||
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
|
||||
import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController'
|
||||
import { outerLinePointsState } from '@/store/outerLineAtom'
|
||||
import { placementShapeDrawingPointsState } from '@/store/placementShapeDrawingAtom'
|
||||
|
||||
export function usePlan(params = {}) {
|
||||
const { floorPlanState } = useContext(FloorPlanContext)
|
||||
@ -33,6 +35,10 @@ export function usePlan(params = {}) {
|
||||
const { get, promisePost, promisePut, promiseDel, promiseGet } = useAxios()
|
||||
|
||||
const { setEstimateContextState } = useEstimateController()
|
||||
|
||||
const resetOuterLinePoints = useResetRecoilState(outerLinePointsState)
|
||||
const resetPlacementShapeDrawingPoints = useResetRecoilState(placementShapeDrawingPointsState)
|
||||
|
||||
/**
|
||||
* 마우스 포인터의 가이드라인을 제거합니다.
|
||||
*/
|
||||
@ -284,6 +290,8 @@ export function usePlan(params = {}) {
|
||||
} else {
|
||||
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
|
||||
await saveCanvas(true)
|
||||
|
||||
clearRecoilState()
|
||||
}
|
||||
setCurrentCanvasPlan(plans.find((plan) => plan.id === newCurrentId))
|
||||
setPlans((plans) => plans.map((plan) => ({ ...plan, isCurrent: plan.id === newCurrentId })))
|
||||
@ -296,6 +304,12 @@ export function usePlan(params = {}) {
|
||||
// setBgImage()
|
||||
}, [currentCanvasPlan])
|
||||
|
||||
const clearRecoilState = () => {
|
||||
//clear가 필요한 recoil state 관리
|
||||
resetOuterLinePoints()
|
||||
resetPlacementShapeDrawingPoints()
|
||||
}
|
||||
|
||||
const handleCurrentPlanUrl = () => {
|
||||
const currentPlan = plans.find((plan) => plan.isCurrent)
|
||||
// if (currentPlan) router.push(`${pathname}?pid=${currentPlan?.planNo}&objectNo=${floorPlanState?.objectNo}`)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user