From f78d5b41a431e1b4354c6830a78e79c85677aca3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 20 Dec 2023 09:11:16 +0100 Subject: [PATCH 1/2] refs #6584 hotfix await --- src/pages/Claim/Card/ClaimAction.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/Claim/Card/ClaimAction.vue b/src/pages/Claim/Card/ClaimAction.vue index 44575f1d6..812517231 100644 --- a/src/pages/Claim/Card/ClaimAction.vue +++ b/src/pages/Claim/Card/ClaimAction.vue @@ -142,12 +142,17 @@ async function regularizeClaim() { }) .onOk(async () => await onUpdateGreugeAccept()); } else { + await claimRef.value.fetch(); quasar.notify({ message: t('globals.dataSaved'), type: 'positive', }); } await arrayData.fetch({ append: false }); + quasar.notify({ + message: t('globals.dataSaved'), + type: 'positive', + }); } async function updateGreuge(greuges) { From d286e35f99b5f43f8a5b2bf042b730b5864549a3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 20 Dec 2023 13:25:55 +0100 Subject: [PATCH 2/2] refs #6584 refactor --- src/pages/Claim/Card/ClaimAction.vue | 55 ++++++++-------------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/src/pages/Claim/Card/ClaimAction.vue b/src/pages/Claim/Card/ClaimAction.vue index 812517231..fb47eeee2 100644 --- a/src/pages/Claim/Card/ClaimAction.vue +++ b/src/pages/Claim/Card/ClaimAction.vue @@ -127,11 +127,14 @@ async function updateDestination(claimDestinationFk, row, options = {}) { } async function regularizeClaim() { - const query = `Claims/${claimId}/regularizeClaim`; - - await axios.post(query); + await axios.post(`Claims/${claimId}/regularizeClaim`); + await claimRef.value.fetch(); + await arrayData.fetch({ append: false }); + quasar.notify({ + message: t('globals.dataSaved'), + type: 'positive', + }); if (claim.value.responsibility >= Math.ceil(DEFAULT_MAX_RESPONSABILITY) / 2) { - await claimRef.value.fetch(); quasar .dialog({ component: VnConfirm, @@ -141,34 +144,19 @@ async function regularizeClaim() { }, }) .onOk(async () => await onUpdateGreugeAccept()); - } else { - await claimRef.value.fetch(); - quasar.notify({ - message: t('globals.dataSaved'), - type: 'positive', - }); } - await arrayData.fetch({ append: false }); - quasar.notify({ - message: t('globals.dataSaved'), - type: 'positive', - }); -} - -async function updateGreuge(greuges) { - const { data } = await axios.post(`Greuges`, greuges); - quasar.notify({ - message: t('globals.dataSaved'), - type: 'positive', - }); - return data; } async function onUpdateGreugeAccept() { - const greugeTypeFreightId = await getGreugeTypeId(); - const freightPickUpPrice = await getGreugeConfig(); + const greugeTypeFreightId = ( + await axios.get(`GreugeTypes/findOne`, { + filter: { where: { code: 'freightPickUp' } }, + }) + ).data.id; + const freightPickUpPrice = (await axios.get(`GreugeConfigs/findOne`)).data + .freightPickUpPrice; - await updateGreuge({ + await axios.post(`Greuges`, { clientFk: claim.value.clientFk, description: `${t('ClaimGreugeDescription')} ${claimId}`.toUpperCase(), amount: freightPickUpPrice, @@ -181,19 +169,6 @@ async function onUpdateGreugeAccept() { }); } -async function getGreugeTypeId() { - const params = { filter: { where: { code: 'freightPickUp' } } }; - const query = `GreugeTypes/findOne`; - const { data } = await axios.get(query, { params }); - return data.id; -} - -async function getGreugeConfig() { - const query = `GreugeConfigs/findOne`; - const { data } = await axios.get(query); - return data.freightPickUpPrice; -} - async function save(data) { const query = `Claims/${claimId}/updateClaimAction`; await axios.patch(query, data);