mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
overwork transactionLink and disbursementLink
This commit is contained in:
parent
fddfe69bad
commit
11eb0c45a7
@ -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
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
</BRow>
|
||||
</h3>
|
||||
</BCol>
|
||||
<template v-if="linkData.user">
|
||||
{{ linkData.user.firstName }}
|
||||
<template v-if="linkData.senderUser">
|
||||
{{ linkData.senderUser.firstName }}
|
||||
{{ $t('transaction-link.send_you') }} {{ $filters.GDD(linkData.amount) }}
|
||||
</template>
|
||||
</h1>
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user