feat: update and delete stall
This commit is contained in:
parent
6d8488d2c3
commit
c1a0e721e6
2 changed files with 80 additions and 29 deletions
|
|
@ -85,14 +85,14 @@
|
|||
<div v-if="stall"></div>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
<!-- <div class="row items-center q-mt-md q-mb-lg">
|
||||
<div class="row items-center q-mt-md q-mb-lg">
|
||||
<div class="col-6 q-pr-lg">
|
||||
<q-btn
|
||||
unelevated
|
||||
color="secondary"
|
||||
class="float-left"
|
||||
@click="updateRelay()"
|
||||
>Update Relay</q-btn
|
||||
>Update Stall</q-btn
|
||||
>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
|
|
@ -102,8 +102,8 @@
|
|||
icon="cancel"
|
||||
class="float-right"
|
||||
@click="deleteRelay()"
|
||||
>Delete Relay</q-btn
|
||||
>Delete Stall</q-btn
|
||||
>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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,19 +43,61 @@ 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