From 76603d82cf4ec311d5aa66fce196b0e8d6ea9d4a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Jun 2023 22:18:44 +0200 Subject: [PATCH 1/6] rework GdtEntry --- backend/src/graphql/model/GdtEntry.ts | 42 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/backend/src/graphql/model/GdtEntry.ts b/backend/src/graphql/model/GdtEntry.ts index 81dda0ca7..43a33ba30 100644 --- a/backend/src/graphql/model/GdtEntry.ts +++ b/backend/src/graphql/model/GdtEntry.ts @@ -1,25 +1,39 @@ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { ObjectType, Field, Float, Int } from 'type-graphql' import { GdtEntryType } from '@enum/GdtEntryType' @ObjectType() export class GdtEntry { - constructor(json: any) { - this.id = json.id - this.amount = json.amount - this.date = json.date - this.email = json.email - this.comment = json.comment - this.couponCode = json.coupon_code - this.gdtEntryType = json.gdt_entry_type_id - this.factor = json.factor - this.amount2 = json.amount2 - this.factor2 = json.factor2 - this.gdt = json.gdt + constructor({ + id, + amount, + date, + email, + comment, + // eslint-disable-next-line camelcase + coupon_code, + // eslint-disable-next-line camelcase + gdt_entry_type_id, + factor, + amount2, + factor2, + gdt, + }: any) { + this.id = id + this.amount = amount + this.date = date + this.email = email + this.comment = comment + // eslint-disable-next-line camelcase + this.couponCode = coupon_code + // eslint-disable-next-line camelcase + this.gdtEntryType = gdt_entry_type_id + this.factor = factor + this.amount2 = amount2 + this.factor2 = factor2 + this.gdt = gdt } @Field(() => Int) From c5cbb9e1204bb619a7b9aabde95df303823cd5a2 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Jun 2023 22:18:56 +0200 Subject: [PATCH 2/6] rework GdtEntryList --- backend/src/graphql/model/GdtEntryList.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/backend/src/graphql/model/GdtEntryList.ts b/backend/src/graphql/model/GdtEntryList.ts index 7c08520c8..adbe5dbc6 100644 --- a/backend/src/graphql/model/GdtEntryList.ts +++ b/backend/src/graphql/model/GdtEntryList.ts @@ -1,20 +1,15 @@ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { ObjectType, Field, Int, Float } from 'type-graphql' import { GdtEntry } from './GdtEntry' @ObjectType() export class GdtEntryList { - constructor(json: any) { - this.status = json.state - this.count = json.count - this.gdtEntries = json.gdtEntries ? json.gdtEntries.map((json: any) => new GdtEntry(json)) : [] - this.gdtSum = json.gdtSum - this.timeUsed = json.timeUsed + constructor(status = '', count = 0, gdtEntries = [], gdtSum = 0, timeUsed = 0) { + this.status = status + this.count = count + this.gdtEntries = gdtEntries + this.gdtSum = gdtSum + this.timeUsed = timeUsed } @Field(() => String) From 87e5b7437fe45e286869bf0e8519df232236e8ad Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Jun 2023 22:19:28 +0200 Subject: [PATCH 3/6] properly construct result objects, return an empty GDT list on success=false --- backend/src/graphql/resolver/GdtResolver.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/GdtResolver.ts b/backend/src/graphql/resolver/GdtResolver.ts index 3b9213567..74cd81f01 100644 --- a/backend/src/graphql/resolver/GdtResolver.ts +++ b/backend/src/graphql/resolver/GdtResolver.ts @@ -6,6 +6,7 @@ import { Resolver, Query, Args, Ctx, Authorized, Arg, Int, Float } from 'type-gr import { Paginated } from '@arg/Paginated' import { Order } from '@enum/Order' +import { GdtEntry } from '@model/GdtEntry' import { GdtEntryList } from '@model/GdtEntryList' import { apiGet, apiPost } from '@/apis/HttpRequest' @@ -31,9 +32,17 @@ export class GdtResolver { `${CONFIG.GDT_API_URL}/GdtEntries/listPerEmailApi/${userEntity.emailContact.email}/${currentPage}/${pageSize}/${order}`, ) if (!resultGDT.success) { - throw new LogError(resultGDT.data) + return new GdtEntryList() } - return new GdtEntryList(resultGDT.data) + const { state, count, gdtEntries, gdtSum, timeUsed } = resultGDT.data + return new GdtEntryList( + state, + count, + // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any + gdtEntries ? gdtEntries.map((data: any) => new GdtEntry(data)) : [], + gdtSum, + timeUsed, + ) } catch (err) { throw new LogError('GDT Server is not reachable') } From ccada453c0b474ffa2962097abffb3c51009fef9 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Jun 2023 22:37:20 +0200 Subject: [PATCH 4/6] fixed vue error --- frontend/src/layouts/DashboardLayout.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vue index 9db576f1f..9a4c28aa2 100755 --- a/frontend/src/layouts/DashboardLayout.vue +++ b/frontend/src/layouts/DashboardLayout.vue @@ -276,7 +276,7 @@ export default { } = result this.GdtBalance = transactionList.balance.balanceGDT === null - ? null + ? 0 : Number(transactionList.balance.balanceGDT) this.transactions = transactionList.transactions this.balance = Number(transactionList.balance.balance) From e62a677668bc70ddbac2735184612f86140b3868 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 27 Jun 2023 22:37:37 +0200 Subject: [PATCH 5/6] fixed network policy for gdt query --- frontend/src/pages/Transactions.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/pages/Transactions.vue b/frontend/src/pages/Transactions.vue index 95c1c3400..9b8694173 100644 --- a/frontend/src/pages/Transactions.vue +++ b/frontend/src/pages/Transactions.vue @@ -59,6 +59,7 @@ export default { currentPage: this.currentPage, pageSize: this.pageSize, }, + fetchPolicy: 'network-only', }) .then((result) => { const { From f86d0e916265df4cb7fb97d6b73be51f5f3a1f07 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 28 Jun 2023 10:55:05 +0200 Subject: [PATCH 6/6] fix tests for new network policy in transactions --- frontend/src/pages/Transactions.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/pages/Transactions.spec.js b/frontend/src/pages/Transactions.spec.js index ea2a5e1f6..bcff628cc 100644 --- a/frontend/src/pages/Transactions.spec.js +++ b/frontend/src/pages/Transactions.spec.js @@ -142,6 +142,7 @@ describe('Transactions', () => { currentPage: 1, pageSize: 25, }, + fetchPolicy: 'network-only', }) }) @@ -170,6 +171,7 @@ describe('Transactions', () => { currentPage: 2, pageSize: 25, }, + fetchPolicy: 'network-only', }) }) })