refactor: renamings

This commit is contained in:
Vlad Stan 2022-10-10 09:19:53 +03:00
parent 33522204d6
commit 016534600e

View File

@ -129,7 +129,6 @@ page_container %}
<q-td key="hash" :props="props"> <q-td key="hash" :props="props">
<div>{{props.row.hash}}</div> <div>{{props.row.hash}}</div>
</q-td> </q-td>
</q-tr> </q-tr>
<!-- <q-tr v-show="props.row.expanded" :props="props"> <!-- <q-tr v-show="props.row.expanded" :props="props">
<q-td colspan="100%"> <q-td colspan="100%">
@ -507,7 +506,7 @@ page_container %}
{% raw %} {% raw %}
<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="!buyTokens.bolt11"> <div v-if="!buyTokens.data.bolt11">
<div class="row items-center no-wrap q-mb-sm"> <div class="row items-center no-wrap q-mb-sm">
<div class="col-12"> <div class="col-12">
<span class="text-subtitle1" <span class="text-subtitle1"
@ -518,7 +517,7 @@ page_container %}
<q-input <q-input
filled filled
dense dense
v-model.number="buyTokens.amount" v-model.number="buyTokens.data.amount"
label="Amount (sats) *" label="Amount (sats) *"
type="number" type="number"
class="q-mb-lg" class="q-mb-lg"
@ -527,15 +526,15 @@ page_container %}
<q-input <q-input
filled filled
dense dense
v-model.trim="buyTokens.memo" v-model.trim="buyTokens.data.memo"
label="Memo" label="Memo"
></q-input> ></q-input>
</div> </div>
<div v-else class="text-center q-mb-lg"> <div v-else class="text-center q-mb-lg">
<a :href="'lightning:' + buyTokens.bolt11"> <a :href="'lightning:' + buyTokens.data.bolt11">
<q-responsive :ratio="1" class="q-mx-xl"> <q-responsive :ratio="1" class="q-mx-xl">
<qrcode <qrcode
:value="buyTokens.bolt11" :value="buyTokens.data.bolt11"
:options="{width: 340}" :options="{width: 340}"
class="rounded-borders" class="rounded-borders"
> >
@ -545,8 +544,8 @@ page_container %}
</div> </div>
<div class="row q-mt-lg"> <div class="row q-mt-lg">
<q-btn <q-btn
v-if="buyTokens.bolt11" v-if="buyTokens.data.bolt11"
@click="copyText(buyTokens.bolt11)" @click="copyText(buyTokens.data.bolt11)"
outline outline
color="grey" color="grey"
>Copy invoice</q-btn >Copy invoice</q-btn
@ -587,6 +586,9 @@ page_container %}
</style> </style>
{% endblock %} {% block scripts %} {% endblock %} {% block scripts %}
<script> <script>
var currentDateStr = function () {
return Quasar.utils.date.formatDate(new Date(), 'YYYY-MM-DD HH:mm')
}
var mapMint = function (obj) { var mapMint = function (obj) {
obj.date = Quasar.utils.date.formatDate( obj.date = Quasar.utils.date.formatDate(
new Date(obj.time * 1000), new Date(obj.time * 1000),
@ -613,10 +615,13 @@ page_container %}
tokenBuys: [], tokenBuys: [],
buyTokens: { buyTokens: {
showDialog: false, showDialog: false,
data: {
amount: 0, amount: 0,
memo: '', memo: '',
bolt11: '', bolt11: '',
hash: '' hash: ''
}
}, },
receive: { receive: {
@ -948,24 +953,32 @@ page_container %}
/////////////////////////////////// WALLET /////////////////////////////////// /////////////////////////////////// WALLET ///////////////////////////////////
showBuyTokensDialog: async function () { showBuyTokensDialog: async function () {
this.buyTokens.amount = 0 console.log('##### showBuyTokensDialog')
this.buyTokens.bolt11 = '' this.buyTokens.data.amount = 0
this.buyTokens.hash = '' this.buyTokens.data.bolt11 = ''
this.buyTokens.memo = '' this.buyTokens.data.hash = ''
this.buyTokens.data.memo = ''
this.buyTokens.showDialog = true this.buyTokens.showDialog = true
}, },
requestInvoice: async function () { requestInvoice: async function () {
try { try {
const {data} = await LNbits.api.request( const {data} = await LNbits.api.request(
'GET', 'GET',
`/cashu/api/v1/cashu/${this.mintId}/mint?amount=${this.buyTokens.amount}` `/cashu/api/v1/cashu/${this.mintId}/mint?amount=${this.buyTokens.data.amount}`
) )
console.log('### data', data) console.log('### data', data)
this.buyTokens.bolt11 = data.pr this.buyTokens.data.bolt11 = data.pr
this.buyTokens.hash = data.hash this.buyTokens.data.hash = data.hash
this.tokenBuys.push({...this.buyTokens, date: new Date().toISOString()}) this.tokenBuys.push({
localStorage.setItem('cashu.tokenBuys', JSON.stringify(this.tokenBuys)) ...this.buyTokens.data,
date: currentDateStr(),
status: 'pending'
})
localStorage.setItem(
'cashu.tokenBuys',
JSON.stringify(this.tokenBuys)
)
} catch (error) { } catch (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
} }
@ -1019,7 +1032,9 @@ page_container %}
this.mintName = this.$q.localStorage.getItem('cashu.name') this.mintName = this.$q.localStorage.getItem('cashu.name')
} }
this.tokenBuys = JSON.parse(localStorage.getItem('cashu.tokenBuys') || '[]') this.tokenBuys = JSON.parse(
localStorage.getItem('cashu.tokenBuys') || '[]'
)
console.log('#### this.tokenBuys', this.tokenBuys) console.log('#### this.tokenBuys', this.tokenBuys)
console.log('#### this.mintId', this.mintId) console.log('#### this.mintId', this.mintId)
console.log('#### this.mintName', this.mintName) console.log('#### this.mintName', this.mintName)