feat: move logic to relay-details component

This commit is contained in:
Vlad Stan 2023-02-07 14:24:12 +02:00
parent 999bb1683f
commit 1bc8640640
4 changed files with 60 additions and 42 deletions

View file

@ -4,7 +4,7 @@ async function relayDetails(path) {
name: 'relay-details',
template,
props: [],
props: ['relay-id', 'adminkey', 'inkey'],
data: function () {
return {
items: [],
@ -21,6 +21,25 @@ async function relayDetails(path) {
methods: {
satBtc(val, showUnit = true) {
return satOrBtc(val, showUnit, this.satsDenominated)
},
deleteRelay: function () {
LNbits.utils
.confirmDialog(
'All data will be lost! Are you sure you want to delete this relay?'
)
.onOk(async () => {
try {
await LNbits.api.request(
'DELETE',
'/nostrrelay/api/v1/relay/' + this.relayId,
this.adminkey
)
this.$emit('relay-deleted', this.relayId)
} catch (error) {
console.warn(error)
LNbits.utils.notifyApiError(error)
}
})
}
},