fix: only allow zones with the same currency to be selected

This commit is contained in:
Vlad Stan 2023-03-02 10:28:10 +02:00
parent 5972c44ad1
commit 16a6104b25
3 changed files with 24 additions and 7 deletions

View file

@ -47,8 +47,8 @@
v-model="zoneDialog.data.countries"
></q-select>
<q-select
v-if="!zoneDialog.data.id"
style="width: 100px"
:disabled="!!zoneDialog.data.id"
:readonly="!!zoneDialog.data.id"
filled
dense
v-model="zoneDialog.data.currency"

View file

@ -112,6 +112,14 @@
v-model.trim="stallDialog.data.name"
label="Name"
></q-input>
<q-input
filled
dense
v-model.trim="stallDialog.data.description"
type="textarea"
rows="3"
label="Description"
></q-input>
<q-select
filled
dense
@ -130,7 +138,7 @@
:options="currencies"
></q-select>
<q-select
:options="zoneOptions"
:options="filteredZoneOptions"
filled
dense
multiple

View file

@ -14,6 +14,7 @@ async function stallList(path) {
show: false,
data: {
name: '',
description: '',
wallet: null,
currency: 'sat',
shippingZones: []
@ -22,16 +23,23 @@ async function stallList(path) {
zoneOptions: []
}
},
computed: {
filteredZoneOptions: function () {
return this.zoneOptions.filter(
z => z.currency === this.stallDialog.data.currency
)
}
},
methods: {
sendStallFormData: async function () {
console.log('### sendStallFormData', this.stallDialog.data)
await this.createStall({
name: this.stallDialog.data.name,
wallet: this.stallDialog.data.wallet,
currency: this.stallDialog.data.currency,
shipping_zones: this.stallDialog.data.shippingZones,
config: {}
config: {
description: this.stallDialog.data.description
}
})
},
createStall: async function (stall) {
@ -75,7 +83,7 @@ async function stallList(path) {
this.zoneOptions = data.map(z => ({
...z,
label: z.name
? `${z.name} (${z.countries.join(', ')}})`
? `${z.name} (${z.countries.join(', ')})`
: z.countries.join(', ')
}))
console.log('### this.zoneOptions', this.zoneOptions)
@ -88,6 +96,7 @@ async function stallList(path) {
await this.getZones()
this.stallDialog.data = {
name: '',
description: '',
wallet: null,
currency: 'sat',
shippingZones: []