feat: update and delete stall
This commit is contained in:
parent
6d8488d2c3
commit
c1a0e721e6
2 changed files with 80 additions and 29 deletions
|
|
@ -27,6 +27,15 @@ async function stallDetails(path) {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
mapStall: function(stall) {
|
||||
stall.shipping_zones.forEach(
|
||||
z =>
|
||||
(z.label = z.name
|
||||
? `${z.name} (${z.countries.join(', ')})`
|
||||
: z.countries.join(', '))
|
||||
)
|
||||
return stall
|
||||
},
|
||||
getStall: async function () {
|
||||
try {
|
||||
const {data} = await LNbits.api.request(
|
||||
|
|
@ -34,18 +43,60 @@ async function stallDetails(path) {
|
|||
'/nostrmarket/api/v1/stall/' + this.stallId,
|
||||
this.inkey
|
||||
)
|
||||
this.stall = data
|
||||
this.stall.shipping_zones.forEach(
|
||||
z =>
|
||||
(z.label = z.name
|
||||
? `${z.name} (${z.countries.join(', ')})`
|
||||
: z.countries.join(', '))
|
||||
)
|
||||
this.stall = this.mapStall(data)
|
||||
|
||||
console.log('### this.stall', this.stall)
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
}
|
||||
},
|
||||
updateRelay: async function () {
|
||||
try {
|
||||
const {data} = await LNbits.api.request(
|
||||
'PUT',
|
||||
'/nostrmarket/api/v1/stall/' + this.stallId,
|
||||
this.adminkey,
|
||||
this.stall
|
||||
)
|
||||
this.stall = this.mapStall(data)
|
||||
this.$emit('stall-updated', this.stall)
|
||||
this.$q.notify({
|
||||
type: 'positive',
|
||||
message: 'Stall Updated',
|
||||
timeout: 5000
|
||||
})
|
||||
} catch (error) {
|
||||
console.warn(error)
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
},
|
||||
deleteRelay: function () {
|
||||
LNbits.utils
|
||||
.confirmDialog(
|
||||
`
|
||||
Products and orders will be deleted also!
|
||||
Are you sure you want to delete this relay?
|
||||
`
|
||||
)
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await LNbits.api.request(
|
||||
'DELETE',
|
||||
'/nostrmarket/api/v1/stall/' + this.stallId,
|
||||
this.adminkey
|
||||
)
|
||||
this.$emit('stall-deleted', this.stallId)
|
||||
this.$q.notify({
|
||||
type: 'positive',
|
||||
message: 'Stall Deleted',
|
||||
timeout: 5000
|
||||
})
|
||||
} catch (error) {
|
||||
console.warn(error)
|
||||
LNbits.utils.notifyApiError(error)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
created: async function () {
|
||||
await this.getStall()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue