refactor: move mapper in interface
This commit is contained in:
@ -28,3 +28,16 @@ export type GraphqlPerson = {
|
|||||||
phone: string;
|
phone: string;
|
||||||
__typename: 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',
|
||||||
|
});
|
||||||
|
|||||||
@ -4,9 +4,12 @@ import Table from '../../components/table/Table';
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { peopleColumns } from './people-table';
|
import { peopleColumns } from './people-table';
|
||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery } from '@apollo/client';
|
||||||
import { GraphqlPerson, Person } from '../../interfaces/person.interface';
|
import {
|
||||||
|
GraphqlPerson,
|
||||||
|
Person,
|
||||||
|
mapPerson,
|
||||||
|
} from '../../interfaces/person.interface';
|
||||||
import { defaultData } from './default-data';
|
import { defaultData } from './default-data';
|
||||||
import { mapPerson } from './mapper';
|
|
||||||
|
|
||||||
const StyledPeopleContainer = styled.div`
|
const StyledPeopleContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
import { GraphqlPerson, Person } from '../../interfaces/person.interface';
|
|
||||||
|
|
||||||
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',
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user