mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Corected return type for getPendingCreations and corected query.
This commit is contained in:
parent
99749eebb2
commit
602dfd64f1
@ -2,6 +2,14 @@ import gql from 'graphql-tag'
|
|||||||
|
|
||||||
export const getPendingCreations = gql`
|
export const getPendingCreations = gql`
|
||||||
query {
|
query {
|
||||||
getPendingCreations
|
getPendingCreations {
|
||||||
|
firstName
|
||||||
|
lastName
|
||||||
|
email
|
||||||
|
amount
|
||||||
|
note
|
||||||
|
date
|
||||||
|
moderator
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
31
backend/src/graphql/model/PendingCreation.ts
Normal file
31
backend/src/graphql/model/PendingCreation.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { ObjectType, Field, Int } from 'type-graphql'
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class PendingCreation {
|
||||||
|
@Field(() => String)
|
||||||
|
firstName: string
|
||||||
|
|
||||||
|
@Field(() => Int)
|
||||||
|
id?: number
|
||||||
|
|
||||||
|
@Field(() => String)
|
||||||
|
lastName: string
|
||||||
|
|
||||||
|
@Field(() => Number)
|
||||||
|
userId: number
|
||||||
|
|
||||||
|
@Field(() => String)
|
||||||
|
email: string
|
||||||
|
|
||||||
|
@Field(() => Date)
|
||||||
|
date: Date
|
||||||
|
|
||||||
|
@Field(() => String)
|
||||||
|
note: string
|
||||||
|
|
||||||
|
@Field(() => Number)
|
||||||
|
amount: BigInt
|
||||||
|
|
||||||
|
@Field(() => Number)
|
||||||
|
moderator: number
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import { Resolver, Query, Arg, Args, Authorized } from 'type-graphql'
|
import { Resolver, Query, Arg, Args, Authorized } from 'type-graphql'
|
||||||
import { getCustomRepository, Raw, Any } from 'typeorm'
|
import { getCustomRepository, Raw, Any } from 'typeorm'
|
||||||
import { UserAdmin } from '../model/UserAdmin'
|
import { UserAdmin } from '../model/UserAdmin'
|
||||||
|
import { PendingCreation } from '../model/PendingCreation'
|
||||||
import { LoginUserRepository } from '../../typeorm/repository/LoginUser'
|
import { LoginUserRepository } from '../../typeorm/repository/LoginUser'
|
||||||
import { RIGHTS } from '../../auth/RIGHTS'
|
import { RIGHTS } from '../../auth/RIGHTS'
|
||||||
import { TransactionCreationRepository } from '../../typeorm/repository/TransactionCreation'
|
import { TransactionCreationRepository } from '../../typeorm/repository/TransactionCreation'
|
||||||
@ -54,12 +55,28 @@ export class AdminResolver {
|
|||||||
return await getUserCreations(user.id)
|
return await getUserCreations(user.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query(() => String)
|
@Query(() => [PendingCreation])
|
||||||
async getPendingCreations(): Promise<string> {
|
async getPendingCreations(): Promise<PendingCreation[]> {
|
||||||
const pendingCreationRepository = getCustomRepository(PendingCreationRepository)
|
const pendingCreationRepository = getCustomRepository(PendingCreationRepository)
|
||||||
const pendingCreations = await pendingCreationRepository.find()
|
const pendingCreations = await pendingCreationRepository.find()
|
||||||
console.log('pendingCreations', pendingCreations)
|
|
||||||
return pendingCreations.toString()
|
const pendingCreationsPromise = await Promise.all(
|
||||||
|
pendingCreations.map(async (pendingCreation) => {
|
||||||
|
const userRepository = getCustomRepository(UserRepository)
|
||||||
|
const user = await userRepository.findOneOrFail({ id: pendingCreation.userId })
|
||||||
|
|
||||||
|
const newPendingCreation = {
|
||||||
|
...pendingCreation,
|
||||||
|
firstName: user.firstName,
|
||||||
|
lastName: user.lastName,
|
||||||
|
email: user.email,
|
||||||
|
}
|
||||||
|
|
||||||
|
return newPendingCreation
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
console.log('pendingCreations', pendingCreationsPromise)
|
||||||
|
return pendingCreationsPromise
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user