From 5663064dd8ca211f328e96e0bba902685cec0f9a Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 29 Oct 2024 09:23:49 +0100 Subject: [PATCH] refactor: modified composable --- src/pages/Order/Card/OrderLines.vue | 7 +++++-- src/pages/Order/Card/OrderSummary.vue | 9 +++++++-- src/pages/Order/composables/confirmOrder.js | 21 ++------------------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/pages/Order/Card/OrderLines.vue b/src/pages/Order/Card/OrderLines.vue index 90586dc15..58c5c9551 100644 --- a/src/pages/Order/Card/OrderLines.vue +++ b/src/pages/Order/Card/OrderLines.vue @@ -6,7 +6,7 @@ import { useQuasar } from 'quasar'; import axios from 'axios'; import { useStateStore } from 'stores/useStateStore'; import { useArrayData } from 'composables/useArrayData'; -import { confirmOrder } from 'composables/confirmOrder'; +import { confirm } from 'src/pages/Order/composables/confirmOrder'; import { toCurrency, toDate } from 'src/filters'; import VnConfirm from 'components/ui/VnConfirm.vue'; @@ -32,7 +32,6 @@ const orderSummary = ref({ }); const getTotalRef = ref(); const getVATRef = ref(); -const { confirm } = confirmOrder(); const lineFilter = ref({ include: [ { @@ -208,6 +207,10 @@ async function remove(item) { async function handleConfirm() { const result = await confirm(route.params.id); if (result) { + quasar.notify({ + message: t('globals.dataSaved'), + type: 'positive', + }); router.push({ name: 'TicketList', query: { diff --git a/src/pages/Order/Card/OrderSummary.vue b/src/pages/Order/Card/OrderSummary.vue index 3669fe8d8..032af1993 100644 --- a/src/pages/Order/Card/OrderSummary.vue +++ b/src/pages/Order/Card/OrderSummary.vue @@ -2,9 +2,10 @@ import { computed, ref } from 'vue'; import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; +import { useQuasar } from 'quasar'; import { dashIfEmpty, toCurrency, toDateHourMinSec } from 'src/filters'; import { useArrayData } from 'composables/useArrayData'; -import { confirmOrder } from 'composables/confirmOrder'; +import { confirm } from 'src/pages/Order/composables/confirmOrder'; import VnLv from 'components/ui/VnLv.vue'; import CardSummary from 'components/ui/CardSummary.vue'; import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue'; @@ -24,8 +25,8 @@ const $props = defineProps({ const entityId = computed(() => $props.id || route.params.id); const summary = ref(); +const quasar = useQuasar(); const descriptorData = useArrayData('orderData'); -const { confirm } = confirmOrder(); const detailsColumns = ref([ { name: 'item', @@ -58,6 +59,10 @@ const detailsColumns = ref([ async function handleConfirm() { const result = await confirm(route.params.id); if (result) { + quasar.notify({ + message: t('globals.dataSaved'), + type: 'positive', + }); summary.value.fetch({}); descriptorData.fetch({}); } diff --git a/src/pages/Order/composables/confirmOrder.js b/src/pages/Order/composables/confirmOrder.js index 33e05a1d7..b9eb5d7ac 100644 --- a/src/pages/Order/composables/confirmOrder.js +++ b/src/pages/Order/composables/confirmOrder.js @@ -1,22 +1,5 @@ import axios from 'axios'; -import { useQuasar } from 'quasar'; -import { useI18n } from 'vue-i18n'; -export function confirmOrder() { - const quasar = useQuasar(); - const { t } = useI18n(); - - async function confirm(route) { - const { data } = await axios.post(`Orders/${route}/confirm`); - if (data) { - quasar.notify({ - message: t('globals.confirm'), - type: 'positive', - }); - return data; - } - return null; - } - - return { confirm }; +export async function confirm(routeId) { + return await axios.post(`Orders/${routeId}/confirm`); }