mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
change computed lastMonthObject
This commit is contained in:
parent
6dd11a961f
commit
b0df5996e0
@ -57,7 +57,6 @@
|
||||
<b-button class="test-submit" type="submit" variant="primary" :disabled="disable">
|
||||
{{ $t('contribution.submit') }}
|
||||
</b-button>
|
||||
{{ form }}
|
||||
</div>
|
||||
</b-form>
|
||||
</div>
|
||||
@ -102,19 +101,12 @@ export default {
|
||||
return false
|
||||
},
|
||||
lastMonthObject() {
|
||||
let obj = {
|
||||
month: new Date(this.lastMonth).toLocaleString(this.$i18n.locale, { month: 'long' }),
|
||||
year: new Date().getFullYear(),
|
||||
creation: this.$store.state.creation[1],
|
||||
}
|
||||
// If the current month is January then the current year must be counted back by -1.
|
||||
if (new Date().getMonth === 1) {
|
||||
obj = {
|
||||
// new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month
|
||||
const obj = {
|
||||
month: new Date(this.lastMonth).toLocaleString(this.$i18n.locale, { month: 'long' }),
|
||||
year: new Date().getFullYear() - 1,
|
||||
year: new Date().getMonth === 1 ? new Date().getFullYear() - 1 : new Date().getFullYear(),
|
||||
creation: this.$store.state.creation[1],
|
||||
}
|
||||
}
|
||||
return this.$t('contribution.formText.lastMonth', obj)
|
||||
},
|
||||
thisMonthObject() {
|
||||
|
||||
@ -162,3 +162,25 @@ export const listTransactionLinks = gql`
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const listContributions = gql`
|
||||
query(
|
||||
$currentPage: Int = 1
|
||||
$pageSize: Int = 25
|
||||
$order: Order = DESC
|
||||
$filterConfirmed: Boolean = false
|
||||
) {
|
||||
listContributions(
|
||||
currentPage: $currentPage
|
||||
pageSize: $pageSize
|
||||
order: $order
|
||||
filterConfirmed: $filterConfirmed
|
||||
) {
|
||||
id
|
||||
amount
|
||||
memo
|
||||
createdAt
|
||||
deletedAt
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
import ContributionForm from '@/components/Contributions/ContributionForm.vue'
|
||||
import ContributionList from '@/components/Contributions/ContributionList.vue'
|
||||
import { createContribution } from '@/graphql/mutations'
|
||||
import { listContributions } from '@/graphql/queries'
|
||||
|
||||
export default {
|
||||
name: 'Community',
|
||||
@ -29,39 +30,18 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
items: [
|
||||
{
|
||||
id: '0',
|
||||
date: '07/06/2022',
|
||||
memo: 'Ich habe 10 Stunden die Elbwiesen von Müll befreit.',
|
||||
amount: 200,
|
||||
status: 'pending',
|
||||
},
|
||||
{
|
||||
id: '1',
|
||||
date: '06/22/2022',
|
||||
memo: 'Ich habe 30 Stunden Frau Müller beim EInkaufen und im Haushalt geholfen.',
|
||||
amount: 600,
|
||||
status: 'pending',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
date: '05/04/2022',
|
||||
memo:
|
||||
'Ich habe 50 Stunden den Nachbarkindern bei ihren Hausaufgaben geholfen und Nachhilfeunterricht gegeben.',
|
||||
amount: 1000,
|
||||
status: 'pending',
|
||||
},
|
||||
],
|
||||
currentPage: 1,
|
||||
pageSize: 25,
|
||||
items: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setContribution(data) {
|
||||
// console.log('setContribution', data)
|
||||
this.$apollo
|
||||
.query({
|
||||
.mutate({
|
||||
fetchPolicy: 'no-cache',
|
||||
query: createContribution,
|
||||
mutation: createContribution,
|
||||
variables: {
|
||||
creationDate: data.date,
|
||||
memo: data.memo,
|
||||
@ -76,6 +56,31 @@ export default {
|
||||
this.toastError(err.message)
|
||||
})
|
||||
},
|
||||
getListContributions(data) {
|
||||
this.$apollo
|
||||
.query({
|
||||
fetchPolicy: 'no-cache',
|
||||
query: listContributions,
|
||||
variables: {
|
||||
currentPage: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
console.log('result', result.data)
|
||||
const {
|
||||
data: { listContributions },
|
||||
} = result
|
||||
this.items = listContributions
|
||||
// this.toastSuccess(result.data)
|
||||
})
|
||||
.catch((err) => {
|
||||
this.toastError(err.message)
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getListContributions()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user