diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 137b46400..c6bade1a1 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -117,10 +117,6 @@ export default { return {} }, }, - creation: { - type: Array, - required: true, - }, }, data() { return { @@ -129,6 +125,7 @@ export default { rangeMin: 0, rangeMax: 1000, selected: '', + userId: this.item.userId, } }, methods: { @@ -167,6 +164,10 @@ export default { this.$refs.creationForm.reset() this.value = 0 }) + .finally(() => { + this.$apollo.queries.OpenCreations.refetch() + this.selected = '' + }) }, }, watch: { diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index fbc60df15..1d22460c7 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -75,7 +75,6 @@ diff --git a/admin/src/graphql/adminOpenCreations.js b/admin/src/graphql/adminOpenCreations.js new file mode 100644 index 000000000..0e766c0f7 --- /dev/null +++ b/admin/src/graphql/adminOpenCreations.js @@ -0,0 +1,11 @@ +import gql from 'graphql-tag' + +export const adminOpenCreations = gql` + query ($userId: Int!) { + adminOpenCreations(userId: $userId) { + year + month + amount + } + } +` diff --git a/admin/src/graphql/openCreations.js b/admin/src/graphql/openCreations.js deleted file mode 100644 index 010ed62df..000000000 --- a/admin/src/graphql/openCreations.js +++ /dev/null @@ -1,11 +0,0 @@ -import gql from 'graphql-tag' - -export const openCreations = gql` - query ($userId: Int) { - openCreations(userId: $userId) { - year - month - amount - } - } -` diff --git a/admin/src/mixins/creationMonths.js b/admin/src/mixins/creationMonths.js index c26dc5b02..57e0ab17e 100644 --- a/admin/src/mixins/creationMonths.js +++ b/admin/src/mixins/creationMonths.js @@ -1,9 +1,11 @@ +import { adminOpenCreations } from '../graphql/adminOpenCreations' + export const creationMonths = { - props: { - creation: { - type: Array, - default: () => [1000, 1000, 1000], - }, + data() { + return { + creation: [1000, 1000, 1000], + userId: 0, + } }, computed: { creationDates() { @@ -38,4 +40,23 @@ export const creationMonths = { return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ') }, }, + apollo: { + OpenCreations: { + query() { + return adminOpenCreations + }, + variables() { + return { + userId: this.userId, + } + }, + fetchPolicy: 'no-cache', + update({ adminOpenCreations }) { + this.creation = adminOpenCreations.map((obj) => obj.amount) + }, + error({ message }) { + this.toastError(message) + }, + }, + }, }