mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-24 20:42:05 +03:00
feature: wip get persons and map it
This commit is contained in:
parent
7f2ec0c260
commit
887a7af5e2
@ -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 (
|
||||
<WithTopBarContainer title="People" icon={faUser}>
|
||||
<StyledPeopleContainer>
|
||||
{mydata && (
|
||||
<Table
|
||||
data={defaultData}
|
||||
data={mydata}
|
||||
columns={peopleColumns}
|
||||
viewName="All People"
|
||||
viewIcon={faList}
|
||||
/>
|
||||
)}
|
||||
</StyledPeopleContainer>
|
||||
</WithTopBarContainer>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user