mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
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:
parent
7d95809f6e
commit
f51ad1131b
14
webapp/graphql/Donations.js
Normal file
14
webapp/graphql/Donations.js
Normal 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
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
@ -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))
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user