refactor: 견적서 저장 후 캔버스 저장
This commit is contained in:
parent
d7fb15c2e9
commit
0e006174b0
@ -5,6 +5,7 @@ import { useRecoilValue } from 'recoil'
|
||||
|
||||
import { useAxios } from '@/hooks/useAxios'
|
||||
import { useSwal } from '@/hooks/useSwal'
|
||||
import { usePlan } from '@/hooks/usePlan'
|
||||
import { GlobalDataContext } from '@/app/GlobalDataProvider'
|
||||
import { currentCanvasPlanState } from '@/store/canvasAtom'
|
||||
import { loginUserStore } from '@/store/commonAtom'
|
||||
@ -15,8 +16,9 @@ export function useEstimate() {
|
||||
const loginUserState = useRecoilValue(loginUserStore)
|
||||
const currentCanvasPlan = useRecoilValue(currentCanvasPlanState)
|
||||
|
||||
const { swalFire } = useSwal()
|
||||
const { promisePost } = useAxios()
|
||||
const { swalFire } = useSwal()
|
||||
const { saveCanvas } = usePlan()
|
||||
|
||||
/**
|
||||
* 도면 견적서 저장
|
||||
@ -50,7 +52,9 @@ export function useEstimate() {
|
||||
}
|
||||
|
||||
await promisePost({ url: '/api/estimate/save-estimate', data: saveEstimateData })
|
||||
.then(() => {
|
||||
.then(async () => {
|
||||
// 견적서 저장이 완료되면 캔버스 저장 후 견적서 페이지로 이동
|
||||
await saveCanvas()
|
||||
moveEstimate(planNo, objectNo)
|
||||
})
|
||||
.catch((error) => {
|
||||
@ -58,11 +62,15 @@ export function useEstimate() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 견적서 페이지로 이동
|
||||
*/
|
||||
const moveEstimate = (planNo, objectNo) => {
|
||||
router.push(`/floor-plan/estimate/5?pid=${planNo}&objectNo=${objectNo}`)
|
||||
}
|
||||
|
||||
return {
|
||||
saveEstimate,
|
||||
moveEstimate,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user