refactor: move mapper in interface

This commit is contained in:
Sammy Teillet
2023-04-20 15:41:18 +02:00
parent b8032e9605
commit b3acfa465b
3 changed files with 18 additions and 16 deletions

View File

@ -28,3 +28,16 @@ export type GraphqlPerson = {
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',
});

View File

@ -4,9 +4,12 @@ import Table from '../../components/table/Table';
import styled from '@emotion/styled';
import { peopleColumns } from './people-table';
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 { mapPerson } from './mapper';
const StyledPeopleContainer = styled.div`
display: flex;

View File

@ -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',
});