This commit is contained in:
j3d1 2024-06-15 17:39:41 +02:00
parent ab88e50d82
commit da075d162f
2 changed files with 20 additions and 7 deletions

View file

@ -20,7 +20,8 @@ const store = createStore({
groups: [], groups: [],
state_options: [], state_options: [],
messageTemplates: [], messageTemplates: [],
messageTemplatesVariables: [], messageTemplateVariables: [],
shippingCodes: null,
lastEvent: '37C3', lastEvent: '37C3',
lastUsed: {}, lastUsed: {},
@ -209,6 +210,9 @@ const store = createStore({
setMessageTemplateVariables(state, variables) { setMessageTemplateVariables(state, variables) {
state.messageTemplateVariables = variables; state.messageTemplateVariables = variables;
}, },
setShippingCodes(state, codes) {
state.shippingCodes = codes;
},
}, },
actions: { actions: {
async login({commit}, {username, password, remember}) { async login({commit}, {username, password, remember}) {
@ -450,6 +454,12 @@ const store = createStore({
if (data && success) { if (data && success) {
commit('setMessageTemplates', data); commit('setMessageTemplates', data);
} }
},
async fetchShippingCodes({commit, state}) {
const {data, success} = await http.get('/2/shipping_codes/', state.user.token);
if (data && success) {
commit('setShippingCodes', data);
}
} }
}, },
plugins: [ plugins: [

View file

@ -1,12 +1,12 @@
<template> <template>
<Table <Table
:columns="['slug', 'name']" :columns="['type', 'code']"
:items="events" :items="shippingCodes"
:keyName="'slug'" :keyName="'code'"
> >
<template #actions="{ item }"> <template #actions="{ item }">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-secondary" @click.stop="changeEvent(item)"> <button class="btn btn-secondary" @click.stop="alert(item)">
<font-awesome-icon icon="archive"/> <font-awesome-icon icon="archive"/>
use use
</button> </button>
@ -26,8 +26,11 @@ import Table from '@/components/Table';
export default { export default {
name: 'Shipping', name: 'Shipping',
components: {Table}, components: {Table},
computed: mapState(['events']), computed: mapState(['shippingCodes']),
methods: mapActions(['changeEvent']), methods: mapActions(['fetchShippingCodes']),
mounted() {
this.fetchShippingCodes();
},
}; };
</script> </script>