fix: plan 초기 생성 시 이전 물건 plan이 같이 보이는 현상 수정
This commit is contained in:
parent
c10689558c
commit
4edef1c87d
@ -14,6 +14,7 @@ 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'
|
||||
|
||||
export function usePlan(params = {}) {
|
||||
const { floorPlanState } = useContext(FloorPlanContext)
|
||||
|
||||
@ -159,7 +160,7 @@ export function usePlan(params = {}) {
|
||||
/**
|
||||
* 신규 canvas 데이터를 저장
|
||||
*/
|
||||
const postCanvasStatus = async (userId, objectNo, canvasStatus) => {
|
||||
const postCanvasStatus = async (userId, objectNo, canvasStatus, isInitPlan = false) => {
|
||||
const planNo = await postObjectPlan(userId, objectNo)
|
||||
if (!planNo) return
|
||||
|
||||
@ -173,7 +174,12 @@ export function usePlan(params = {}) {
|
||||
}
|
||||
await promisePost({ url: '/api/canvas-management/canvas-statuses', data: planData })
|
||||
.then((res) => {
|
||||
if (isInitPlan) {
|
||||
// 초기 플랜 생성인 경우 플랜 목록 초기화
|
||||
setPlans([{ id: res.data, objectNo: objectNo, planNo: planNo, userId: userId, canvasStatus: canvasStatus }])
|
||||
} else {
|
||||
setPlans((plans) => [...plans, { id: res.data, objectNo: objectNo, planNo: planNo, userId: userId, canvasStatus: canvasStatus }])
|
||||
}
|
||||
updateCurrentPlan(res.data)
|
||||
})
|
||||
.catch((error) => {
|
||||
@ -313,13 +319,13 @@ export function usePlan(params = {}) {
|
||||
text: `Plan ${currentCanvasPlan.planNo} ` + getMessage('plan.message.confirm.copy'),
|
||||
type: 'confirm',
|
||||
confirmFn: async () => {
|
||||
await postCanvasStatus(userId, objectNo, currentCanvasData())
|
||||
await postCanvasStatus(userId, objectNo, currentCanvasData(), false)
|
||||
},
|
||||
denyFn: async () => {
|
||||
await postCanvasStatus(userId, objectNo, '')
|
||||
await postCanvasStatus(userId, objectNo, '', false)
|
||||
},
|
||||
})
|
||||
: await postCanvasStatus(userId, objectNo, '')
|
||||
: await postCanvasStatus(userId, objectNo, '', false)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -373,7 +379,7 @@ export function usePlan(params = {}) {
|
||||
setPlans(res)
|
||||
updateCurrentPlan(res.find((plan) => plan.planNo === planNo).id)
|
||||
} else {
|
||||
postCanvasStatus(userId, objectNo, '')
|
||||
postCanvasStatus(userId, objectNo, '', true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user