import { ObjectType, Field, ID, ArgsType, InputType, registerEnumType, Ctx } from 'type-graphql'; import { BaseGraphModel } from '@seed/graphql/BaseGraphModel'; import { Permission } from '@seed/interfaces/permission'; import { TranslatableComponent } from '@src/__components/components'; import { GetArgs } from '@seed/graphql/Request'; import { AccountTypeEnum } from '@src/accounts/account.components'; import { ApolloContext } from '@seed/interfaces/context'; import { TVAValue } from './vat.components'; const permissions: Permission = { c: [AccountTypeEnum.admin], r: [AccountTypeEnum.admin, AccountTypeEnum.public], w: [AccountTypeEnum.admin], d: [AccountTypeEnum.admin], }; @ObjectType() export default class VatClassModel extends BaseGraphModel { public constructor() { super({ // ...init, collectionName: 'shop.vat', permissions: permissions, }); } // eslint-disable-next-line @typescript-eslint/no-unused-vars @Field(() => ID) readonly _id: string; @Field() title: string; @Field(() => TVAValue) values: TVAValue; searchOptions(): string[] { return []; } filterOptions(): string[] { return []; } } @ArgsType() export class VatClassArgs { @Field(() => GetArgs, { nullable: true }) pagination?: GetArgs; } @InputType() export class EditVatClassInput { @Field() title: string; @Field(() => TVAValue, { nullable: true }) values?: TVAValue; } @InputType() export class NewVatClassInput { @Field() title: string; @Field(() => TVAValue) values: TVAValue; } @InputType() export class ValidateVatInput { @Field() countryCode: string; @Field() vatNumber: string; } @ObjectType() export class VatResponse { @Field(() => Boolean) valid: boolean; @Field({ nullable: true }) database?: string; @Field(() => Boolean) format_valid?: boolean; @Field({ nullable: true }) query?: string; @Field({ nullable: true }) country_code?: string; @Field({ nullable: true }) vat_number?: string; @Field({ nullable: true }) company_name?: string; @Field({ nullable: true }) company_address?: string; }