list all contribution in tab

This commit is contained in:
ogerly 2023-02-01 20:06:19 +01:00
parent 452f68b032
commit b9f4eb5d84
3 changed files with 80 additions and 1 deletions

View File

@ -1,6 +1,12 @@
<template>
<div class="open-creations-table">
<b-table-lite :items="items" :fields="fields" caption-top striped hover stacked="md">
<template #cell(state)="row">
<b-icon v-if="row.item.state === 'IN_PROGRESS'" icon="bell-fill"></b-icon>
<b-icon v-if="row.item.state === 'PENDING'" icon="bell-fill"></b-icon>
<b-icon v-if="row.item.state === 'CONFIRMED'" icon="check"></b-icon>
<b-icon v-if="row.item.state === 'DELETED'" icon="trash"></b-icon>
</template>
<template #cell(bookmark)="row">
<b-button
variant="danger"
@ -37,6 +43,9 @@
</b-button>
</div>
</template>
<template #cell(chatCreation)="row">
{{ row.item.messagesCount }}
</template>
<template #cell(deny)="row">
<div v-if="$store.state.moderator.id !== row.item.userId">
<b-button

View File

@ -0,0 +1,24 @@
import gql from 'graphql-tag'
export const listAllContributions = gql`
query ($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) {
listAllContributions(currentPage: $currentPage, pageSize: $pageSize, order: $order) {
contributionCount
contributionList {
id
firstName
lastName
amount
memo
createdAt
contributionDate
confirmedAt
confirmedBy
state
messagesCount
deniedAt
deniedBy
}
}
}
`

View File

@ -22,8 +22,13 @@
<b-tab :title="$t('contributions.denied')">
<p>{{ $t('contributions.denied') }}</p>
</b-tab>
<b-tab :title="$t('contributions.all')">
<b-tab :title="$t('contributions.all')" @click="$apollo.queries.AllContributions.refetch()">
<p>{{ $t('contributions.all') }}</p>
<open-creations-table
class="mt-4"
:items="allCreations"
:fields="fieldsAllContributions"
/>
</b-tab>
</b-tabs>
</div>
@ -57,6 +62,7 @@
import Overlay from '../components/Overlay.vue'
import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue'
import { listUnconfirmedContributions } from '../graphql/listUnconfirmedContributions'
import { listAllContributions } from '../graphql/listAllContributions'
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
import { confirmContribution } from '../graphql/confirmContribution'
import { denyContribution } from '../graphql/denyContribution'
@ -70,6 +76,7 @@ export default {
data() {
return {
pendingCreations: [],
allCreations: [],
overlay: false,
item: {},
variant: 'confirm',
@ -172,6 +179,30 @@ export default {
{ key: 'confirm', label: this.$t('save') },
]
},
fieldsAllContributions() {
return [
{ key: 'state', label: 'state' },
{ key: 'messagesCount', label: 'mc' },
{ key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'amount',
label: this.$t('creation'),
formatter: (value) => {
return value + ' GDD'
},
},
{ key: 'memo', label: this.$t('text'), class: 'text-break' },
{
key: 'date',
label: this.$t('date'),
formatter: (value) => {
return this.$d(new Date(value), 'short')
},
},
{ key: 'chatCreation', label: this.$t('chat') },
]
},
overlayTitle() {
return `overlay.${this.variant}.title`
},
@ -218,6 +249,21 @@ export default {
this.toastError(message)
},
},
AllContributions: {
query() {
return listAllContributions
},
variables() {
// may be at some point we need a pagination here
return {}
},
update({ listAllContributions }) {
this.allCreations = listAllContributions.contributionList
},
error({ message }) {
this.toastError(message)
},
},
},
}
</script>