including validation date infos to link copying after transaction link creation

- adapt transaction link creation mutation to get the validation date
- add validation date and text to link copy
- utilize mixins to avoid code doubling
This commit is contained in:
mahula 2022-07-28 13:06:42 +02:00
parent e17e1b43f5
commit 2d80c7029e
4 changed files with 19 additions and 43 deletions

View File

@ -6,7 +6,7 @@
<b-button size="sm" text="Button" variant="primary" @click="copyLinkWithText"> <b-button size="sm" text="Button" variant="primary" @click="copyLinkWithText">
{{ $t('gdd_per_link.copy-link-with-text') }} {{ $t('gdd_per_link.copy-link-with-text') }}
</b-button> </b-button>
<b-button size="sm" text="Button" variant="primary" @click="CopyLink"> <b-button size="sm" text="Button" variant="primary" @click="copyLink">
{{ $t('gdd_per_link.copy-link') }} {{ $t('gdd_per_link.copy-link') }}
</b-button> </b-button>
<b-button variant="primary" class="text-light" @click="$emit('show-qr-code-button')"> <b-button variant="primary" class="text-light" @click="$emit('show-qr-code-button')">
@ -21,46 +21,10 @@
</div> </div>
</template> </template>
<script> <script>
import { copyLinks } from '@/mixins/copyLinks'
export default { export default {
name: 'ClipboardCopy', name: 'ClipboardCopy',
props: { mixins: [copyLinks],
link: { type: String, required: true },
amount: { type: Number, required: true },
memo: { type: String, required: true },
},
data() {
return {
canCopyLink: true,
}
},
methods: {
CopyLink() {
navigator.clipboard
.writeText(this.link)
.then(() => {
this.toastSuccess(this.$t('gdd_per_link.link-copied'))
})
.catch(() => {
this.canCopyLink = false
this.toastError(this.$t('gdd_per_link.not-copied'))
})
},
copyLinkWithText() {
navigator.clipboard
.writeText(
`${this.link}
${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido.
"${this.memo}"`,
)
.then(() => {
this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied'))
})
.catch(() => {
this.canCopyLink = false
this.toastError(this.$t('gdd_per_link.not-copied'))
})
},
},
} }
</script> </script>
<style> <style>

View File

@ -7,6 +7,7 @@
:link="link" :link="link"
:amount="amount" :amount="amount"
:memo="memo" :memo="memo"
:validUntil="validUntil"
@show-qr-code-button="showQrCodeButton" @show-qr-code-button="showQrCodeButton"
></clipboard-copy> ></clipboard-copy>
@ -33,8 +34,9 @@ export default {
}, },
props: { props: {
link: { type: String, required: true }, link: { type: String, required: true },
amount: { type: Number, required: true }, amount: { type: String, required: true },
memo: { type: String, required: true }, memo: { type: String, required: true },
validUntil: { type: String, required: true },
}, },
data() { data() {
return { return {

View File

@ -74,6 +74,9 @@ export const createTransactionLink = gql`
mutation($amount: Decimal!, $memo: String!) { mutation($amount: Decimal!, $memo: String!) {
createTransactionLink(amount: $amount, memo: $memo) { createTransactionLink(amount: $amount, memo: $memo) {
link link
amount
memo
validUntil
} }
} }
` `

View File

@ -45,6 +45,7 @@
:link="link" :link="link"
:amount="amount" :amount="amount"
:memo="memo" :memo="memo"
:validUntil="validUntil"
@on-reset="onReset" @on-reset="onReset"
></transaction-result-link> ></transaction-result-link>
</template> </template>
@ -149,9 +150,15 @@ export default {
}) })
.then((result) => { .then((result) => {
this.$emit('set-tunneled-email', null) this.$emit('set-tunneled-email', null)
this.link = result.data.createTransactionLink.link const {
this.amount = this.transactionData.amount data: {
this.memo = this.transactionData.memo createTransactionLink: { link, amount, memo, validUntil },
},
} = result
this.link = link
this.amount = amount
this.memo = memo
this.validUntil = validUntil
this.transactionData = { ...EMPTY_TRANSACTION_DATA } this.transactionData = { ...EMPTY_TRANSACTION_DATA }
this.currentTransactionStep = TRANSACTION_STEPS.transactionResultLink this.currentTransactionStep = TRANSACTION_STEPS.transactionResultLink
this.updateTransactions({}) this.updateTransactions({})