final changes before merge

This commit is contained in:
Moriz Wahl 2021-08-04 11:51:50 +02:00
parent 729aa02035
commit 403826a6d9
8 changed files with 17 additions and 122 deletions

View File

@ -32,8 +32,6 @@ export const apiGet = async (url: string): Promise<any> => {
return { success: true, data: result.data }
})
.catch((error) => {
// eslint-disable-next-line no-console
console.log('IN apiGet.ERROR: ', { success: false, result: error })
return { success: false, data: error.message }
})
}

View File

@ -1,22 +1,5 @@
import { ArgsType, Field } from 'type-graphql'
/*
@InputType()
export class LoginUserInput {
@Field({ nullable: true })
username?: string
@Field({ nullable: true })
email?: string
@Field({ nullable: true })
pubkey?: string
@Field()
password: string
}
*/
@ArgsType()
export class UnsecureLoginArgs {
@Field(() => String)
@ -41,18 +24,6 @@ export class CreateUserArgs {
password: string
}
@ArgsType()
export class SendEmailArgs {
@Field(() => String)
email: string
@Field(() => Number)
emailText: number
@Field(() => String)
emailVerificationCodeType: string
}
@ArgsType()
export class GetUserInfoArgs {
@Field(() => Number)
@ -109,6 +80,6 @@ export class CheckUsernameArgs {
@Field(() => String)
username: string
@Field(() => Number)
@Field(() => Number, { nullable: true })
groupId?: number
}

View File

@ -1,14 +1,14 @@
import { ArgsType, Field } from 'type-graphql'
import { ArgsType, Field, Int } from 'type-graphql'
@ArgsType()
export class TransactionListInput {
@Field(() => Number)
sessionId: number
@Field(() => Number)
@Field(() => Int)
firstPage: number
@Field(() => Number)
@Field(() => Int)
items: number
@Field(() => String)
@ -29,21 +29,3 @@ export class TransactionSendArgs {
@Field(() => String)
memo: string
}
@ArgsType()
export class TransactionCreateArgs {
@Field(() => Number)
sessionId: number
@Field(() => String)
email: string
@Field(() => Number)
amount: number
@Field(() => String)
memo: string
@Field(() => Date)
targetDate: Date
}

View File

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ObjectType, Field } from 'type-graphql'
import { ObjectType, Field, Int } from 'type-graphql'
@ObjectType()
export class Decay {
@ -14,12 +14,12 @@ export class Decay {
@Field(() => Number)
balance: number
@Field({ nullable: true })
@Field(() => Int, { nullable: true })
decayStart?: number
@Field({ nullable: true })
@Field(() => Int, { nullable: true })
decayEnd?: number
@Field(() => String)
decayDuration: string
@Field(() => String, { nullable: true })
decayDuration?: string
}

View File

@ -1,16 +0,0 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Entity, BaseEntity } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
@Entity()
@ObjectType()
export class Server extends BaseEntity {
constructor(json: any) {
super()
this.loginServerPath = json.login_server_path
}
@Field(() => String)
loginServerPath: string
}

View File

@ -11,6 +11,7 @@ import { Decay } from './Decay'
@ObjectType()
export class Transaction {
constructor(json: any) {
// console.log('Transaction constructor', json)
this.type = json.type
this.balance = Number(json.balance)
this.decayStart = json.decay_start
@ -21,7 +22,7 @@ export class Transaction {
this.name = json.name
this.email = json.email
this.date = json.date
this.decay = json.decay
this.decay = json.decay ? new Decay(json.decay) : undefined
}
@Field(() => String)
@ -66,7 +67,9 @@ export class TransactionList {
this.balance = Number(json.balance)
this.decay = Number(json.decay)
this.decayDate = json.decay_date
this.transactions = json.transactions
this.transactions = json.transactions.map((el: any) => {
return new Transaction(el)
})
}
@Field(() => Number)

View File

@ -1,40 +0,0 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Entity, BaseEntity } from 'typeorm'
import { ObjectType, Field } from 'type-graphql'
import { Server } from './Server'
import { User } from './User'
@Entity()
@ObjectType()
export class UserInfoData extends BaseEntity {
constructor(json: any) {
super()
this.state = json.state
this.userData = new User(json.user_data)
this.server = new Server(json.server)
this.errors = json.errors
}
@Field(() => String)
state: string
@Field(() => User)
userData: User
@Field(() => Server)
server: Server
@Field(() => [String])
errors: [string]
}
@Entity()
@ObjectType()
export class GetUserInfoResponse extends BaseEntity {
@Field(() => Boolean)
success: boolean
@Field(() => UserInfoData)
data: UserInfoData
}

View File

@ -12,7 +12,6 @@ import {
CheckUsernameArgs,
CreateUserArgs,
GetUserInfoArgs,
SendEmailArgs,
UnsecureLoginArgs,
UpdateUserInfosArgs,
} from '../inputs/LoginUserInput'
@ -89,16 +88,14 @@ export class UserResolver {
return 'success'
}
// TODO
@Query(() => SendPasswordResetEmailResponse)
async sendResetPasswordEmail(
@Args()
{ email, emailText = 7, emailVerificationCodeType = 'resetPassword' }: SendEmailArgs,
@Arg('email') email: string,
): Promise<SendPasswordResetEmailResponse> {
const payload = {
email,
email_text: emailText,
email_verification_code_type: emailVerificationCodeType,
email_text: 7,
email_verification_code_type: 'resetPassword',
}
const response = await apiPost(CONFIG.LOGIN_API_URL + 'sendEmail', payload)
if (!response.success) throw new Error(response.data)