Skip to content

The open alternative to Salesforce, designed for AI.

Refactor GraphqlPerson to GraphqlQueryPerson

Anders Borch8ed09d61efc4
diff --git a/front/src/interfaces/person.interface.test.ts b/front/src/interfaces/person.interface.test.ts
index e5c01f812a1..75aa9f4f5cd 100644
--- a/front/src/interfaces/person.interface.test.ts
+++ b/front/src/interfaces/person.interface.test.ts
@@ -12,6 +12,7 @@ describe('mapPerson', () => {
created_at: '',
company: {
__typename: '',
+ id: 1,
company_name: '',
company_domain: '',
},
diff --git a/front/src/interfaces/person.interface.ts b/front/src/interfaces/person.interface.ts
index c9c8b56c48d..f88f9bea48b 100644
--- a/front/src/interfaces/person.interface.ts
+++ b/front/src/interfaces/person.interface.ts
@@ -14,10 +14,11 @@ export type Person = {
countryCode: string;
};
-export type GraphqlPerson = {
+export type GraphqlQueryPerson = {
city: string;
company: {
__typename: string;
+ id: number;
company_name: string;
company_domain: string;
};
@@ -48,7 +49,7 @@ export const mapPerson = (person: GraphqlQueryPerson): Person => ({
pipe: { name: 'coucou', id: 1, icon: '💰' },
...person,
company: {
- id: 1,
+ id: person.company.id,
name: person.company.company_name,
domain: person.company.company_domain,
},
diff --git a/front/src/pages/people/default-data.ts b/front/src/pages/people/default-data.ts
index b0efc97a55a..16b30571a6d 100644
--- a/front/src/pages/people/default-data.ts
+++ b/front/src/pages/people/default-data.ts
@@ -1,6 +1,6 @@
-import { GraphqlPerson } from '../../interfaces/person.interface';
+import { GraphqlQueryPerson } from '../../interfaces/person.interface';
-export const defaultData: Array<GraphqlPerson> = [
+export const defaultData: Array<GraphqlQueryPerson> = [
{
id: 1,
__typename: 'Person',
@@ -8,6 +8,7 @@ export const defaultData: Array<GraphqlPerson> = [
lastname: 'Prot',
company: {
+ id: 1,
company_name: 'Qonto',
company_domain: 'qonto.com',
__typename: 'Company',
@@ -24,6 +25,7 @@ export const defaultData: Array<GraphqlPerson> = [
lastname: 'Prot',
company: {
+ id: 1,
company_name: 'LinkedIn',
company_domain: 'linkedin.com',
__typename: 'Company',
@@ -40,6 +42,7 @@ export const defaultData: Array<GraphqlPerson> = [
lastname: 'Prot',
company: {
+ id: 1,
company_name: 'Sequoia',
company_domain: 'sequoiacap.com',
__typename: 'Company',
@@ -57,6 +60,7 @@ export const defaultData: Array<GraphqlPerson> = [
lastname: 'Prot',
company: {
+ id: 1,
company_name: 'Facebook',
company_domain: 'facebook.com',
__typename: 'Company',
diff --git a/front/src/pages/people/people-table.tsx b/front/src/pages/people/people-table.tsx
index f7fd24ad464..81b00743ee8 100644
--- a/front/src/pages/people/people-table.tsx
+++ b/front/src/pages/people/people-table.tsx
@@ -15,9 +15,11 @@ import Checkbox from '../../components/form/Checkbox';
import HorizontalyAlignedContainer from '../../layout/containers/HorizontalyAlignedContainer';
import CompanyChip from '../../components/chips/CompanyChip';
import PersonChip from '../../components/chips/PersonChip';
-import { GraphqlPerson, Person } from '../../interfaces/person.interface';
+import { GraphqlQueryPerson, Person } from '../../interfaces/person.interface';
import PipeChip from '../../components/chips/PipeChip';
import { SortType } from '../../components/table/table-header/SortAndFilterBar';
+import EditableCell from '../../components/table/EditableCell';
+import { updatePerson } from '../../services/people';
export const sortsAvailable = [
{
@@ -34,9 +36,7 @@ export const sortsAvailable = [
icon: faCalendar,
},
{ id: 'city', label: 'City', order: 'asc', icon: faMapPin },
-] satisfies Array<SortType<keyof GraphqlPerson>>;
-import EditableCell from '../../components/table/EditableCell';
-import { updatePerson } from '../../services/people';
+] satisfies Array<SortType<keyof GraphqlQueryPerson>>;
const columnHelper = createColumnHelper<Person>();
export const peopleColumns = [
diff --git a/front/src/services/people/select.ts b/front/src/services/people/select.ts
index 9cc91a5f506..6cffc3fdd86 100644
--- a/front/src/services/people/select.ts
+++ b/front/src/services/people/select.ts
@@ -1,5 +1,5 @@
import { QueryResult, gql, useQuery } from '@apollo/client';
-import { GraphqlPerson } from '../../interfaces/person.interface';
+import { GraphqlQueryPerson } from '../../interfaces/person.interface';
export type OrderBy = Record<string, 'asc' | 'desc'>;
@@ -14,6 +14,7 @@ export const GET_PEOPLE = gql`
lastname
created_at
company {
+ id
company_name
company_domain
}
@@ -23,8 +24,8 @@ export const GET_PEOPLE = gql`
export function usePeopleQuery(
orderBy: OrderBy[],
-): QueryResult<{ people: GraphqlPerson[] }> {
- return useQuery<{ people: GraphqlPerson[] }>(GET_PEOPLE, {
+): QueryResult<{ people: GraphqlQueryPerson[] }> {
+ return useQuery<{ people: GraphqlQueryPerson[] }>(GET_PEOPLE, {
variables: { orderBy },
});
}