do not use route query to pass email. try inject/provide instead

This commit is contained in:
Moriz Wahl 2022-03-22 14:02:28 +01:00
parent ce8efa8dff
commit aaa6137c31
12 changed files with 60 additions and 18 deletions

View File

@ -4,7 +4,7 @@ import flushPromises from 'flush-promises'
const localVue = global.localVue
describe('GddSend', () => {
describe('TransactionForm', () => {
let wrapper
const mocks = {
@ -25,7 +25,16 @@ describe('GddSend', () => {
}
const Wrapper = () => {
return mount(TransactionForm, { localVue, mocks, propsData })
return mount(TransactionForm, {
localVue,
mocks,
propsData,
provide: {
getTunneledEmail() {
return null
},
},
})
}
describe('mount', () => {

View File

@ -162,12 +162,13 @@ export default {
balance: { type: Number, default: 0 },
email: { type: String, default: null },
},
inject: ['getTunneledEmail'],
data() {
return {
amountFocused: false,
emailFocused: false,
form: {
email: this.email ? this.email : '',
email: '',
amount: '',
memo: '',
amountValue: 0.0,
@ -209,6 +210,12 @@ export default {
sendTypes() {
return SEND_TYPES
},
recipientEmail() {
return this.getTunneledEmail()
},
},
created() {
this.form.email = this.recipientEmail ? this.recipientEmail : ''
},
}
</script>

View File

@ -23,6 +23,7 @@
class="list-group-item"
v-bind="transactions[index]"
:decayStartBlock="decayStartBlock"
v-on="$listeners"
/>
</template>
@ -31,6 +32,7 @@
class="list-group-item"
v-bind="transactions[index]"
:decayStartBlock="decayStartBlock"
v-on="$listeners"
/>
</template>

View File

@ -60,10 +60,13 @@ describe('AmountAndNameRow', () => {
await wrapper.find('div.gdd-transaction-list-item-name').find('a').trigger('click')
})
it('pushes the rpute with query for email', () => {
it('emits set tunneled email', () => {
expect(wrapper.emitted('set-tunneled-email')).toEqual([['bibi@bloxberg.de']])
})
it('pushes the route with query for email', () => {
expect(mocks.$router.push).toBeCalledWith({
path: '/send',
query: { email: 'bibi@bloxberg.de' },
})
})
})

View File

@ -10,10 +10,7 @@
</b-col>
<b-col cols="7">
<div class="gdd-transaction-list-item-name">
<b-link
v-if="linkedUser && linkedUser.email"
@click.stop="$router.push({ path: '/send', query: { email: `${linkedUser.email}` } })"
>
<b-link v-if="linkedUser && linkedUser.email" @click.stop="tunnelEmail">
{{ itemText }}
</b-link>
<span v-else>{{ itemText }}</span>
@ -39,6 +36,12 @@ export default {
required: false,
},
},
methods: {
tunnelEmail() {
this.$emit('set-tunneled-email', this.linkedUser.email)
this.$router.push({ path: '/send' })
},
},
computed: {
itemText() {
return this.linkedUser

View File

@ -13,7 +13,7 @@
<b-col cols="11">
<!-- Amount / Name || Text -->
<amount-and-name-row :amount="amount" :linkedUser="linkedUser" />
<amount-and-name-row :amount="amount" :linkedUser="linkedUser" v-on="$listeners" />
<!-- Nachricht Memo -->
<memo-row :memo="memo" />

View File

@ -13,7 +13,7 @@
<b-col cols="11">
<!-- Amount / Name -->
<amount-and-name-row :amount="amount" :linkedUser="linkedUser" />
<amount-and-name-row :amount="amount" :linkedUser="linkedUser" v-on="$listeners" />
<!-- Memo -->
<memo-row :memo="memo" />

View File

@ -29,6 +29,7 @@
:decayStartBlock="decayStartBlock"
@update-balance="updateBalance"
@update-transactions="updateTransactions"
@set-tunneled-email="setTunneledEmail"
></router-view>
</fade-transition>
</div>
@ -64,6 +65,12 @@ export default {
pending: true,
visible: false,
decayStartBlock: new Date(),
tunneledEmail: null,
}
},
provide() {
return {
getTunneledEmail: () => this.tunneledEmail,
}
},
methods: {
@ -122,6 +129,9 @@ export default {
setVisible(bool) {
this.visible = bool
},
setTunneledEmail(email) {
this.tunneledEmail = email
},
},
computed: {
elopageUri() {

View File

@ -22,6 +22,7 @@
:transaction-count="transactionCount"
:transactionLinkCount="transactionLinkCount"
@update-transactions="updateTransactions"
v-on="$listeners"
/>
<gdd-transaction-list-footer :count="transactionCount" />
</div>

View File

@ -39,7 +39,16 @@ describe('Send', () => {
}
const Wrapper = () => {
return mount(Send, { localVue, mocks, propsData })
return mount(Send, {
localVue,
mocks,
propsData,
provide: {
getTunneledEmail() {
return null
},
},
})
}
describe('mount', () => {

View File

@ -3,11 +3,7 @@
<b-container>
<gdd-send :currentTransactionStep="currentTransactionStep" class="pt-3 ml-2 mr-2">
<template #transactionForm>
<transaction-form
:balance="balance"
@set-transaction="setTransaction"
:email="$route.query.email"
></transaction-form>
<transaction-form :balance="balance" @set-transaction="setTransaction"></transaction-form>
</template>
<template #transactionConfirmationSend>
<transaction-confirmation-send
@ -99,7 +95,6 @@ export default {
transactions: {
default: () => [],
},
pending: {
type: Boolean,
default: true,
@ -130,6 +125,7 @@ export default {
.then(() => {
this.error = false
this.$emit('update-balance', this.transactionData.amount)
this.$emit('set-tunneled-email', null)
this.currentTransactionStep = TRANSACTION_STEPS.transactionResultSendSuccess
})
.catch((err) => {
@ -145,6 +141,7 @@ export default {
variables: { amount: this.transactionData.amount, memo: this.transactionData.memo },
})
.then((result) => {
this.$emit('set-tunneled-email', null)
this.code = result.data.createTransactionLink.code
this.currentTransactionStep = TRANSACTION_STEPS.transactionResultLink
})

View File

@ -12,6 +12,7 @@
:show-pagination="true"
:decayStartBlock="decayStartBlock"
@update-transactions="updateTransactions"
v-on="$listeners"
/>
</b-tab>