add date, pass date to server

This commit is contained in:
Moriz Wahl 2022-01-20 15:57:13 +01:00
parent f9b5df8720
commit 4142e6df9f
6 changed files with 78 additions and 70 deletions

View File

@ -199,10 +199,11 @@ export default {
// eslint-disable-next-line no-console
console.log('SUBMIT CREATION => ' + this.type + ' >> für VIELE ' + i + ' Mitglieder')
this.submitObj = []
const date = new Date(this.radioSelected.date)
this.items.forEach((item) => {
this.submitObj.push({
email: item.email,
creationDate: this.radioSelected.long,
creationDate: date.toISOString(),
amount: Number(this.value),
memo: this.text,
moderator: Number(this.$store.state.moderator.id),
@ -234,9 +235,10 @@ export default {
this.$toasted.error(error.message)
})
} else if (this.type === 'singleCreation') {
const date = new Date(this.radioSelected.date)
this.submitObj = {
email: this.item.email,
creationDate: this.radioSelected.long,
creationDate: date.toISOString(),
amount: Number(this.value),
memo: this.text,
moderator: Number(this.$store.state.moderator.id),
@ -290,6 +292,7 @@ export default {
short: this.$d(this.now, 'month'),
long: this.$d(this.now, 'short'),
year: this.$d(this.now, 'year'),
date: this.now,
}
},
lastMonth() {
@ -299,6 +302,7 @@ export default {
short: this.$d(lastMonth, 'month'),
long: this.$d(lastMonth, 'short'),
year: this.$d(lastMonth, 'year'),
date: lastMonth,
}
},
beforeLastMonth() {
@ -308,6 +312,7 @@ export default {
short: this.$d(beforeLastMonth, 'month'),
long: this.$d(beforeLastMonth, 'short'),
year: this.$d(beforeLastMonth, 'year'),
date: beforeLastMonth,
}
},
},

View File

@ -108,7 +108,7 @@ describe('EditCreationFormular', () => {
expect.objectContaining({
variables: {
amount: 90,
creationDate: '2021-10-31',
creationDate: '2021-10-31T23:00:00.000Z',
email: 'bob@baumeister.de',
id: 0,
memo: 'Test create coins',
@ -180,7 +180,7 @@ describe('EditCreationFormular', () => {
expect.objectContaining({
variables: {
amount: 90,
creationDate: '2021-11-30',
creationDate: '2021-11-30T23:00:00.000Z',
email: 'bob@baumeister.de',
id: 0,
memo: 'Test create coins',
@ -236,7 +236,7 @@ describe('EditCreationFormular', () => {
expect.objectContaining({
variables: {
amount: 90,
creationDate: '2022-01-20',
creationDate: expect.stringContaining('2022-01-20T'),
email: 'bob@baumeister.de',
id: 0,
memo: 'Test create coins',

View File

@ -169,10 +169,11 @@ export default {
this.rangeMax = this.creation[index]
},
submitCreation() {
const date = new Date(this.radioSelected.date)
this.submitObj = {
id: this.item.id,
email: this.item.email,
creationDate: this.radioSelected.long,
creationDate: date.toISOString(),
amount: Number(this.value),
memo: this.text,
moderator: Number(this.$store.state.moderator.id),
@ -221,6 +222,7 @@ export default {
return {
short: this.$d(this.now, 'month'),
long: this.$d(this.now, 'short'),
date: this.now,
}
},
lastMonth() {
@ -229,6 +231,7 @@ export default {
return {
short: this.$d(lastMonth, 'month'),
long: this.$d(lastMonth, 'short'),
date: lastMonth,
}
},
beforeLastMonth() {
@ -237,6 +240,7 @@ export default {
return {
short: this.$d(beforeLastMonth, 'month'),
long: this.$d(beforeLastMonth, 'short'),
date: beforeLastMonth,
}
},
},

View File

@ -65,32 +65,6 @@ export default {
data() {
return {
showArrays: false,
Searchfields: [
{ key: 'bookmark', label: 'bookmark' },
{ key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'creation',
label: this.creationLabel,
formatter: (value, key, item) => {
return value.join(' | ')
},
},
{ key: 'email', label: this.$t('e_mail') },
],
fields: [
{ key: 'email', label: this.$t('e_mail') },
{ key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'creation',
label: this.creationLabel,
formatter: (value, key, item) => {
return value.join(' | ')
},
},
{ key: 'bookmark', label: this.$t('remove') },
],
itemsList: [],
itemsMassCreation: [],
radioSelectedMass: '',
@ -156,6 +130,36 @@ export default {
},
},
computed: {
Searchfields() {
return [
{ key: 'bookmark', label: 'bookmark' },
{ key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'creation',
label: this.creationLabel,
formatter: (value, key, item) => {
return value.join(' | ')
},
},
{ key: 'email', label: this.$t('e_mail') },
]
},
fields() {
return [
{ key: 'email', label: this.$t('e_mail') },
{ key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'creation',
label: this.creationLabel,
formatter: (value, key, item) => {
return value.join(' | ')
},
},
{ key: 'bookmark', label: this.$t('remove') },
]
},
creationLabel() {
const now = new Date(this.now)
const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1)

View File

@ -24,22 +24,13 @@ const toastErrorMock = jest.fn()
const mocks = {
$t: jest.fn((t) => t),
$d: jest.fn((d) => d),
$apollo: {
query: apolloQueryMock,
},
$toasted: {
error: toastErrorMock,
},
$moment: jest.fn(() => {
return {
format: jest.fn((m) => m),
subtract: jest.fn(() => {
return {
format: jest.fn((m) => m),
}
}),
}
}),
}
describe('UserSearch', () => {

View File

@ -44,41 +44,14 @@ export default {
data() {
return {
showArrays: false,
fields: [
{ key: 'email', label: this.$t('e_mail') },
{ key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'creation',
label: [
this.$moment().subtract(2, 'month').format('MMM'),
this.$moment().subtract(1, 'month').format('MMM'),
this.$moment().format('MMM'),
].join(' | '),
formatter: (value, key, item) => {
return value.join(' | ')
},
},
{ key: 'show_details', label: this.$t('details') },
{ key: 'confirm_mail', label: this.$t('confirmed') },
{ key: 'transactions_list', label: this.$t('transaction') },
],
searchResult: [],
massCreation: [],
criteria: '',
currentMonth: {
short: this.$moment().format('MMMM'),
},
lastMonth: {
short: this.$moment().subtract(1, 'month').format('MMMM'),
},
beforeLastMonth: {
short: this.$moment().subtract(2, 'month').format('MMMM'),
},
filterCheckedEmails: false,
rows: 0,
currentPage: 1,
perPage: 25,
now: Date.now(),
}
},
methods: {
@ -111,6 +84,37 @@ export default {
this.getUsers()
},
},
computed: {
lastMonthDate() {
const now = new Date(this.now)
return new Date(now.getFullYear(), now.getMonth() - 1, 1)
},
beforeLastMonthDate() {
const now = new Date(this.now)
return new Date(now.getFullYear(), now.getMonth() - 2, 1)
},
fields() {
return [
{ key: 'email', label: this.$t('e_mail') },
{ key: 'firstName', label: this.$t('firstname') },
{ key: 'lastName', label: this.$t('lastname') },
{
key: 'creation',
label: [
this.$d(this.beforeLastMonthDate, 'monthShort'),
this.$d(this.lastMonthDate, 'monthShort'),
this.$d(this.now, 'monthShort'),
].join(' | '),
formatter: (value, key, item) => {
return value.join(' | ')
},
},
{ key: 'show_details', label: this.$t('details') },
{ key: 'confirm_mail', label: this.$t('confirmed') },
{ key: 'transactions_list', label: this.$t('transaction') },
]
},
},
created() {
this.getUsers()
},