From 763cf2e3459ed7dbd6bf97fceca1963730bb024b Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 4 Sep 2024 10:30:14 +0200 Subject: [PATCH] refactor: refs #6900 create setRectificative composable --- src/pages/InvoiceIn/Card/InvoiceInCard.vue | 16 ++-------------- .../InvoiceIn/composables/setRectificative.js | 14 ++++++++++++++ src/router/modules/invoiceIn.js | 17 ++--------------- 3 files changed, 18 insertions(+), 29 deletions(-) create mode 100644 src/pages/InvoiceIn/composables/setRectificative.js diff --git a/src/pages/InvoiceIn/Card/InvoiceInCard.vue b/src/pages/InvoiceIn/Card/InvoiceInCard.vue index be92b6a8b..0fe2a2368 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInCard.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInCard.vue @@ -3,8 +3,8 @@ import VnCard from 'components/common/VnCard.vue'; import InvoiceInDescriptor from './InvoiceInDescriptor.vue'; import InvoiceInFilter from '../InvoiceInFilter.vue'; import InvoiceInSearchbar from '../InvoiceInSearchbar.vue'; -import axios from 'axios'; import { onBeforeRouteUpdate } from 'vue-router'; +import { setRectificative } from '../composables/setRectificative'; const filter = { include: [ @@ -23,19 +23,7 @@ const filter = { ], }; -onBeforeRouteUpdate(async (to) => { - const card = to.matched.find((route) => route.name === 'InvoiceInCard'); - const corrective = card.children.find( - (route) => route.name === 'InvoiceInCorrective' - ); - - const isRectificative = !!( - await axios.get('InvoiceInCorrections', { - params: { filter: { where: { correctingFk: to.params.id } } }, - }) - ).data.length; - corrective.meta.hidden = !isRectificative; -}); +onBeforeRouteUpdate(async (to) => await setRectificative(to));