Merge pull request #1149 from gradido/1078-GDD-Calculate-Decay-Tool-clear

1057 display gdd balance when sending
This commit is contained in:
Alexander Friedland 2021-12-17 13:17:40 +01:00 committed by GitHub
commit fe6f093847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 97 additions and 31 deletions

View File

@ -57,6 +57,7 @@
"at": "am", "at": "am",
"cancel": "Abbrechen", "cancel": "Abbrechen",
"close": "schließen", "close": "schließen",
"current_balance": "aktueller Kontostand",
"date": "Datum", "date": "Datum",
"description": "Beschreibung", "description": "Beschreibung",
"edit": "bearbeiten", "edit": "bearbeiten",
@ -66,6 +67,7 @@
"lastname": "Nachname", "lastname": "Nachname",
"memo": "Nachricht", "memo": "Nachricht",
"message": "Nachricht", "message": "Nachricht",
"new_balance": "neuer Kontostand nach Bestätigung",
"password": "Passwort", "password": "Passwort",
"passwordRepeat": "Passwort wiederholen", "passwordRepeat": "Passwort wiederholen",
"password_new": "neues Passwort", "password_new": "neues Passwort",
@ -90,7 +92,8 @@
"is-not": "Du kannst dir selbst keine Gradidos überweisen", "is-not": "Du kannst dir selbst keine Gradidos überweisen",
"usernmae-regex": "Der Username muss mit einem Buchstaben beginnen auf den mindestens zwei alfanumerische Zeichen folgen müssen.", "usernmae-regex": "Der Username muss mit einem Buchstaben beginnen auf den mindestens zwei alfanumerische Zeichen folgen müssen.",
"usernmae-unique": "Der Username ist bereits vergeben." "usernmae-unique": "Der Username ist bereits vergeben."
} },
"your_amount": "Dein Betrag"
}, },
"gdt": { "gdt": {
"action": "Aktion", "action": "Aktion",

View File

@ -57,6 +57,7 @@
"at": "at", "at": "at",
"cancel": "Cancel", "cancel": "Cancel",
"close": "Close", "close": "Close",
"current_balance": "current balance",
"date": "Date", "date": "Date",
"description": "Description", "description": "Description",
"edit": "Edit", "edit": "Edit",
@ -66,6 +67,7 @@
"lastname": "Lastname", "lastname": "Lastname",
"memo": "Message", "memo": "Message",
"message": "Message", "message": "Message",
"new_balance": "account balance after confirmation",
"password": "Password", "password": "Password",
"passwordRepeat": "Repeat password", "passwordRepeat": "Repeat password",
"password_new": "New password", "password_new": "New password",
@ -90,7 +92,8 @@
"is-not": "You cannot send Gradidos to yourself", "is-not": "You cannot send Gradidos to yourself",
"usernmae-regex": "The username must start with a letter, followed by at least two alphanumeric characters.", "usernmae-regex": "The username must start with a letter, followed by at least two alphanumeric characters.",
"usernmae-unique": "The username is already taken." "usernmae-unique": "The username is already taken."
} },
"your_amount": "Your amount"
}, },
"gdt": { "gdt": {
"action": "Action", "action": "Action",

View File

@ -13,7 +13,9 @@ describe('SendOverview', () => {
const propsData = { const propsData = {
balance: 123.45, balance: 123.45,
transactionCount: 1, GdtBalance: 1234.56,
transactions: [{ balance: 0.1 }],
pending: true,
} }
const mocks = { const mocks = {
@ -42,18 +44,16 @@ describe('SendOverview', () => {
expect(wrapper.find('div.gdd-send').exists()).toBeTruthy() expect(wrapper.find('div.gdd-send').exists()).toBeTruthy()
}) })
// it('has a transactions table', () => {
// expect(wrapper.find('div.gdd-transaction-list').exists()).toBeTruthy()
// })
describe('transaction form', () => { describe('transaction form', () => {
it('steps forward in the dialog', async () => { beforeEach(async () => {
await wrapper.findComponent({ name: 'TransactionForm' }).vm.$emit('set-transaction', { wrapper.findComponent({ name: 'TransactionForm' }).vm.$emit('set-transaction', {
email: 'user@example.org', email: 'user@example.org',
amount: 23.45, amount: 23.45,
memo: 'Make the best of it!', memo: 'Make the best of it!',
}) })
expect(wrapper.findComponent({ name: 'TransactionConfirmation' }).exists()).toBeTruthy() })
it('steps forward in the dialog', () => {
expect(wrapper.findComponent({ name: 'TransactionConfirmation' }).exists()).toBe(true)
}) })
}) })
@ -112,18 +112,22 @@ describe('SendOverview', () => {
describe('transaction is confirmed and server response is error', () => { describe('transaction is confirmed and server response is error', () => {
beforeEach(async () => { beforeEach(async () => {
jest.clearAllMocks() jest.clearAllMocks()
sendMock.mockRejectedValue({ message: 'receiver not found' }) sendMock.mockRejectedValue({ message: 'recipiant not known' })
await wrapper await wrapper
.findComponent({ name: 'TransactionConfirmation' }) .findComponent({ name: 'TransactionConfirmation' })
.vm.$emit('send-transaction') .vm.$emit('send-transaction')
}) })
it('shows the error page', () => { it('shows the error page', () => {
expect(wrapper.find('div.card-body').text()).toContain('form.send_transaction_error') expect(wrapper.find('.test-send_transaction_error').text()).toContain(
'form.send_transaction_error',
)
}) })
it('shows recipient not found', () => { it('shows recipient not found', () => {
expect(wrapper.text()).toContain('transaction.receiverNotFound') expect(wrapper.find('.test-receiver-not-found').text()).toContain(
'transaction.receiverNotFound',
)
}) })
}) })
}) })

View File

@ -1,12 +1,14 @@
<template> <template>
<div> <div>
<b-container> <b-container>
<gdd-send :currentTransactionStep="currentTransactionStep"> <gdd-send :currentTransactionStep="currentTransactionStep" class="pt-3">
<template #transaction-form> <template #transaction-form>
<transaction-form :balance="balance" @set-transaction="setTransaction"></transaction-form> <transaction-form :balance="balance" @set-transaction="setTransaction"></transaction-form>
</template> </template>
<template #transaction-confirmation> <template #transaction-confirmation>
<transaction-confirmation <transaction-confirmation
:balance="balance"
:transactions="transactions"
:email="transactionData.email" :email="transactionData.email"
:amount="transactionData.amount" :amount="transactionData.amount"
:memo="transactionData.memo" :memo="transactionData.memo"
@ -44,7 +46,6 @@ export default {
name: 'SendOverview', name: 'SendOverview',
components: { components: {
GddSend, GddSend,
TransactionForm, TransactionForm,
TransactionConfirmation, TransactionConfirmation,
TransactionResult, TransactionResult,

View File

@ -2,23 +2,61 @@
<div> <div>
<b-row> <b-row>
<b-col> <b-col>
<div class="display-4 p-4">{{ $t('form.send_check') }}</div> <div class="display-4 pb-4">{{ $t('form.send_check') }}</div>
<b-list-group> <b-list-group class="">
<b-list-group-item class="d-flex justify-content-between align-items-center"> <label class="input-1" for="input-1">{{ $t('form.recipient') }}</label>
{{ email }} <b-input-group id="input-group-1" class="borderbottom" size="lg">
<b-badge variant="primary" pill>{{ $t('form.recipient') }}</b-badge> <b-input-group-prepend class="d-none d-md-block gray-background">
</b-list-group-item> <b-icon icon="envelope" class="display-4 m-3"></b-icon>
<b-list-group-item class="d-flex justify-content-between align-items-center"> </b-input-group-prepend>
{{ $n(amount, 'decimal') }} GDD <div class="p-3">{{ email }}</div>
<b-badge variant="primary" pill>{{ $t('form.amount') }}</b-badge> </b-input-group>
</b-list-group-item> <br />
<b-list-group-item class="d-flex justify-content-between align-items-center"> <label class="input-2" for="input-2">{{ $t('form.amount') }}</label>
{{ memo ? memo : '-' }} <b-input-group id="input-group-2" class="borderbottom" size="lg">
<b-badge variant="primary" pill>{{ $t('form.message') }}</b-badge> <b-input-group-prepend class="p-2 d-none d-md-block gray-background">
</b-list-group-item> <div class="m-1 mt-2">GDD</div>
</b-input-group-prepend>
<div class="p-3">{{ $n(amount, 'decimal') }}</div>
</b-input-group>
<br />
<label class="input-3" for="input-3">{{ $t('form.message') }}</label>
<b-input-group id="input-group-3" class="borderbottom">
<b-input-group-prepend class="d-none d-md-block gray-background">
<b-icon icon="chat-right-text" class="display-4 m-3 mt-4"></b-icon>
</b-input-group-prepend>
<div class="p-3">{{ memo ? memo : '-' }}</div>
</b-input-group>
</b-list-group> </b-list-group>
</b-col> </b-col>
</b-row> </b-row>
<b-container class="bv-example-row mt-3 gray-background p-2">
<b-row class="pr-3">
<b-col class="text-right">{{ $t('form.current_balance') }}</b-col>
<b-col class="text-right">{{ $n(balance, 'decimal') }}</b-col>
</b-row>
<b-row class="pr-3">
<b-col class="text-right">
<strong>{{ $t('form.your_amount') }}</strong>
</b-col>
<b-col class="text-right">
<strong>- {{ $n(amount, 'decimal') }}</strong>
</b-col>
</b-row>
<b-row class="pr-3">
<b-col class="text-right">{{ $t('decay.decay') }}</b-col>
<b-col class="text-right" style="border-bottom: double">- {{ $n(decay, 'decimal') }}</b-col>
</b-row>
<b-row class="pr-3">
<b-col class="text-right">{{ $t('form.new_balance') }}</b-col>
<b-col class="text-right">~ {{ $n(balance - amount - decay, 'decimal') }}</b-col>
</b-row>
</b-container>
<b-row class="mt-4"> <b-row class="mt-4">
<b-col> <b-col>
<b-button @click="$emit('on-reset')">{{ $t('form.cancel') }}</b-button> <b-button @click="$emit('on-reset')">{{ $t('form.cancel') }}</b-button>
@ -35,10 +73,27 @@
export default { export default {
name: 'TransactionConfirmation', name: 'TransactionConfirmation',
props: { props: {
balance: { type: Number, default: 0 },
email: { type: String, default: '' }, email: { type: String, default: '' },
amount: { type: Number, default: 0 }, amount: { type: Number, default: 0 },
memo: { type: String, default: '' }, memo: { type: String, default: '' },
loading: { type: Boolean, default: false }, loading: { type: Boolean, default: false },
transactions: {
default: () => [],
},
},
data() {
return {
decay: this.transactions[0].balance,
}
}, },
} }
</script> </script>
<style>
.gray-background {
background-color: #ecebe6a3 !important;
}
.borderbottom {
border-bottom: 1px solid rgb(70, 65, 65);
}
</style>

View File

@ -20,10 +20,10 @@
<div>{{ $t('form.sorry') }}</div> <div>{{ $t('form.sorry') }}</div>
<hr /> <hr />
<div>{{ $t('form.send_transaction_error') }}</div> <div class="test-send_transaction_error">{{ $t('form.send_transaction_error') }}</div>
<hr /> <hr />
<div v-if="errorResult === 'receiver not found'"> <div class="test-receiver-not-found" v-if="errorResult === 'recipiant not known'">
{{ $t('transaction.receiverNotFound') }} {{ $t('transaction.receiverNotFound') }}
</div> </div>
<div v-else>({{ errorResult }})</div> <div v-else>({{ errorResult }})</div>