From 11eb0c45a7f3955774611484a8106b1b4146c07e Mon Sep 17 00:00:00 2001
From: clauspeterhuebner
Date: Thu, 17 Apr 2025 17:48:03 +0200
Subject: [PATCH] overwork transactionLink and disbursementLink
---
backend/src/graphql/model/DisbursementLink.ts | 18 +++++++++-------
.../resolver/TransactionLinkResolver.ts | 11 +++++++++-
.../RedeemCommunitySelection.vue | 16 +++++++-------
frontend/src/graphql/queries.js | 21 +++++++++++++------
frontend/src/pages/TransactionLink.vue | 17 +++++++++++----
5 files changed, 56 insertions(+), 27 deletions(-)
diff --git a/backend/src/graphql/model/DisbursementLink.ts b/backend/src/graphql/model/DisbursementLink.ts
index acbc584c9..87167d79a 100644
--- a/backend/src/graphql/model/DisbursementLink.ts
+++ b/backend/src/graphql/model/DisbursementLink.ts
@@ -10,34 +10,36 @@ import { User } from './User'
export class DisbursementLink {
constructor(
disbursementPayload: DisbursementJwtPayloadType,
+ senderCommunity: Community,
+ senderUser: User,
recipientCommunity: Community,
recipientUser?: User,
) {
+ this.senderCommunity = senderCommunity
this.recipientCommunity = recipientCommunity
+ this.senderUser = senderUser
if (recipientUser !== undefined) {
this.recipientUser = recipientUser
} else {
this.recipientUser = null
}
- this.senderGradidoID = disbursementPayload.sendergradidoid
- this.senderName = disbursementPayload.sendername
this.amount = new Decimal(disbursementPayload.amount)
this.memo = disbursementPayload.memo
this.code = disbursementPayload.redeemcode
}
+ @Field(() => Community)
+ senderCommunity: Community
+
+ @Field(() => User)
+ senderUser: User
+
@Field(() => Community)
recipientCommunity: Community
@Field(() => User, { nullable: true })
recipientUser: User | null
- @Field(() => String)
- senderGradidoID: string
-
- @Field(() => String)
- senderName: string
-
@Field(() => Decimal)
amount: Decimal
diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts
index 68a385e47..0eee2c991 100644
--- a/backend/src/graphql/resolver/TransactionLinkResolver.ts
+++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts
@@ -249,7 +249,16 @@ export class TransactionLinkResolver {
)
const homeCommunity = await getHomeCommunity()
const recipientCommunity = new Community(homeCommunity)
- const disbursementLink = new DisbursementLink(verifiedPayload, recipientCommunity)
+ const senderCommunity = new Community(senderCom)
+ const senderUser = new User(null)
+ senderUser.gradidoID = verifiedPayload.sendergradidoid
+ senderUser.firstName = verifiedPayload.sendername
+ const disbursementLink = new DisbursementLink(
+ verifiedPayload,
+ senderCommunity,
+ senderUser,
+ recipientCommunity,
+ )
logger.debug(
'TransactionLinkResolver.queryTransactionLink... disbursementLink=',
disbursementLink,
diff --git a/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue b/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue
index 4b6e857aa..0f9ae50a9 100644
--- a/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue
+++ b/frontend/src/components/LinkInformations/RedeemCommunitySelection.vue
@@ -31,8 +31,8 @@
-
- {{ linkData.user.firstName }}
+
+ {{ linkData.senderUser.firstName }}
{{ $t('transaction-link.send_you') }} {{ $filters.GDD(linkData.amount) }}
@@ -123,27 +123,27 @@ async function onSwitch(event) {
console.log('RedeemCommunitySelection.onSwitch... props=', props)
if (isForeignCommunitySelected.value) {
console.log('RedeemCommunitySelection.onSwitch vor createRedeemJwt params:', {
- gradidoID: props.linkData.user.gradidoID,
+ gradidoID: props.linkData.senderUser.gradidoID,
senderCommunityUuid: senderCommunity.value.uuid,
senderCommunityName: senderCommunity.value.name,
receiverCommunityUuid: currentReceiverCommunity.value.uuid,
code: props.redeemCode,
amount: props.linkData.amount,
memo: props.linkData.memo,
- firstName: props.linkData.user.firstName,
- alias: props.linkData.user.alias,
+ firstName: props.linkData.senderUser.firstName,
+ alias: props.linkData.senderUser.alias,
})
try {
const { data } = await createRedeemJwt({
- gradidoID: props.linkData.user.gradidoID,
+ gradidoID: props.linkData.senderUser.gradidoID,
senderCommunityUuid: senderCommunity.value.uuid,
senderCommunityName: senderCommunity.value.name,
receiverCommunityUuid: currentReceiverCommunity.value.uuid,
code: props.redeemCode,
amount: props.linkData.amount,
memo: props.linkData.memo,
- firstName: props.linkData.user.firstName,
- alias: props.linkData.user.alias,
+ firstName: props.linkData.senderUser.firstName,
+ alias: props.linkData.senderUser.alias,
})
console.log('RedeemCommunitySelection.onSwitch... response=', data)
if (!data?.createRedeemJwt) {
diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js
index d8ad0e2dd..8cf24fc89 100644
--- a/frontend/src/graphql/queries.js
+++ b/frontend/src/graphql/queries.js
@@ -138,7 +138,7 @@ export const queryTransactionLink = gql`
validUntil
redeemedAt
deletedAt
- user {
+ senderUser {
gradidoID
firstName
publisherId
@@ -152,6 +152,20 @@ export const queryTransactionLink = gql`
}
}
... on DisbursementLink {
+ amount
+ memo
+ code
+ senderCommunity {
+ foreign
+ name
+ description
+ url
+ uuid
+ }
+ senderUser {
+ gradidoID
+ firstName
+ }
recipientCommunity {
foreign
name
@@ -164,11 +178,6 @@ export const queryTransactionLink = gql`
firstName
publisherId
}
- senderGradidoID
- senderName
- amount
- memo
- code
}
... on ContributionLink {
id
diff --git a/frontend/src/pages/TransactionLink.vue b/frontend/src/pages/TransactionLink.vue
index c618672d0..77f9bda9d 100644
--- a/frontend/src/pages/TransactionLink.vue
+++ b/frontend/src/pages/TransactionLink.vue
@@ -58,7 +58,10 @@ const linkData = ref({
__typename: 'TransactionLink',
amount: 0,
memo: '',
- user: null,
+ senderCommunity: null,
+ senderUser: null,
+ recipientCommunity: null,
+ recipientUser: null,
deletedAt: null,
validLink: false,
communities: [],
@@ -121,7 +124,10 @@ const itemType = computed(() => {
console.log('TransactionLink.itemType... REDEEM_SELECT_COMMUNITY')
return 'REDEEM_SELECT_COMMUNITY'
}
- if (linkData.value.user && store.state.gradidoID === linkData.value.user.gradidoID) {
+ if (
+ linkData.value.recipientUser &&
+ store.state.gradidoID === linkData.value.recipientUser.gradidoID
+ ) {
console.log('TransactionLink.itemType... SELF_CREATOR')
return 'SELF_CREATOR'
}
@@ -180,13 +186,16 @@ onMounted(() => {
onResult(() => {
console.log('TransactionLink.onResult... result=', result)
- if (!result || !result.value) return
- if (result.value.__typename === 'TransactionLink') {
+ if (!result || !result.value) {
+ console.log('TransactionLink.onResult... no result:', result)
+ } else if (result.value.__typename === 'TransactionLink') {
console.log('TransactionLink.onResult... redeeming')
setTransactionLinkInformation()
} else if (result.value.__typename === 'DisbursementLink') {
console.log('TransactionLink.onResult... disbursing')
setDisbursementLinkInformation()
+ } else {
+ console.log('TransactionLink.onResult... unknown type:', result.value.__typename)
}
})