refactor: etract type in file

This commit is contained in:
Sammy Teillet
2023-04-20 13:52:26 +02:00
parent c1883d381e
commit d5ebff5b53
2 changed files with 18 additions and 18 deletions

View File

@ -4,7 +4,7 @@ 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 { GraphqlPerson, Person } from './types';
import { defaultData } from './defaultData';
const StyledPeopleContainer = styled.div`
@ -30,24 +30,8 @@ const GET_PEOPLE = gql`
}
`;
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 { data } = useQuery<{ person: GraphqlPerson[] }>(GET_PEOPLE);
const mydata: Person[] = data
? data.person.map((person) => ({

View File

@ -12,3 +12,19 @@ export type Person = {
city: string;
countryCode: string;
};
export type GraphqlPerson = {
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;
};