Replace prompt with VnConfirm
gitea/hedera-web/pipeline/pr-4922-vueMigration This commit looks good Details

This commit is contained in:
William Buezas 2024-08-14 10:56:07 -03:00
parent f2c8b90324
commit 44627dbc8a
1 changed files with 26 additions and 10 deletions

View File

@ -4,6 +4,8 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import CardList from 'src/components/ui/CardList.vue'; 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 { currency, formatDateTitle } from 'src/lib/filters.js';
import { tpvStore } from 'stores/tpv'; import { tpvStore } from 'stores/tpv';
@ -12,6 +14,8 @@ const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const jApi = inject('jApi'); const jApi = inject('jApi');
const showAmountToPayDialog = ref(null);
const amountToPay = ref(null);
const orders = ref(null); const orders = ref(null);
const debt = ref(0); const debt = ref(0);
const tpv = tpvStore(); const tpv = tpvStore();
@ -24,19 +28,18 @@ onMounted(async () => {
}); });
const onPayClick = async () => { const onPayClick = async () => {
let amount = -debt.value; showAmountToPayDialog.value = true;
amount = amount <= 0 ? null : amount;
let defaultAmountStr = ''; if (debt.value <= 0) {
if (amount !== null) { amountToPay.value = -debt.value;
defaultAmountStr = amount;
} }
};
amount = prompt(t('amountToPay'), defaultAmountStr); const onConfirmPay = async () => {
if (amountToPay.value) {
if (amount != null) { const amount = amountToPay.value.toString().replace('.', ',');
amount = parseFloat(amount.replace(',', '.')); amountToPay.value = parseFloat(amount);
await tpv.pay(amount); await tpv.pay(amountToPay.value);
} }
}; };
</script> </script>
@ -106,6 +109,19 @@ const onPayClick = async () => {
:title="t('startOrder')" :title="t('startOrder')"
/> />
</QPageSticky> </QPageSticky>
<VnConfirm
v-model="showAmountToPayDialog"
:message="t('amountToPay')"
:promise="onConfirmPay"
>
<template #customHTML>
<VnInput
v-model="amountToPay"
:clearable="false"
class="full-width"
/>
</template>
</VnConfirm>
</QPage> </QPage>
</template> </template>