feat: delete product

This commit is contained in:
Vlad Stan 2023-03-02 18:15:17 +02:00
parent 4bad9655be
commit 1e6aaf8436
4 changed files with 51 additions and 19 deletions

View file

@ -17,7 +17,7 @@ async function stallDetails(path) {
],
data: function () {
return {
tab: 'info',
tab: 'products',
stall: null,
products: [],
productDialog: {
@ -271,6 +271,30 @@ async function stallDetails(path) {
LNbits.utils.notifyApiError(error)
}
},
deleteProduct: async function (productId) {
LNbits.utils
.confirmDialog('Are you sure you want to delete this product?')
.onOk(async () => {
try {
await LNbits.api.request(
'DELETE',
'/nostrmarket/api/v1/product/' + productId,
this.adminkey
)
this.products = _.reject(this.products, function (obj) {
return obj.id === productId
})
this.$q.notify({
type: 'positive',
message: 'Product deleted',
timeout: 5000
})
} catch (error) {
console.warn(error)
LNbits.utils.notifyApiError(error)
}
})
},
showNewProductDialog: async function () {
this.productDialog.showDialog = true
}