From 7232780baed4d76bfcf02012386b6c0b1bea4fe9 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Mar 2023 19:25:06 +0100 Subject: [PATCH] send form with gradido id via url query --- .../components/GddSend/TransactionForm.vue | 25 ++++++++++++++++++- .../src/components/TransactionRows/Name.vue | 4 +-- frontend/src/graphql/queries.js | 9 +++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/GddSend/TransactionForm.vue b/frontend/src/components/GddSend/TransactionForm.vue index 51e5c5ece..8620337d6 100644 --- a/frontend/src/components/GddSend/TransactionForm.vue +++ b/frontend/src/components/GddSend/TransactionForm.vue @@ -65,7 +65,7 @@ {{ $t('form.recipient') }} - {{ gradidoID }} + {{ userName }} @@ -129,6 +129,7 @@ import { SEND_TYPES } from '@/pages/Send' import InputEmail from '@/components/Inputs/InputEmail' import InputAmount from '@/components/Inputs/InputAmount' import InputTextarea from '@/components/Inputs/InputTextarea' +import { user as userQuery } from '@/graphql/queries' export default { name: 'TransactionForm', @@ -153,6 +154,7 @@ export default { memo: this.memo, }, radioSelected: this.selected, + userName: '', } }, methods: { @@ -173,11 +175,32 @@ export default { this.form.amount = '' this.form.memo = '' this.$refs.formValidator.validate() + if (this.$route.query && !this.$route.query === {}) this.$router.replace({ query: undefined }) }, setNewRecipientEmail() { this.form.email = this.recipientEmail ? this.recipientEmail : this.form.email }, }, + apollo: { + UserName: { + query() { + return userQuery + }, + fetchPolicy: 'network-only', + variables() { + return { identifier: this.gradidoID } + }, + skip() { + return !this.gradidoID + }, + update({ user }) { + this.userName = `${user.firstName} ${user.lastName}` + }, + error({ message }) { + this.toastError(message) + }, + }, + }, watch: { recipientEmail() { this.setNewRecipientEmail() diff --git a/frontend/src/components/TransactionRows/Name.vue b/frontend/src/components/TransactionRows/Name.vue index 84b235cb3..de87c0ad1 100644 --- a/frontend/src/components/TransactionRows/Name.vue +++ b/frontend/src/components/TransactionRows/Name.vue @@ -36,8 +36,8 @@ export default { methods: { tunnelEmail() { this.$emit('set-tunneled-email', this.linkedUser.email) - if (this.$router.history.current.fullPath !== '/send') - this.$router.push({ path: '/send', query: { gradidoID: this.linkedUser.gradidoID } }) + if (this.$router.history.current.fullPath !== '/send') this.$router.push({ path: '/send' }) + this.$router.push({ query: { gradidoID: this.linkedUser.gradidoID } }) }, }, computed: { diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 45f360610..ceaa6043b 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -268,3 +268,12 @@ export const openCreations = gql` } } ` + +export const user = gql` + query($identifier: String!) { + user(identifier: $identifier) { + firstName + lastName + } + } +`