Refactor to use filters in query listTransactionLinksAdmin

This commit is contained in:
Wolfgang Huß 2022-05-23 11:23:56 +02:00
parent f901a76b2d
commit 85eaa4b391
4 changed files with 37 additions and 8 deletions

View File

@ -3,8 +3,8 @@ import { Field, InputType } from 'type-graphql'
@InputType()
export default class SearchUsersFilters {
@Field(() => Boolean, { nullable: true, defaultValue: null })
byActivated?: boolean | null
byActivated: boolean
@Field(() => Boolean, { nullable: true, defaultValue: null })
byDeleted?: boolean | null
byDeleted: boolean
}

View File

@ -1,13 +1,13 @@
import { ArgsType, Field } from 'type-graphql'
import { Field, InputType } from 'type-graphql'
@ArgsType()
@InputType()
export default class TransactionLinkFilters {
@Field(() => Boolean, { nullable: true, defaultValue: true })
byDeleted?: boolean
byDeleted: boolean
@Field(() => Boolean, { nullable: true, defaultValue: true })
byExpired?: boolean
byExpired: boolean
@Field(() => Boolean, { nullable: true, defaultValue: true })
byRedeemed?: boolean
byRedeemed: boolean
}

View File

@ -426,7 +426,7 @@ export class AdminResolver {
async listTransactionLinksAdmin(
@Args()
{ currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated,
@Args()
@Arg('filters')
filters: TransactionLinkFilters,
@Arg('userId', () => Int) userId: number,
): Promise<TransactionLinkResult> {

View File

@ -163,3 +163,32 @@ export const deletePendingCreation = gql`
deletePendingCreation(id: $id)
}
`
export const listTransactionLinksAdmin = gql`
query (
$userId: Int!
$filters: TransactionLinkFilters!
$currentPage: Int = 1
$pageSize: Int = 5
) {
listTransactionLinksAdmin(
userId: $userId
filters: $filters
currentPage: $currentPage
pageSize: $pageSize
) {
linkCount
linkList {
id
amount
holdAvailableAmount
memo
code
createdAt
validUntil
redeemedAt
deletedAt
}
}
}
`