try to get gdt transactionlist working

This commit is contained in:
Moriz Wahl 2021-08-16 17:36:10 +02:00
parent 594030eb9a
commit b633c7006c
5 changed files with 12 additions and 10 deletions

View File

@ -14,15 +14,16 @@ export class GdtTransactionInput {
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })
order?: string order?: string
} }
@ArgsType() @ArgsType()
export class GdtTransactionSessionIdInput { export class GdtTransactionSessionIdInput {
@Field(() => Number) @Field(() => Number)
sessionId: number sessionId: number
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
currentPage?: number currentPage?: number
@Field(() => Number, { nullable: true }) @Field(() => Int, { nullable: true })
pageSize?: number pageSize?: number
@Field(() => String, { nullable: true }) @Field(() => String, { nullable: true })

View File

@ -15,6 +15,7 @@ export enum GdtEntryType {
@ObjectType() @ObjectType()
export class GdtEntry { export class GdtEntry {
constructor(json: any) { constructor(json: any) {
// console.log(json)
this.transactionId = json.transaction_id this.transactionId = json.transaction_id
this.amount = json.amount this.amount = json.amount
this.date = json.date this.date = json.date

View File

@ -2,7 +2,7 @@
import { Resolver, Query, /* Mutation, */ Args } from 'type-graphql' import { Resolver, Query, /* Mutation, */ Args } from 'type-graphql'
import CONFIG from '../../config' import CONFIG from '../../config'
import { GdtEntryList } from '../models/GdtEntryList' import { GdtEntryList } from '../models/GdtEntryList'
import { GdtTransactionInput } from '../inputs/GdtInputs' import { GdtTransactionSessionIdInput } from '../inputs/GdtInputs'
import { apiGet } from '../../apis/loginAPI' import { apiGet } from '../../apis/loginAPI'
@Resolver() @Resolver()
@ -10,13 +10,13 @@ export class GdtResolver {
@Query(() => GdtEntryList) @Query(() => GdtEntryList)
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
async listGDTEntries( async listGDTEntries(
@Args() { email, currentPage = 1, pageSize = 5, order = 'DESC' }: GdtTransactionInput, @Args()
{ currentPage = 1, pageSize = 5, order = 'DESC', sessionId }: GdtTransactionSessionIdInput,
): Promise<GdtEntryList> { ): Promise<GdtEntryList> {
email = email.trim().toLowerCase()
const result = await apiGet( const result = await apiGet(
`${CONFIG.GDT_API_URL}/GdtEntries/listPerEmailApi/${email}/${currentPage}/${pageSize}/${order}`, `${CONFIG.GDT_API_URL}/listGDTTransactions/${currentPage}/${pageSize}/${order}/${sessionId}`,
) )
// console.log(result.data)
if (!result.success) { if (!result.success) {
throw new Error(result.data) throw new Error(result.data)
} }

View File

@ -125,8 +125,8 @@ export const checkUsername = gql`
` `
export const listGDTEntriesQuery = gql` export const listGDTEntriesQuery = gql`
query($email: String!, $currentPage: Int!, $pageSize: Int!) { query($currentPage: Int!, $pageSize: Int!, $sessionId: Float!) {
listGDTEntries(email: $email, currentPage: $currentPage, pageSize: $pageSize) { listGDTEntries(currentPage: $currentPage, pageSize: $pageSize, sessionId: $sessionId) {
count count
gdtEntries { gdtEntries {
transactionId transactionId

View File

@ -199,7 +199,7 @@ export default {
.query({ .query({
query: listGDTEntriesQuery, query: listGDTEntriesQuery,
variables: { variables: {
email: this.$store.state.email, sessionId: this.$store.state.sessionId,
currentPage: this.currentPage, currentPage: this.currentPage,
pageSize: this.pageSize, pageSize: this.pageSize,
}, },