UpdateDonations from admin/donations

@alina-beck I'm not 100% satisfied with this at the moment. I think that
the admin could have the goal and progress initialized from a query for
the Donations, and be able to update if one of them changed... what do
you think?
This commit is contained in:
mattwr18 2019-11-11 19:16:07 +01:00
parent 7d95809f6e
commit f51ad1131b
2 changed files with 31 additions and 4 deletions

View File

@ -0,0 +1,14 @@
import gql from 'graphql-tag'
export const UpdateDonations = () => {
return gql`
mutation($goal: Int, $progress: Int) {
UpdateDonations(goal: $goal, progress: $progress) {
id
goal
progress
updatedAt
}
}
`
}

View File

@ -16,19 +16,32 @@
</template>
<script>
import { UpdateDonations } from '~/graphql/Donations'
export default {
data() {
return {
formData: {
goal: '',
progress: '',
goal: null,
progress: null,
},
}
},
methods: {
submit() {
// TODO: save form data... somewhere
console.log('submitting donations form')
const { goal, progress } = this
this.$apollo
.mutate({
mutation: UpdateDonations(),
variables: {
goal,
progress,
},
})
.then(() => {
this.$toast.success('yay!!')
})
.catch(error => this.$toast.error(error.message))
},
},
}