Files
twenty_crm/front/src/components/table/table-header/interface.ts
Sammy Teillet b8cd842633 Sammy/t 194 aau when i set sort back and forth the (#103)
* bugfix: use original row id in cells to make sure it rerenders

* feature: implement multiple sorts

* bugfix: recreate new array to make sure component rerenders

* feature: orderBy is an array to keep orders

* test: snapshot the searchTemplate methods

* feature: remove the console log and return undefined

* feature: use orderByTemplate instead of hardcoded orderBy

* refactor: move sort and where filters helpers out of service

* refactor: rename file helper

* refactor: move assert function in test
2023-05-05 16:22:47 +02:00

59 lines
1.4 KiB
TypeScript

import { DocumentNode } from 'graphql';
import { ReactNode } from 'react';
import {
Companies_Bool_Exp,
Order_By,
People_Bool_Exp,
Users_Bool_Exp,
} from '../../../generated/graphql';
export type SortType<OrderByTemplate> =
| {
_type: 'default_sort';
label: string;
key: keyof OrderByTemplate & string;
icon?: ReactNode;
}
| {
_type: 'custom_sort';
label: string;
key: string;
icon?: ReactNode;
orderByTemplate: (order: Order_By) => OrderByTemplate;
};
export type SelectedSortType<OrderByTemplate> = SortType<OrderByTemplate> & {
order: 'asc' | 'desc';
};
export type FilterType<WhereTemplate, FilterValue = Record<string, any>> = {
operands: FilterOperandType[];
label: string;
key: string;
icon: ReactNode;
whereTemplate: (
operand: FilterOperandType,
value: FilterValue,
) => WhereTemplate | undefined;
searchQuery: DocumentNode;
searchTemplate: (
searchInput: string,
) => People_Bool_Exp | Companies_Bool_Exp | Users_Bool_Exp;
searchResultMapper: (data: any) => {
displayValue: string;
value: FilterValue;
};
};
export type FilterOperandType = {
label: string;
id: string;
keyWord: 'ilike' | 'not_ilike' | 'equal' | 'not_equal';
};
export type SelectedFilterType<WhereTemplate> = FilterType<WhereTemplate> & {
value: string;
operand: FilterOperandType;
where: WhereTemplate;
};