From 5c39525a2bc0a02df7ba837d4cbdfef0002e320a Mon Sep 17 00:00:00 2001 From: yogesh_gohil Date: Wed, 1 Dec 2021 18:57:33 +0530 Subject: [PATCH] fix: company save loader on duplicate name error --- .../modal-components/CompanyModal.vue | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/resources/scripts/components/modal-components/CompanyModal.vue b/resources/scripts/components/modal-components/CompanyModal.vue index 38efc98b1..273f04fd1 100644 --- a/resources/scripts/components/modal-components/CompanyModal.vue +++ b/resources/scripts/components/modal-components/CompanyModal.vue @@ -211,27 +211,31 @@ async function submitCompanyData() { } isSaving.value = true - const res = await companyStore.addNewCompany(newCompanyForm) - if (res.data.data) { - await companyStore.setSelectedCompany(res.data.data) - if (companyLogoFileBlob && companyLogoFileBlob.value) { - let logoData = new FormData() - - logoData.append( - 'company_logo', - JSON.stringify({ - name: companyLogoName.value, - data: companyLogoFileBlob.value, - }) - ) - - await companyStore.updateCompanyLogo(logoData) + try { + const res = await companyStore.addNewCompany(newCompanyForm) + if (res.data.data) { + await companyStore.setSelectedCompany(res.data.data) + if (companyLogoFileBlob && companyLogoFileBlob.value) { + let logoData = new FormData() + + logoData.append( + 'company_logo', + JSON.stringify({ + name: companyLogoName.value, + data: companyLogoFileBlob.value, + }) + ) + + await companyStore.updateCompanyLogo(logoData) + } + await globalStore.setIsAppLoaded(false) + await globalStore.bootstrap() + closeCompanyModal() } - await globalStore.setIsAppLoaded(false) - await globalStore.bootstrap() - closeCompanyModal() + isSaving.value = false + } catch { + isSaving.value = false } - isSaving.value = false } function resetNewCompanyForm() {