Files
twenty_crm/front/src/interfaces/person.interface.ts
2023-04-20 15:41:18 +02:00

44 lines
926 B
TypeScript

import { Company } from './company.interface';
import { Pipe } from './pipe.interface';
export type Person = {
fullName: string;
picture?: string;
email: string;
company: Company;
phone: string;
creationDate: Date;
pipe: Pipe;
city: string;
countryCode: string;
};
export type GraphqlPerson = {
city: string;
company: {
__typename: string;
company_name: string;
company_domain: string;
};
created_at: string;
email: string;
firstname: string;
id: number;
lastname: string;
phone: string;
__typename: string;
};
export const mapPerson = (person: GraphqlPerson): Person => ({
fullName: `${person.firstname} ${person.lastname}`,
creationDate: new Date(person.created_at),
pipe: { name: 'coucou', id: 1, icon: 'faUser' },
...person,
company: {
id: 1,
name: person.company.company_name,
domain: person.company.company_domain,
},
countryCode: 'FR',
});