From 887a7af5e241f11e8a61402669ecace7e4dd4e34 Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Thu, 20 Apr 2023 13:34:55 +0200 Subject: [PATCH] feature: wip get persons and map it --- front/src/pages/people/People.tsx | 67 ++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/front/src/pages/people/People.tsx b/front/src/pages/people/People.tsx index 982f5f5e44..2ed82b8f94 100644 --- a/front/src/pages/people/People.tsx +++ b/front/src/pages/people/People.tsx @@ -3,6 +3,8 @@ import WithTopBarContainer from '../../layout/containers/WithTopBarContainer'; import Table from '../../components/table/Table'; import styled from '@emotion/styled'; import { peopleColumns } from './people-table'; +import { gql, useQuery } from '@apollo/client'; +import { Person } from './types'; import { defaultData } from './defaultData'; const StyledPeopleContainer = styled.div` @@ -10,16 +12,69 @@ const StyledPeopleContainer = styled.div` width: 100%; `; +const GET_PEOPLE = gql` + query GetPeople { + person { + id + phone + email + city + firstname + lastname + created_at + company { + company_name + company_domain + } + } + } +`; + +type QueryResult = { + 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; +}; + function People() { + const { data } = useQuery<{ person: QueryResult[] }>(GET_PEOPLE); + + const mydata: Person[] = data + ? data.person.map((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', + })) + : defaultData; + return ( - + {mydata && ( +
+ )} );