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,64 +1,77 @@
|
||||
import { Company, GraphqlQueryCompany, mapCompany } from './company.interface';
|
||||
import {
|
||||
Company,
|
||||
GraphqlQueryCompany,
|
||||
mapToCompany,
|
||||
} from './company.interface';
|
||||
import { Pipe } from './pipe.interface';
|
||||
|
||||
export type Person = {
|
||||
id: string;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
picture?: string;
|
||||
email: string;
|
||||
company: Company | null;
|
||||
phone: string;
|
||||
creationDate: Date;
|
||||
pipe: Pipe | null;
|
||||
city: string;
|
||||
firstname?: string;
|
||||
lastname?: string;
|
||||
picture?: string | null;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
city?: string;
|
||||
|
||||
creationDate?: Date;
|
||||
|
||||
company?: Company | null;
|
||||
pipes?: Pipe[] | null;
|
||||
};
|
||||
|
||||
export type GraphqlQueryPerson = {
|
||||
city: string;
|
||||
company: GraphqlQueryCompany | null;
|
||||
created_at: string;
|
||||
email: string;
|
||||
firstname: string;
|
||||
id: string;
|
||||
lastname: string;
|
||||
phone: string;
|
||||
firstname?: string;
|
||||
lastname?: string;
|
||||
city?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
|
||||
created_at?: string;
|
||||
|
||||
company?: GraphqlQueryCompany | null;
|
||||
|
||||
__typename: string;
|
||||
};
|
||||
|
||||
export type GraphqlMutationPerson = {
|
||||
city: string;
|
||||
company_id?: string;
|
||||
created_at: string;
|
||||
email: string;
|
||||
firstname: string;
|
||||
id: string;
|
||||
lastname: string;
|
||||
phone: string;
|
||||
firstname?: string;
|
||||
lastname?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
city?: string;
|
||||
created_at?: string;
|
||||
company_id?: string;
|
||||
__typename: string;
|
||||
};
|
||||
|
||||
export const mapPerson = (person: GraphqlQueryPerson): Person => ({
|
||||
export const mapToPerson = (person: GraphqlQueryPerson): Person => ({
|
||||
id: person.id,
|
||||
firstname: person.firstname,
|
||||
lastname: person.lastname,
|
||||
email: person.email,
|
||||
phone: person.phone,
|
||||
city: person.city,
|
||||
firstname: person.firstname,
|
||||
lastname: person.lastname,
|
||||
creationDate: new Date(person.created_at),
|
||||
pipe: {
|
||||
name: 'coucou',
|
||||
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
|
||||
icon: '💰',
|
||||
},
|
||||
company: person.company ? mapCompany(person.company) : null,
|
||||
|
||||
creationDate: person.created_at ? new Date(person.created_at) : undefined,
|
||||
|
||||
company: person.company ? mapToCompany(person.company) : null,
|
||||
});
|
||||
|
||||
export const mapGqlPerson = (person: Person): GraphqlMutationPerson => ({
|
||||
...(person as Omit<Person, 'company'>),
|
||||
export const mapToGqlPerson = (person: Person): GraphqlMutationPerson => ({
|
||||
id: person.id,
|
||||
firstname: person.firstname,
|
||||
lastname: person.lastname,
|
||||
created_at: person.creationDate.toUTCString(),
|
||||
email: person.email,
|
||||
phone: person.phone,
|
||||
city: person.city,
|
||||
|
||||
created_at: person.creationDate
|
||||
? person.creationDate.toUTCString()
|
||||
: undefined,
|
||||
|
||||
company_id: person.company?.id,
|
||||
__typename: 'People',
|
||||
__typename: 'people',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user