Make all fields optional on entities (#121)
* Make all fields optional on entities * Rewrite tests * Add test on TableHeader Cancel button
This commit is contained in:
@ -1,75 +1,72 @@
|
||||
import { GraphqlQueryUser, User } from './user.interface';
|
||||
|
||||
export interface Opportunity {
|
||||
id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
}
|
||||
import { Pipe } from 'stream';
|
||||
import { GraphqlQueryUser, User, mapToUser } from './user.interface';
|
||||
import { GraphqlQueryPipe } from './pipe.interface';
|
||||
|
||||
export type Company = {
|
||||
id: string;
|
||||
name: string;
|
||||
domain_name: string;
|
||||
employees: number;
|
||||
address: string;
|
||||
opportunities: Opportunity[];
|
||||
name?: string;
|
||||
domainName?: string;
|
||||
employees?: string;
|
||||
address?: string;
|
||||
|
||||
creationDate?: Date;
|
||||
|
||||
pipes?: Pipe[];
|
||||
accountOwner?: User | null;
|
||||
creationDate: Date;
|
||||
};
|
||||
|
||||
export type GraphqlQueryCompany = {
|
||||
id: string;
|
||||
name: string;
|
||||
domain_name: string;
|
||||
name?: string;
|
||||
domain_name?: string;
|
||||
employees?: string;
|
||||
address?: string;
|
||||
|
||||
created_at?: string;
|
||||
|
||||
account_owner?: GraphqlQueryUser | null;
|
||||
employees: number;
|
||||
address: string;
|
||||
created_at: string;
|
||||
pipes?: GraphqlQueryPipe[] | null;
|
||||
__typename: string;
|
||||
};
|
||||
|
||||
export type GraphqlMutationCompany = {
|
||||
id: string;
|
||||
name: string;
|
||||
domain_name: string;
|
||||
name?: string;
|
||||
domain_name?: string;
|
||||
employees?: string;
|
||||
address?: string;
|
||||
|
||||
created_at?: string;
|
||||
|
||||
account_owner_id?: string;
|
||||
employees: number;
|
||||
address: string;
|
||||
created_at: string;
|
||||
account_owner?: GraphqlQueryUser | null;
|
||||
__typename: string;
|
||||
};
|
||||
|
||||
export const mapCompany = (company: GraphqlQueryCompany): Company => ({
|
||||
export const mapToCompany = (company: GraphqlQueryCompany): Company => ({
|
||||
id: company.id,
|
||||
employees: company.employees,
|
||||
name: company.name,
|
||||
address: company.address,
|
||||
domain_name: company.domain_name,
|
||||
domainName: company.domain_name,
|
||||
creationDate: company.created_at ? new Date(company.created_at) : undefined,
|
||||
|
||||
accountOwner: company.account_owner
|
||||
? {
|
||||
id: company.account_owner.id,
|
||||
email: company.account_owner.email,
|
||||
displayName: company.account_owner.displayName,
|
||||
}
|
||||
: null,
|
||||
creationDate: new Date(company.created_at),
|
||||
opportunities: [],
|
||||
? mapToUser(company.account_owner)
|
||||
: company.account_owner,
|
||||
pipes: [],
|
||||
});
|
||||
|
||||
export const mapGqlCompany = (company: Company): GraphqlMutationCompany => ({
|
||||
export const mapToGqlCompany = (company: Company): GraphqlMutationCompany => ({
|
||||
id: company.id,
|
||||
name: company.name,
|
||||
domain_name: company.domain_name,
|
||||
created_at: company.creationDate.toUTCString(),
|
||||
account_owner_id: company.accountOwner?.id,
|
||||
domain_name: company.domainName,
|
||||
address: company.address,
|
||||
employees: company.employees,
|
||||
id: company.id,
|
||||
account_owner: company.accountOwner
|
||||
? {
|
||||
id: company.accountOwner?.id,
|
||||
email: company.accountOwner?.email,
|
||||
displayName: company.accountOwner?.displayName,
|
||||
__typename: 'users',
|
||||
}
|
||||
: null,
|
||||
|
||||
created_at: company.creationDate
|
||||
? company.creationDate.toUTCString()
|
||||
: undefined,
|
||||
|
||||
account_owner_id: company.accountOwner?.id,
|
||||
__typename: 'companies',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user