From 44627dbc8a4b69debd80491a4a191d2edce6c6ec Mon Sep 17 00:00:00 2001 From: wbuezas Date: Wed, 14 Aug 2024 10:56:07 -0300 Subject: [PATCH] Replace prompt with VnConfirm --- src/pages/Ecomerce/OrdersView.vue | 36 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/pages/Ecomerce/OrdersView.vue b/src/pages/Ecomerce/OrdersView.vue index a5692da9..5cd1a9ff 100644 --- a/src/pages/Ecomerce/OrdersView.vue +++ b/src/pages/Ecomerce/OrdersView.vue @@ -4,6 +4,8 @@ import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import CardList from 'src/components/ui/CardList.vue'; +import VnInput from 'src/components/common/VnInput.vue'; +import VnConfirm from 'src/components/ui/VnConfirm.vue'; import { currency, formatDateTitle } from 'src/lib/filters.js'; import { tpvStore } from 'stores/tpv'; @@ -12,6 +14,8 @@ const { t } = useI18n(); const route = useRoute(); const jApi = inject('jApi'); +const showAmountToPayDialog = ref(null); +const amountToPay = ref(null); const orders = ref(null); const debt = ref(0); const tpv = tpvStore(); @@ -24,19 +28,18 @@ onMounted(async () => { }); const onPayClick = async () => { - let amount = -debt.value; - amount = amount <= 0 ? null : amount; + showAmountToPayDialog.value = true; - let defaultAmountStr = ''; - if (amount !== null) { - defaultAmountStr = amount; + if (debt.value <= 0) { + amountToPay.value = -debt.value; } +}; - amount = prompt(t('amountToPay'), defaultAmountStr); - - if (amount != null) { - amount = parseFloat(amount.replace(',', '.')); - await tpv.pay(amount); +const onConfirmPay = async () => { + if (amountToPay.value) { + const amount = amountToPay.value.toString().replace('.', ','); + amountToPay.value = parseFloat(amount); + await tpv.pay(amountToPay.value); } }; @@ -106,6 +109,19 @@ const onPayClick = async () => { :title="t('startOrder')" /> + + +