Sammy/t 240 frontend filtering search is refactored (#122)

* refactor: use AnyEntity instead of any

* refactor: remove any and brand company type

* refactor: add typename for user and people

* bugfix: await company to be created before displaying it

* feature: await deletion before removing the lines

* refactor: remove default tyep for filters

* refactor: remove default type AnyEntity

* refactor: remove USers from filterable types

* refactor: do not depend on Filter types in Table

* Add tests

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Sammy Teillet
2023-05-17 21:49:34 +02:00
committed by GitHub
parent bc49815ff0
commit baca6150f5
25 changed files with 254 additions and 106 deletions

View File

@ -36,6 +36,7 @@ describe('Company mappers', () => {
const company = mapToCompany(graphQLCompany);
expect(company).toStrictEqual({
__typename: 'companies',
id: graphQLCompany.id,
name: graphQLCompany.name,
domainName: graphQLCompany.domain_name,
@ -43,6 +44,7 @@ describe('Company mappers', () => {
employees: graphQLCompany.employees,
address: graphQLCompany.address,
accountOwner: {
__typename: 'users',
id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
email: 'john@example.com',
displayName: 'John Doe',
@ -66,9 +68,11 @@ describe('Company mappers', () => {
id: '522d4ec4-c46b-4360-a0a7-df8df170be81',
email: 'john@example.com',
displayName: 'John Doe',
__typename: 'users',
},
creationDate: now,
};
__typename: 'companies',
} satisfies Company;
const graphQLCompany = mapToGqlCompany(company);
expect(graphQLCompany).toStrictEqual({
id: company.id,

View File

@ -28,6 +28,7 @@ describe('Person mappers', () => {
const person = mapToPerson(graphQLPerson);
expect(person).toStrictEqual({
__typename: 'people',
id: graphQLPerson.id,
firstname: graphQLPerson.firstname,
lastname: graphQLPerson.lastname,
@ -36,6 +37,7 @@ describe('Person mappers', () => {
city: graphQLPerson.city,
phone: graphQLPerson.phone,
company: {
__typename: 'companies',
id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
accountOwner: undefined,
address: undefined,

View File

@ -28,6 +28,7 @@ describe('User mappers', () => {
const User = mapToUser(graphQLUser);
expect(User).toStrictEqual({
__typename: 'users',
id: graphQLUser.id,
displayName: graphQLUser.display_name,
email: graphQLUser.email,
@ -47,6 +48,7 @@ describe('User mappers', () => {
const now = new Date();
now.setMilliseconds(0);
const user = {
__typename: 'users',
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
displayName: 'John Doe',
email: 'john.doe@gmail.com',

View File

@ -3,6 +3,7 @@ import { GraphqlQueryUser, User, mapToUser } from './user.interface';
import { GraphqlQueryPipe } from './pipe.interface';
export type Company = {
__typename: 'companies';
id: string;
name?: string;
domainName?: string;
@ -43,6 +44,7 @@ export type GraphqlMutationCompany = {
};
export const mapToCompany = (company: GraphqlQueryCompany): Company => ({
__typename: 'companies',
id: company.id,
employees: company.employees,
name: company.name,

View File

@ -6,6 +6,7 @@ import {
import { Pipe } from './pipe.interface';
export type Person = {
__typename: 'people';
id: string;
firstname?: string;
lastname?: string;
@ -44,10 +45,11 @@ export type GraphqlMutationPerson = {
city?: string;
created_at?: string;
company_id?: string;
__typename: string;
__typename: 'people';
};
export const mapToPerson = (person: GraphqlQueryPerson): Person => ({
__typename: 'people',
id: person.id,
firstname: person.firstname,
lastname: person.lastname,

View File

@ -5,6 +5,7 @@ import {
} from './workspace_member.interface';
export interface User {
__typename: 'users';
id: string;
email?: string;
displayName?: string;
@ -28,6 +29,7 @@ export type GraphqlMutationUser = {
};
export const mapToUser = (user: GraphqlQueryUser): User => ({
__typename: 'users',
id: user.id,
email: user.email,
displayName: user.display_name,