From 891ad1c100876bfca7210b22cb38cb6731743003 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Sat, 16 Dec 2023 23:02:58 +0000 Subject: [PATCH] atm premium fix (#59) Co-authored-by: Pavol Rusnak --- templates/tpos/tpos.html | 71 +++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/templates/tpos/tpos.html b/templates/tpos/tpos.html index 5bd334d..bace3f8 100644 --- a/templates/tpos/tpos.html +++ b/templates/tpos/tpos.html @@ -383,14 +383,16 @@
${totalfsat} sat
fab icon="shopping_bag" color="primary" - >${[...this.cart.values()].reduce((a,i)=>a+i.quantity,0)}${[...this.cart.values()].reduce((a,i)=>a+i.quantity,0)} EXIT ATM MODE @@ -864,6 +866,9 @@
atm() { if (this.withdrawamtposs > 0) { this.atmBox = true + if (this.atmPremium > 0) { + this.exchangeRate = this.exchangeRate / (1 + this.atmPremium) + } } }, atmSubmit() { @@ -924,6 +929,7 @@
self.atmMode = false } } + this.getRates() }) .catch(function (error) { LNbits.utils.notifyApiError(error) @@ -1158,9 +1164,6 @@
.request('GET', `/tpos/api/v1/rate/${this.currency}`) .then(response => { this.exchangeRate = response.data.rate - if (this.atmPremium > 0) { - this.exchangeRate = this.exchangeRate * (1 + this.atmPremium) - } }) .catch(e => console.error(e)) }, @@ -1224,39 +1227,41 @@
this.showPoS = false } - window.addEventListener('keyup', (event) => { + window.addEventListener('keyup', event => { // do nothing if the event was already processed if (event.defaultPrevented) return - // active only in the the PoS mode, not in the Cart mode - if (!this.showPoS) return + // active only in the the PoS mode, not in the Cart mode or ATM pin + if (!this.showPoS || this.atmBox) return - const { key } = event - if (key >= '0' && key <= '9') { // buttons 0 ... 9 + const {key} = event + if (key >= '0' && key <= '9') { + // buttons 0 ... 9 this.stack.push(Number(key)) - } else switch (key) { - case 'Backspace': // button ⬅ - this.stack.pop() - break - case 'Enter': // button OK - this.submitForm() - break - case 'c': // button C - case 'C': - case 'Escape': - if (this.total > 0.0) { - this.cancelAddAmount() - } else { - this.stack = [] - } - break - case '+': // button + - this.addAmount() - break - default: - // return if we didn't handle anything - return - } + } else + switch (key) { + case 'Backspace': // button ⬅ + this.stack.pop() + break + case 'Enter': // button OK + this.submitForm() + break + case 'c': // button C + case 'C': + case 'Escape': + if (this.total > 0.0) { + this.cancelAddAmount() + } else { + this.stack = [] + } + break + case '+': // button + + this.addAmount() + break + default: + // return if we didn't handle anything + return + } // cancel the default action to avoid it being handled twice event.preventDefault()