Merge pull request #6288 from NicolasDorier/bettershowwarnings

Show warnings if NFC payment isn't complete
This commit is contained in:
Nicolas Dorier 2024-10-10 19:23:42 +09:00 committed by GitHub
commit d50d2f9ca0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 5 deletions

View file

@ -33,7 +33,7 @@
<script>
Vue.component(@Safe.Json(BitcoinCheckoutModelExtension.CheckoutBodyComponentName), {
props: ['model', 'nfcSupported', 'nfcScanning', 'nfcErrorMessage'],
props: ['model', 'nfcSupported', 'nfcScanning', 'nfcErrorMessage', 'nfcWarningMessage'],
template: @Safe.Json("#" + BitcoinCheckoutModelExtension.CheckoutBodyComponentName),
components: {
qrcode: VueQrcode

View file

@ -25,7 +25,7 @@
<script>
Vue.component(@Safe.Json(LNCheckoutModelExtension.CheckoutBodyComponentName), {
props: ['model', 'nfcSupported', 'nfcScanning', 'nfcErrorMessage'],
props: ['model', 'nfcSupported', 'nfcScanning', 'nfcErrorMessage', 'nfcWarningMessage'],
template: @Safe.Json("#" + LNCheckoutModelExtension.CheckoutBodyComponentName),
components: {
qrcode: VueQrcode

View file

@ -1,6 +1,7 @@
<template id="lnurl-withdraw-template">
<div v-if="display" class="mt-4" id="NFC">
<div v-if="nfcErrorMessage" class="alert alert-danger" v-text="nfcErrorMessage"></div>
<div v-if="nfcWarningMessage" class="alert alert-warning" v-text="nfcWarningMessage"></div>
<button class="btn btn-secondary rounded-pill w-100" type="button" id="PayByNFC"
:disabled="nfcScanning || submitting" v-on:click="handleClick">{{btnText}}</button>
</div>
@ -12,7 +13,8 @@ Vue.component("lnurl-withdraw-checkout", {
model: Object,
nfcSupported: Boolean,
nfcScanning: Boolean,
nfcErrorMessage: String
nfcErrorMessage: String,
nfcWarningMessage: String
},
computed: {
display () {

View file

@ -1 +1,7 @@
<lnurl-withdraw-checkout :model="model" :nfc-supported="nfcSupported" :nfc-scanning="nfcScanning" :nfc-error-message="nfcErrorMessage" v-on="$listeners" />
<lnurl-withdraw-checkout
:model="model"
:nfc-supported="nfcSupported"
:nfc-scanning="nfcScanning"
:nfc-error-message="nfcErrorMessage"
:nfc-warning-message="nfcWarningMessage"
v-on="$listeners" />

View file

@ -113,6 +113,7 @@
:nfc-scanning="nfc.scanning"
:nfc-supported="nfc.supported"
:nfc-error-message="nfc.errorMessage"
:nfc-warning-message="nfc.warningMessage"
v-on:start-nfc-scan="startNFCScan"
v-on:handle-nfc-data="handleNFCData"
v-on:handle-nfc-error="handleNFCError"

View file

@ -110,6 +110,7 @@ function initApp() {
scanning: false,
submitting: false,
errorMessage: null,
warningMessage: null,
permissionGranted: false,
readerAbortController: null
}
@ -436,9 +437,13 @@ function initApp() {
this.playSound('nfcRead');
this.$set(this.nfc, 'submitting', true);
this.$set(this.nfc, 'errorMessage', null);
this.$set(this.nfc, 'warningMessage', null);
},
handleNFCResult() { // child component reports result for handling the data
handleNFCResult(message) { // child component reports result for handling the data
this.$set(this.nfc, 'submitting', false);
if (message) {
this.$set(this.nfc, 'warningMessage', message);
}
},
handleNFCError(message) {
// internal or via child component reporting failure of handling the data