mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
pre-fill donation input fields with data from query
This commit is contained in:
parent
cbab34e83c
commit
bdeb208556
@ -1,5 +1,14 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const DonationsQuery = () => gql`
|
||||
query {
|
||||
Donations {
|
||||
goal
|
||||
progress
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const UpdateDonations = () => {
|
||||
return gql`
|
||||
mutation($goal: Int, $progress: Int) {
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { UpdateDonations } from '~/graphql/Donations'
|
||||
import { DonationsQuery, UpdateDonations } from '~/graphql/Donations'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -44,5 +44,19 @@ export default {
|
||||
.catch(error => this.$toast.error(error.message))
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Donations: {
|
||||
query() {
|
||||
return DonationsQuery()
|
||||
},
|
||||
result({ data: { Donations } }) {
|
||||
const { goal, progress } = Donations[0]
|
||||
this.formData = {
|
||||
goal,
|
||||
progress,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user