mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
update GDT to use enums and switch-case
This commit is contained in:
parent
cc4571e4d3
commit
2630de425d
@ -30,7 +30,7 @@ export class GdtResolver {
|
||||
if (!resultGDT.success) {
|
||||
throw new Error(resultGDT.data)
|
||||
}
|
||||
|
||||
console.log(resultGDT.data)
|
||||
return new GdtEntryList(resultGDT.data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
</b-row>
|
||||
|
||||
<!-- Message-->
|
||||
<b-row v-if="comment && gdtEntryType !== 7">
|
||||
<b-row v-if="comment && !isGlobalModificator">
|
||||
<b-col cols="6" class="text-right">
|
||||
{{ $t('form.memo') }}
|
||||
</b-col>
|
||||
@ -72,6 +72,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import TransactionCollapse from './TransactionCollapse.vue'
|
||||
import { GdtEntryType } from '../graphql/enums'
|
||||
|
||||
export default {
|
||||
name: 'Transaction',
|
||||
@ -82,42 +83,52 @@ export default {
|
||||
amount: { type: Number },
|
||||
date: { type: String },
|
||||
comment: { type: String },
|
||||
gdtEntryType: { type: Number, default: 1 },
|
||||
gdtEntryType: { type: String, default: GdtEntryType.FORM },
|
||||
factor: { type: Number },
|
||||
gdt: { type: Number },
|
||||
},
|
||||
computed: {
|
||||
isGlobalModificator: function () {
|
||||
return this.gdtEntryType === GdtEntryType.GLOBAL_MODIFICATOR
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getLinesByType(givenType) {
|
||||
if (givenType === 2 || givenType === 3 || givenType === 5 || givenType === 6) givenType = 1
|
||||
|
||||
const linesByType = {
|
||||
1: {
|
||||
icon: 'heart',
|
||||
iconclasses: 'gradido-global-color-accent m-mb-1 font2em',
|
||||
description: this.$t('gdt.contribution'),
|
||||
descriptiontext: this.$n(this.amount, 'decimal') + ' €',
|
||||
credittext: this.$n(this.gdt, 'decimal') + ' GDT',
|
||||
},
|
||||
4: {
|
||||
icon: 'person-check',
|
||||
iconclasses: 'gradido-global-color-accent m-mb-1 font2em',
|
||||
description: this.$t('gdt.recruited-member'),
|
||||
descriptiontext: '5%',
|
||||
credittext: this.$n(this.amount, 'decimal') + ' GDT',
|
||||
},
|
||||
7: {
|
||||
icon: 'gift',
|
||||
iconclasses: 'gradido-global-color-accent m-mb-1 font2em',
|
||||
description: this.$t('gdt.gdt-received'),
|
||||
descriptiontext: this.comment,
|
||||
credittext: this.$n(this.gdt, 'decimal') + ' GDT',
|
||||
},
|
||||
switch (givenType) {
|
||||
case GdtEntryType.FORM:
|
||||
case GdtEntryType.CVS:
|
||||
case GdtEntryType.ELOPAGE:
|
||||
case GdtEntryType.DIGISTORE:
|
||||
case GdtEntryType.CVS2: {
|
||||
return {
|
||||
icon: 'heart',
|
||||
iconclasses: 'gradido-global-color-accent m-mb-1 font2em',
|
||||
description: this.$t('gdt.contribution'),
|
||||
descriptiontext: this.$n(this.amount, 'decimal') + ' €',
|
||||
credittext: this.$n(this.gdt, 'decimal') + ' GDT',
|
||||
}
|
||||
}
|
||||
case GdtEntryType.ELOPAGE_PUBLISHER: {
|
||||
return {
|
||||
icon: 'person-check',
|
||||
iconclasses: 'gradido-global-color-accent m-mb-1 font2em',
|
||||
description: this.$t('gdt.recruited-member'),
|
||||
descriptiontext: '5%',
|
||||
credittext: this.$n(this.amount, 'decimal') + ' GDT',
|
||||
}
|
||||
}
|
||||
case GdtEntryType.GLOBAL_MODIFICATOR: {
|
||||
return {
|
||||
icon: 'gift',
|
||||
iconclasses: 'gradido-global-color-accent m-mb-1 font2em',
|
||||
description: this.$t('gdt.gdt-received'),
|
||||
descriptiontext: this.comment,
|
||||
credittext: this.$n(this.gdt, 'decimal') + ' GDT',
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new Error('no lines for this type: ' + givenType)
|
||||
}
|
||||
|
||||
const type = linesByType[givenType]
|
||||
|
||||
if (type) return type
|
||||
throw new Error('no lines for this type: ' + givenType)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -23,58 +23,65 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { GdtEntryType } from '../graphql/enums'
|
||||
|
||||
export default {
|
||||
name: 'TransactionCollapse',
|
||||
props: {
|
||||
amount: { type: Number },
|
||||
gdtEntryType: { type: Number, default: 1 },
|
||||
gdtEntryType: { type: String, default: GdtEntryType.FORM },
|
||||
factor: { type: Number },
|
||||
gdt: { type: Number },
|
||||
},
|
||||
methods: {
|
||||
getLinesByType(givenType) {
|
||||
if (givenType === 2 || givenType === 3 || givenType === 5 || givenType === 6) givenType = 1
|
||||
|
||||
const linesByType = {
|
||||
1: {
|
||||
headline: this.$t('gdt.calculation'),
|
||||
first: this.$t('gdt.factor'),
|
||||
firstMath: this.factor + ' GDT pro €',
|
||||
second: this.$t('gdt.formula'),
|
||||
secondMath:
|
||||
this.$n(this.amount, 'decimal') +
|
||||
' € * ' +
|
||||
this.factor +
|
||||
' GDT / € = ' +
|
||||
this.$n(this.gdt, 'decimal') +
|
||||
' GDT',
|
||||
},
|
||||
4: {
|
||||
headline: this.$t('gdt.publisher'),
|
||||
first: null,
|
||||
firstMath: null,
|
||||
second: null,
|
||||
secondMath: null,
|
||||
},
|
||||
7: {
|
||||
headline: this.$t('gdt.conversion-gdt-euro'),
|
||||
first: this.$t('gdt.raise'),
|
||||
firstMath: this.factor * 100 + ' % ',
|
||||
second: this.$t('gdt.conversion'),
|
||||
secondMath:
|
||||
this.$n(this.amount, 'decimal') +
|
||||
' GDT * ' +
|
||||
this.factor * 100 +
|
||||
' % = ' +
|
||||
this.$n(this.gdt, 'decimal') +
|
||||
' GDT',
|
||||
},
|
||||
switch (givenType) {
|
||||
case GdtEntryType.FORM:
|
||||
case GdtEntryType.CVS:
|
||||
case GdtEntryType.ELOPAGE:
|
||||
case GdtEntryType.DIGISTORE:
|
||||
case GdtEntryType.CVS2: {
|
||||
return {
|
||||
headline: this.$t('gdt.calculation'),
|
||||
first: this.$t('gdt.factor'),
|
||||
firstMath: this.factor + ' GDT pro €',
|
||||
second: this.$t('gdt.formula'),
|
||||
secondMath:
|
||||
this.$n(this.amount, 'decimal') +
|
||||
' € * ' +
|
||||
this.factor +
|
||||
' GDT / € = ' +
|
||||
this.$n(this.gdt, 'decimal') +
|
||||
' GDT',
|
||||
}
|
||||
}
|
||||
case GdtEntryType.ELOPAGE_PUBLISHER: {
|
||||
return {
|
||||
headline: this.$t('gdt.publisher'),
|
||||
first: null,
|
||||
firstMath: null,
|
||||
second: null,
|
||||
secondMath: null,
|
||||
}
|
||||
}
|
||||
case GdtEntryType.GLOBAL_MODIFICATOR: {
|
||||
return {
|
||||
headline: this.$t('gdt.conversion-gdt-euro'),
|
||||
first: this.$t('gdt.raise'),
|
||||
firstMath: this.factor * 100 + ' % ',
|
||||
second: this.$t('gdt.conversion'),
|
||||
secondMath:
|
||||
this.$n(this.amount, 'decimal') +
|
||||
' GDT * ' +
|
||||
this.factor * 100 +
|
||||
' % = ' +
|
||||
this.$n(this.gdt, 'decimal') +
|
||||
' GDT',
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new Error('no additional transaction info for this type: ' + givenType)
|
||||
}
|
||||
|
||||
const type = linesByType[givenType]
|
||||
|
||||
if (type) return type
|
||||
throw new Error('no additional transaction info for this type: ' + givenType)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
9
frontend/src/graphql/enums.js
Normal file
9
frontend/src/graphql/enums.js
Normal file
@ -0,0 +1,9 @@
|
||||
export const GdtEntryType = {
|
||||
FORM: 'FORM',
|
||||
CVS: 'CVS',
|
||||
ELOPAGE: 'ELOPAGE',
|
||||
ELOPAGE_PUBLISHER: 'ELOPAGE_PUBLISHER',
|
||||
DIGISTORE: 'DIGISTORE',
|
||||
CVS2: 'CVS2',
|
||||
GLOBAL_MODIFICATOR: 'GLOBAL_MODIFICATOR',
|
||||
}
|
||||
@ -1,25 +1,25 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const subscribeNewsletter = gql`
|
||||
mutation($email: String!, $language: String!) {
|
||||
mutation ($email: String!, $language: String!) {
|
||||
subscribeNewsletter(email: $email, language: $language)
|
||||
}
|
||||
`
|
||||
|
||||
export const unsubscribeNewsletter = gql`
|
||||
mutation($email: String!) {
|
||||
mutation ($email: String!) {
|
||||
unsubscribeNewsletter(email: $email)
|
||||
}
|
||||
`
|
||||
|
||||
export const resetPassword = gql`
|
||||
mutation($sessionId: Float!, $email: String!, $password: String!) {
|
||||
mutation ($sessionId: Float!, $email: String!, $password: String!) {
|
||||
resetPassword(sessionId: $sessionId, email: $email, password: $password)
|
||||
}
|
||||
`
|
||||
|
||||
export const updateUserInfos = gql`
|
||||
mutation(
|
||||
mutation (
|
||||
$firstName: String
|
||||
$lastName: String
|
||||
$description: String
|
||||
@ -45,7 +45,7 @@ export const updateUserInfos = gql`
|
||||
`
|
||||
|
||||
export const registerUser = gql`
|
||||
mutation(
|
||||
mutation (
|
||||
$firstName: String!
|
||||
$lastName: String!
|
||||
$email: String!
|
||||
@ -63,7 +63,7 @@ export const registerUser = gql`
|
||||
`
|
||||
|
||||
export const sendCoins = gql`
|
||||
mutation($email: String!, $amount: Float!, $memo: String!) {
|
||||
mutation ($email: String!, $amount: Float!, $memo: String!) {
|
||||
sendCoins(email: $email, amount: $amount, memo: $memo)
|
||||
}
|
||||
`
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const login = gql`
|
||||
query($email: String!, $password: String!) {
|
||||
query ($email: String!, $password: String!) {
|
||||
login(email: $email, password: $password) {
|
||||
email
|
||||
username
|
||||
@ -24,7 +24,7 @@ export const logout = gql`
|
||||
`
|
||||
|
||||
export const loginViaEmailVerificationCode = gql`
|
||||
query($optin: String!) {
|
||||
query ($optin: String!) {
|
||||
loginViaEmailVerificationCode(optin: $optin) {
|
||||
sessionId
|
||||
email
|
||||
@ -33,7 +33,7 @@ export const loginViaEmailVerificationCode = gql`
|
||||
`
|
||||
|
||||
export const transactionsQuery = gql`
|
||||
query($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) {
|
||||
query ($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) {
|
||||
transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) {
|
||||
gdtSum
|
||||
count
|
||||
@ -64,7 +64,7 @@ export const transactionsQuery = gql`
|
||||
`
|
||||
|
||||
export const sendResetPasswordEmail = gql`
|
||||
query($email: String!) {
|
||||
query ($email: String!) {
|
||||
sendResetPasswordEmail(email: $email) {
|
||||
state
|
||||
}
|
||||
@ -72,7 +72,7 @@ export const sendResetPasswordEmail = gql`
|
||||
`
|
||||
|
||||
export const checkUsername = gql`
|
||||
query($username: String!) {
|
||||
query ($username: String!) {
|
||||
checkUsername(username: $username) {
|
||||
state
|
||||
}
|
||||
@ -80,7 +80,7 @@ export const checkUsername = gql`
|
||||
`
|
||||
|
||||
export const listGDTEntriesQuery = gql`
|
||||
query($currentPage: Int!, $pageSize: Int!) {
|
||||
query ($currentPage: Int!, $pageSize: Int!) {
|
||||
listGDTEntries(currentPage: $currentPage, pageSize: $pageSize) {
|
||||
count
|
||||
gdtEntries {
|
||||
@ -98,7 +98,7 @@ export const listGDTEntriesQuery = gql`
|
||||
`
|
||||
|
||||
export const checkEmailQuery = gql`
|
||||
query($optin: String!) {
|
||||
query ($optin: String!) {
|
||||
checkEmail(optin: $optin) {
|
||||
email
|
||||
sessionId
|
||||
|
||||
@ -1,15 +1,7 @@
|
||||
import { mutations, actions } from './store'
|
||||
|
||||
const {
|
||||
language,
|
||||
email,
|
||||
token,
|
||||
username,
|
||||
firstName,
|
||||
lastName,
|
||||
description,
|
||||
newsletterState,
|
||||
} = mutations
|
||||
const { language, email, token, username, firstName, lastName, description, newsletterState } =
|
||||
mutations
|
||||
const { login, logout } = actions
|
||||
|
||||
describe('Vuex store', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user