Map Person to GraphqlMutationPerson
This commit is contained in:
@ -2,6 +2,7 @@ import { Company } from './company.interface';
|
|||||||
import { Pipe } from './pipe.interface';
|
import { Pipe } from './pipe.interface';
|
||||||
|
|
||||||
export type Person = {
|
export type Person = {
|
||||||
|
id: number;
|
||||||
fullName: string;
|
fullName: string;
|
||||||
picture?: string;
|
picture?: string;
|
||||||
email: string;
|
email: string;
|
||||||
@ -29,7 +30,19 @@ export type GraphqlPerson = {
|
|||||||
__typename: string;
|
__typename: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mapPerson = (person: GraphqlPerson): Person => ({
|
export type GraphqlMutationPerson = {
|
||||||
|
city: string;
|
||||||
|
company_id?: number;
|
||||||
|
created_at: string;
|
||||||
|
email: string;
|
||||||
|
firstname: string;
|
||||||
|
id: number;
|
||||||
|
lastname: string;
|
||||||
|
phone: string;
|
||||||
|
__typename: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const mapPerson = (person: GraphqlQueryPerson): Person => ({
|
||||||
fullName: `${person.firstname} ${person.lastname}`,
|
fullName: `${person.firstname} ${person.lastname}`,
|
||||||
creationDate: new Date(person.created_at),
|
creationDate: new Date(person.created_at),
|
||||||
pipe: { name: 'coucou', id: 1, icon: '💰' },
|
pipe: { name: 'coucou', id: 1, icon: '💰' },
|
||||||
@ -41,3 +54,12 @@ export const mapPerson = (person: GraphqlPerson): Person => ({
|
|||||||
},
|
},
|
||||||
countryCode: 'FR',
|
countryCode: 'FR',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const mapGqlPerson = (person: Person): GraphqlMutationPerson => ({
|
||||||
|
firstname: person.fullName.split(' ').shift() || '',
|
||||||
|
lastname: person.fullName.split(' ').slice(1).join(' '),
|
||||||
|
created_at: person.creationDate.toUTCString(),
|
||||||
|
company_id: person.company.id,
|
||||||
|
...(person as Omit<Person, 'company'>),
|
||||||
|
__typename: 'People',
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user