Add link to the TransactionLink and change code by link in frontend.

This commit is contained in:
elweyn 2022-04-06 18:45:27 +02:00
parent d984ff2582
commit 41b35f2c5e
7 changed files with 16 additions and 7 deletions

View File

@ -12,12 +12,13 @@ export class TransactionLink {
this.amount = transactionLink.amount this.amount = transactionLink.amount
this.holdAvailableAmount = transactionLink.holdAvailableAmount this.holdAvailableAmount = transactionLink.holdAvailableAmount
this.memo = transactionLink.memo this.memo = transactionLink.memo
this.code = CONFIG.COMMUNITY_URL + 'redeem/' + transactionLink.code this.code = transactionLink.code
this.createdAt = transactionLink.createdAt this.createdAt = transactionLink.createdAt
this.validUntil = transactionLink.validUntil this.validUntil = transactionLink.validUntil
this.deletedAt = transactionLink.deletedAt this.deletedAt = transactionLink.deletedAt
this.redeemedAt = transactionLink.redeemedAt this.redeemedAt = transactionLink.redeemedAt
this.redeemedBy = redeemedBy this.redeemedBy = redeemedBy
this.link = CONFIG.COMMUNITY_REDEEM_URL + this.code
} }
@Field(() => Number) @Field(() => Number)
@ -52,6 +53,9 @@ export class TransactionLink {
@Field(() => User, { nullable: true }) @Field(() => User, { nullable: true })
redeemedBy: User | null redeemedBy: User | null
@Field(() => String)
link: string
} }
@ObjectType() @ObjectType()

View File

@ -14,11 +14,11 @@
export default { export default {
name: 'ClipboardCopy', name: 'ClipboardCopy',
props: { props: {
code: { type: String, required: true }, link: { type: String, required: true },
}, },
data() { data() {
return { return {
url: `${this.code}`, url: `${this.link}`,
} }
}, },
methods: { methods: {

View File

@ -5,7 +5,7 @@
<b-card class="p-0 gradido-custom-background"> <b-card class="p-0 gradido-custom-background">
<div class="p-4"> <div class="p-4">
<div class="h3 mb-5">{{ $t('gdd_per_link.created') }}</div> <div class="h3 mb-5">{{ $t('gdd_per_link.created') }}</div>
<clipboard-copy :code="code" /> <clipboard-copy :link="link" />
</div> </div>
<p class="text-center mt-3"> <p class="text-center mt-3">
<b-button variant="success" @click="$emit('on-reset')">{{ $t('form.close') }}</b-button> <b-button variant="success" @click="$emit('on-reset')">{{ $t('form.close') }}</b-button>
@ -24,7 +24,7 @@ export default {
ClipboardCopy, ClipboardCopy,
}, },
props: { props: {
code: { link: {
type: String, type: String,
required: true, required: true,
}, },

View File

@ -55,6 +55,7 @@ export default {
props: { props: {
amount: { type: String, required: true }, amount: { type: String, required: true },
code: { type: String, required: true }, code: { type: String, required: true },
link: { type: String, required: true },
holdAvailableAmount: { type: String, required: true }, holdAvailableAmount: { type: String, required: true },
id: { type: Number, required: true }, id: { type: Number, required: true },
memo: { type: String, required: true }, memo: { type: String, required: true },
@ -62,7 +63,7 @@ export default {
}, },
methods: { methods: {
copy() { copy() {
const link = `${window.location.origin}/redeem/${this.code}` const link = `${this.link}`
navigator.clipboard navigator.clipboard
.writeText(link) .writeText(link)
.then(() => { .then(() => {

View File

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

View File

@ -155,6 +155,7 @@ export const listTransactionLinks = gql`
holdAvailableAmount holdAvailableAmount
memo memo
code code
link
createdAt createdAt
validUntil validUntil
redeemedAt redeemedAt

View File

@ -41,7 +41,7 @@
></transaction-result-send-error> ></transaction-result-send-error>
</template> </template>
<template #transactionResultLink> <template #transactionResultLink>
<transaction-result-link :code="code" @on-reset="onReset"></transaction-result-link> <transaction-result-link :link="link" @on-reset="onReset"></transaction-result-link>
</template> </template>
</gdd-send> </gdd-send>
<hr /> <hr />
@ -88,6 +88,7 @@ export default {
currentTransactionStep: TRANSACTION_STEPS.transactionForm, currentTransactionStep: TRANSACTION_STEPS.transactionForm,
loading: false, loading: false,
code: null, code: null,
link: null,
} }
}, },
props: { props: {
@ -145,6 +146,7 @@ export default {
.then((result) => { .then((result) => {
this.$emit('set-tunneled-email', null) this.$emit('set-tunneled-email', null)
this.code = result.data.createTransactionLink.code this.code = result.data.createTransactionLink.code
this.link = result.data.createTransactionLink.link
this.transactionData = { ...EMPTY_TRANSACTION_DATA } this.transactionData = { ...EMPTY_TRANSACTION_DATA }
this.currentTransactionStep = TRANSACTION_STEPS.transactionResultLink this.currentTransactionStep = TRANSACTION_STEPS.transactionResultLink
this.updateTransactions({}) this.updateTransactions({})