mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Update pending creation
This commit is contained in:
parent
1ba1c44219
commit
4c2e51b517
@ -232,6 +232,7 @@ export default {
|
||||
}
|
||||
if (this.type === 'singleCreation') {
|
||||
this.submitObj = {
|
||||
id: this.item.id,
|
||||
email: this.item.email,
|
||||
creationDate: this.radioSelected.long,
|
||||
amount: Number(this.value),
|
||||
@ -247,14 +248,20 @@ export default {
|
||||
variables: this.submitObj,
|
||||
})
|
||||
.then((result) => {
|
||||
this.$emit('update-user-data', this.item, result.data.createPendingCreation)
|
||||
this.$emit('update-user-data', this.item, result.data.updatePendingCreation.creation)
|
||||
this.$emit('update-creation-data', {
|
||||
amount: Number(result.data.updatePendingCreation.amount),
|
||||
date: result.data.updatePendingCreation.date,
|
||||
memo: result.data.updatePendingCreation.memo,
|
||||
moderator: Number(result.data.updatePendingCreation.moderator),
|
||||
})
|
||||
this.$toasted.success(
|
||||
`Offene schöpfung (${this.value} GDD) für ${this.item.email} wurde geändert, liegt zur Bestätigung bereit`,
|
||||
)
|
||||
this.submitObj = null
|
||||
this.createdIndex = null
|
||||
// das creation Formular reseten
|
||||
this.$refs.creationForm.reset()
|
||||
this.$refs.updateCreationForm.reset()
|
||||
// Den geschöpften Wert auf o setzen
|
||||
this.value = 0
|
||||
})
|
||||
@ -262,7 +269,7 @@ export default {
|
||||
this.$toasted.error(error.message)
|
||||
this.submitObj = null
|
||||
// das creation Formular reseten
|
||||
this.$refs.creationForm.reset()
|
||||
this.$refs.updateCreationForm.reset()
|
||||
// Den geschöpften Wert auf o setzen
|
||||
this.value = 0
|
||||
})
|
||||
|
||||
@ -240,9 +240,18 @@ export default {
|
||||
row.toggleDetails()
|
||||
},
|
||||
updateCreationData(data) {
|
||||
this.creationUserData = {
|
||||
...data,
|
||||
}
|
||||
// console.log('updateCreationData this.creationUserData11=> ', this.creationUserData)
|
||||
// console.log('updateCreationData data=> ', data)
|
||||
// this.creationUserData = {
|
||||
// ...this.creationUserData,
|
||||
// ...data,
|
||||
// }
|
||||
// console.log('updateCreationData this.creationUserData22=> ', this.creationUserData)
|
||||
|
||||
this.creationUserData.amount = data.amount
|
||||
this.creationUserData.date = data.date
|
||||
this.creationUserData.memo = data.memo
|
||||
this.creationUserData.moderator = data.moderator
|
||||
},
|
||||
updateUserData(rowItem, newCreation) {
|
||||
rowItem.creation = newCreation
|
||||
|
||||
@ -1,13 +1,27 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const updatePendingCreation = gql`
|
||||
query ($email: String!, $amount: Int!, $memo: String!, $creationDate: String!, $moderator: Int!) {
|
||||
mutation (
|
||||
$id: Int!
|
||||
$email: String!
|
||||
$amount: Int!
|
||||
$memo: String!
|
||||
$creationDate: String!
|
||||
$moderator: Int!
|
||||
) {
|
||||
updatePendingCreation(
|
||||
id: $id
|
||||
email: $email
|
||||
amount: $amount
|
||||
memo: $memo
|
||||
creationDate: $creationDate
|
||||
moderator: $moderator
|
||||
)
|
||||
) {
|
||||
amount
|
||||
date
|
||||
memo
|
||||
creation
|
||||
moderator
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
22
backend/src/graphql/arg/UpdatePendingCreationArgs.ts
Normal file
22
backend/src/graphql/arg/UpdatePendingCreationArgs.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { ArgsType, Field, Int } from 'type-graphql'
|
||||
|
||||
@ArgsType()
|
||||
export default class CreatePendingCreationArgs {
|
||||
@Field(() => Int)
|
||||
id: number
|
||||
|
||||
@Field(() => String)
|
||||
email: string
|
||||
|
||||
@Field(() => Int)
|
||||
amount: number
|
||||
|
||||
@Field(() => String)
|
||||
memo: string
|
||||
|
||||
@Field(() => String)
|
||||
creationDate: string
|
||||
|
||||
@Field(() => Int)
|
||||
moderator: number
|
||||
}
|
||||
19
backend/src/graphql/model/UpdatePendingCreation.ts
Normal file
19
backend/src/graphql/model/UpdatePendingCreation.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@ObjectType()
|
||||
export class UpdatePendingCreation {
|
||||
@Field(() => Date)
|
||||
date: Date
|
||||
|
||||
@Field(() => String)
|
||||
memo: string
|
||||
|
||||
@Field(() => Number)
|
||||
amount: number
|
||||
|
||||
@Field(() => Number)
|
||||
moderator: number
|
||||
|
||||
@Field(() => [Number])
|
||||
creation: number[]
|
||||
}
|
||||
@ -2,11 +2,13 @@ import { Resolver, Query, Arg, Args, Authorized, Mutation } from 'type-graphql'
|
||||
import { getCustomRepository, Raw } from 'typeorm'
|
||||
import { UserAdmin } from '../model/UserAdmin'
|
||||
import { PendingCreation } from '../model/PendingCreation'
|
||||
import { UpdatePendingCreation } from '../model/UpdatePendingCreation'
|
||||
import { RIGHTS } from '../../auth/RIGHTS'
|
||||
import { TransactionCreationRepository } from '../../typeorm/repository/TransactionCreation'
|
||||
import { PendingCreationRepository } from '../../typeorm/repository/PendingCreation'
|
||||
import { UserRepository } from '../../typeorm/repository/User'
|
||||
import CreatePendingCreationArgs from '../arg/CreatePendingCreationArgs'
|
||||
import UpdatePendingCreationArgs from '../arg/UpdatePendingCreationArgs'
|
||||
import moment from 'moment'
|
||||
import { LoginPendingTasksAdmin } from '@entity/LoginPendingTasksAdmin'
|
||||
|
||||
@ -30,6 +32,7 @@ export class AdminResolver {
|
||||
return adminUsers
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.SEARCH_USERS])
|
||||
@Mutation(() => [Number])
|
||||
async createPendingCreation(
|
||||
@Args() { email, amount, memo, creationDate, moderator }: CreatePendingCreationArgs,
|
||||
@ -54,6 +57,55 @@ export class AdminResolver {
|
||||
return await getUserCreations(user.id)
|
||||
}
|
||||
|
||||
// @Authorized([RIGHTS.SEARCH_USERS])
|
||||
@Mutation(() => UpdatePendingCreation)
|
||||
async updatePendingCreation(
|
||||
@Args() { id, email, amount, memo, creationDate, moderator }: UpdatePendingCreationArgs,
|
||||
): Promise<UpdatePendingCreation> {
|
||||
console.log('UpdatePendingCreationArgs', { id, email, amount, memo, creationDate, moderator })
|
||||
const userRepository = getCustomRepository(UserRepository)
|
||||
const user = await userRepository.findByEmail(email)
|
||||
|
||||
const pendingCreationRepository = getCustomRepository(PendingCreationRepository)
|
||||
const updatedCreation = await pendingCreationRepository.findOneOrFail({ id })
|
||||
console.log('updatedCreation', updatedCreation)
|
||||
|
||||
if (updatedCreation.userId !== user.id)
|
||||
throw new Error('user of the pending creation and send user does not correspond')
|
||||
|
||||
updatedCreation.amount = BigInt(amount * 10000)
|
||||
updatedCreation.memo = memo
|
||||
updatedCreation.date = new Date(creationDate)
|
||||
updatedCreation.moderator = moderator
|
||||
|
||||
await pendingCreationRepository.save(updatedCreation)
|
||||
const result = new UpdatePendingCreation()
|
||||
result.amount = parseInt(updatedCreation.amount.toString())
|
||||
result.memo = updatedCreation.memo
|
||||
result.date = updatedCreation.date
|
||||
result.moderator = updatedCreation.moderator
|
||||
result.creation = await getUserCreations(user.id)
|
||||
|
||||
console.log('result', result)
|
||||
return result
|
||||
|
||||
// const creations = await getUserCreations(user.id)
|
||||
// const creationDateObj = new Date(creationDate)
|
||||
// if (isCreationValid(creations, amount, creationDateObj)) {
|
||||
// const pendingCreationRepository = getCustomRepository(PendingCreationRepository)
|
||||
// const loginPendingTaskAdmin = pendingCreationRepository.create()
|
||||
// loginPendingTaskAdmin.userId = user.id
|
||||
// loginPendingTaskAdmin.amount = BigInt(amount * 10000)
|
||||
// loginPendingTaskAdmin.created = new Date()
|
||||
// loginPendingTaskAdmin.date = creationDateObj
|
||||
// loginPendingTaskAdmin.memo = memo
|
||||
// loginPendingTaskAdmin.moderator = moderator
|
||||
//
|
||||
// pendingCreationRepository.save(loginPendingTaskAdmin)
|
||||
// }
|
||||
// return await getUserCreations(user.id)
|
||||
}
|
||||
|
||||
@Query(() => [PendingCreation])
|
||||
async getPendingCreations(): Promise<PendingCreation[]> {
|
||||
const pendingCreationRepository = getCustomRepository(PendingCreationRepository)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user