Lines 37-55
import { APIClient } from "../../fetch/api-client"
Link Here
|
37 |
export default { |
37 |
export default { |
38 |
setup() { |
38 |
setup() { |
39 |
const vendorStore = inject("vendorStore") |
39 |
const vendorStore = inject("vendorStore") |
40 |
|
40 |
const { config } = storeToRefs(vendorStore) |
41 |
const AVStore = inject("AVStore") |
|
|
42 |
|
41 |
|
43 |
const mainStore = inject("mainStore") |
42 |
const mainStore = inject("mainStore") |
44 |
|
|
|
45 |
const { loading, loaded, setError } = mainStore |
43 |
const { loading, loaded, setError } = mainStore |
|
|
44 |
const AVStore = inject("AVStore") |
46 |
|
45 |
|
47 |
const permissionsStore = inject("permissionsStore") |
46 |
const permissionsStore = inject("permissionsStore") |
48 |
const { userPermissions } = storeToRefs(permissionsStore) |
47 |
const { userPermissions } = storeToRefs(permissionsStore) |
49 |
|
48 |
|
50 |
return { |
49 |
return { |
51 |
vendorStore, |
50 |
vendorStore, |
52 |
AVStore, |
|
|
53 |
setError, |
51 |
setError, |
54 |
loading, |
52 |
loading, |
55 |
loaded, |
53 |
loaded, |
Lines 99-159
export default {
Link Here
|
99 |
this.initialized = true |
97 |
this.initialized = true |
100 |
}) |
98 |
}) |
101 |
}, |
99 |
}, |
102 |
beforeCreate() { |
|
|
103 |
this.loading() |
104 |
|
105 |
const fetchConfig = () => { |
106 |
let promises = [] |
107 |
|
108 |
const av_client = APIClient.authorised_values |
109 |
const authorised_values = { |
110 |
vendor_types: "VENDOR_TYPE", |
111 |
vendor_interface_types: "VENDOR_INTERFACE_TYPE", |
112 |
vendor_payment_methods: "VENDOR_PAYMENT_METHOD", |
113 |
lang: "LANG", |
114 |
} |
115 |
|
116 |
let av_cat_array = Object.keys(authorised_values).map(function ( |
117 |
av_cat |
118 |
) { |
119 |
return '"' + authorised_values[av_cat] + '"' |
120 |
}) |
121 |
|
122 |
promises.push( |
123 |
av_client.values |
124 |
.getCategoriesWithValues(av_cat_array) |
125 |
.then(av_categories => { |
126 |
Object.entries(authorised_values).forEach( |
127 |
([av_var, av_cat]) => { |
128 |
const av_match = av_categories.find( |
129 |
element => element.category_name == av_cat |
130 |
) |
131 |
this.AVStore[av_var] = |
132 |
av_match.authorised_values |
133 |
} |
134 |
) |
135 |
}) |
136 |
) |
137 |
|
138 |
return Promise.all(promises) |
139 |
} |
140 |
|
141 |
fetchConfig().then(() => { |
142 |
this.vendorStore.currencies = currencies |
143 |
this.vendorStore.gstValues = gstValues.map(gv => { |
144 |
return { |
145 |
label: `${(gv.option * 100).toFixed(2)}%`, |
146 |
value: gv.option, |
147 |
} |
148 |
}) |
149 |
this.loaded() |
150 |
this.initialized = true |
151 |
}) |
152 |
}, |
153 |
data() { |
100 |
data() { |
154 |
this.userPermissions = userPermissions |
101 |
this.userPermissions = userPermissions |
155 |
return { |
102 |
return { |
156 |
initialized: true, |
103 |
initialized: false, |
157 |
} |
104 |
} |
158 |
}, |
105 |
}, |
159 |
methods: {}, |
106 |
methods: {}, |