feat: show receive dialog

This commit is contained in:
Vlad Stan 2022-10-11 18:44:28 +03:00 committed by dni ⚡
parent 2179c7a327
commit dc03692cfd

View File

@ -52,6 +52,7 @@ page_container %}
rounded rounded
color="primary" color="primary"
class="full-width" class="full-width"
@click="showReceiveTokensDialog"
>Receive</q-btn >Receive</q-btn
> >
</div> </div>
@ -322,6 +323,43 @@ page_container %}
</q-card> </q-card>
</q-dialog> </q-dialog>
<q-dialog v-model="showReceiveTokens" position="top">
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
<div>
<div class="row items-center no-wrap q-mb-sm">
<div class="col-12">
<span class="text-subtitle1"
>Paste tokens please</span
>
</div>
</div>
<q-input
filled
dense
v-model="receiveData.tokensBase64"
label="tokens"
type="textarea"
class="q-mb-lg"
></q-input>
</div>
<div class="row q-mt-lg">
<q-btn
@click="acceptTokens"
outline
color="grey"
>Accept Tokens</q-btn
>
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
>Close</q-btn
>
</div>
</q-card>
</q-dialog>
<q-dialog v-model="showPayInvoice" position="top"> <q-dialog v-model="showPayInvoice" position="top">
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card"> <q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
<div v-if="!sellData.invoice"> <div v-if="!sellData.invoice">
@ -436,9 +474,13 @@ page_container %}
tokens: '', tokens: '',
tokensBase64: '' tokensBase64: ''
}, },
receiveData: {
tokensBase64: ''
},
showInvoiceDetails: false, showInvoiceDetails: false,
showPayInvoice: false, showPayInvoice: false,
showSendTokens: false, showSendTokens: false,
showReceiveTokens: false,
tokens: [], tokens: [],
tab: 'tokens', tab: 'tokens',
@ -868,6 +910,11 @@ page_container %}
this.showSendTokens = true this.showSendTokens = true
}, },
showReceiveTokensDialog : function() {
this.receiveData.tokensBase64 = ''
this.showReceiveTokens = true
},
requestInvoice: async function () { requestInvoice: async function () {
try { try {
const {data} = await LNbits.api.request( const {data} = await LNbits.api.request(
@ -1015,14 +1062,23 @@ page_container %}
console.log('### this.tokens', this.tokens) console.log('### this.tokens', this.tokens)
}, },
acceptTokens: async function() {
this.showReceiveTokens = false
console.log('### receive tokens', this.receiveData.tokensBase64)
if (this.receiveData.tokensBase64) {
const tokensJson = atob(this.receiveData.tokensBase64)
console.log('tokensJson', tokensJson)
}
},
findTokenForAmount: function (amount) { findTokenForAmount: function (amount) {
for (const token of this.tokens) { for (const token of this.tokens) {
const index = token.promises?.findIndex(p => p.amount === amount) const index = token.promises?.findIndex(p => p.amount === amount)
if (index >= 0) { if (index >= 0) {
return { return {
promise: token.promises[index], promise: token.promises[index],
secret: token.secrets[index], secret: token.secrets[index]
randomBlindingFactor: token.randomBlindingFactors[index]
} }
} }
} }