improve Donnation component and fix string format for the value in the wallet

This commit is contained in:
Dominic Villemure
2024-08-25 14:59:04 -04:00
parent ddee8cd848
commit c14a2fa8e9
2 changed files with 24 additions and 13 deletions

View File

@@ -26,13 +26,19 @@
</div> </div>
<v-card-text> <v-card-text>
<v-text-field v-model="tipAmount" <v-text-field
v-model="tipAmount"
type="number"
:min="0"
class="p-2" class="p-2"
label="Montant" label="Montant"
density="comfortable" density="comfortable"
variant="outlined" variant="outlined"
hide-details hide-details
clearable clearable
inputmode="numeric"
@keydown="preventNonNumeric"
prepend-inner-icon="mdi-currency-usd"
></v-text-field> ></v-text-field>
<v-textarea v-model="tipMessage" <v-textarea v-model="tipMessage"
@@ -139,7 +145,6 @@ function closeDialog() {
checkout.destroy(); checkout.destroy();
} }
} }
async function goPay() { async function goPay() {
isPaymentDialogActive.value = true; isPaymentDialogActive.value = true;
@@ -149,4 +154,13 @@ async function goPay() {
await checkout.mount('#checkout'); await checkout.mount('#checkout');
} }
function preventNonNumeric(event) {
const key = event.key;
const allowedKeys = ['Backspace', 'ArrowLeft', 'ArrowRight', 'Delete'];
if (!/^\d$/.test(key) && !allowedKeys.includes(key)) {
event.preventDefault();
}
}
</script> </script>

View File

@@ -64,11 +64,8 @@ const formattedTransactions = computed(() => {
}); });
const formattedBalance = computed(() => { const formattedBalance = computed(() => {
const balanceStr = totalBalance.value.toString(); const balance = totalBalance.value.toString();
const balanceParts = balanceStr.split("."); return `${balance} $`
const integerPart = balanceParts[0]
const decimalPart = balanceParts[1]
return integerPart + ',' + decimalPart + ' $';
}); });
const transactionCount = computed(() => userTransactions.value.length); const transactionCount = computed(() => userTransactions.value.length);