diff --git a/src/components/floor-plan/CanvasMenu.jsx b/src/components/floor-plan/CanvasMenu.jsx index fa06fa08..ed2249b0 100644 --- a/src/components/floor-plan/CanvasMenu.jsx +++ b/src/components/floor-plan/CanvasMenu.jsx @@ -272,7 +272,7 @@ export default function CanvasMenu(props) { // 저장버튼(btn08) 클릭 시 호출되는 함수 const handleSaveCanvas = async () => { - await saveCanvas() + await saveCanvas(true) } // 나가기 버튼 클릭 diff --git a/src/hooks/useEstimate.js b/src/hooks/useEstimate.js index 3d64d66c..e2ed851d 100644 --- a/src/hooks/useEstimate.js +++ b/src/hooks/useEstimate.js @@ -7,11 +7,13 @@ import { useAxios } from '@/hooks/useAxios' import { useSwal } from '@/hooks/useSwal' import { usePlan } from '@/hooks/usePlan' import { GlobalDataContext } from '@/app/GlobalDataProvider' +import { QcastContext } from '@/app/QcastProvider' import { currentCanvasPlanState } from '@/store/canvasAtom' import { loginUserStore } from '@/store/commonAtom' export function useEstimate() { const { managementStateLoaded } = useContext(GlobalDataContext) + const { setIsGlobalLoading } = useContext(QcastContext) const router = useRouter() const loginUserState = useRecoilValue(loginUserStore) const currentCanvasPlan = useRecoilValue(currentCanvasPlanState) @@ -24,6 +26,9 @@ export function useEstimate() { * 도면 견적서 저장 */ const saveEstimate = async (estimateParam) => { + // 로딩 임시 주석 + // setIsGlobalLoading(true) + const userId = loginUserState.userId const saleStoreId = managementStateLoaded.saleStoreId const objectNo = currentCanvasPlan.objectNo @@ -54,7 +59,7 @@ export function useEstimate() { await promisePost({ url: '/api/estimate/save-estimate', data: saveEstimateData }) .then(async () => { // 견적서 저장이 완료되면 캔버스 저장 후 견적서 페이지로 이동 - await saveCanvas() + await saveCanvas(false) moveEstimate(planNo, objectNo) }) .catch((error) => { diff --git a/src/hooks/usePlan.js b/src/hooks/usePlan.js index d560dec1..2bb37a1e 100644 --- a/src/hooks/usePlan.js +++ b/src/hooks/usePlan.js @@ -120,9 +120,9 @@ export function usePlan(params = {}) { /** * 페이지 내 캔버스를 저장 */ - const saveCanvas = async () => { + const saveCanvas = async (saveAlert = true) => { const canvasStatus = currentCanvasData('save') - await putCanvasStatus(canvasStatus) + await putCanvasStatus(canvasStatus, saveAlert) } /** @@ -192,7 +192,7 @@ export function usePlan(params = {}) { /** * id에 해당하는 canvas 데이터를 수정 */ - const putCanvasStatus = async (canvasStatus) => { + const putCanvasStatus = async (canvasStatus, saveAlert = true) => { const planData = { id: currentCanvasPlan.id, bgImageName: currentCanvasPlan?.bgImageName ?? null, @@ -202,7 +202,7 @@ export function usePlan(params = {}) { await promisePut({ url: '/api/canvas-management/canvas-statuses', data: planData }) .then((res) => { setPlans((plans) => plans.map((plan) => (plan.id === currentCanvasPlan.id ? { ...plan, canvasStatus: canvasStatus } : plan))) - swalFire({ text: getMessage('plan.message.save') }) + if (saveAlert) swalFire({ text: getMessage('plan.message.save') }) }) .catch((error) => { swalFire({ text: error.message, icon: 'error' }) @@ -283,7 +283,7 @@ export function usePlan(params = {}) { }) } else { if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) { - await saveCanvas() + await saveCanvas(true) } setCurrentCanvasPlan(plans.find((plan) => plan.id === newCurrentId)) setPlans((plans) => plans.map((plan) => ({ ...plan, isCurrent: plan.id === newCurrentId }))) @@ -316,7 +316,7 @@ export function usePlan(params = {}) { */ const handleAddPlan = async (userId, objectNo) => { if (currentCanvasPlan?.id) { - await saveCanvas() + await saveCanvas(true) } JSON.parse(currentCanvasData()).objects.length > 0 ? swalFire({