Files
twenty/packages/twenty-front/src/testing/mock-data/tableData.ts
T
59e14fabb4 [Issue-5772] Add sort feature on settings tables (#5787)
## Proposed Changes
-  Introduce  a new custom hook - useTableSort to sort table content
-  Add test cases for the new custom hook
- Integrate useTableSort hook on to the table in settings object and
settings object field pages

## Related Issue

https://github.com/twentyhq/twenty/issues/5772

## Evidence


https://github.com/twentyhq/twenty/assets/87609792/8be456ce-2fa5-44ec-8bbd-70fb6c8fdb30

## Evidence after addressing review comments


https://github.com/twentyhq/twenty/assets/87609792/c267e3da-72f9-4c0e-8c94-a38122d6395e

## Further comments

Apologies for the large PR. Looking forward for the review

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-14 17:11:17 +02:00

72 lines
1.8 KiB
TypeScript

import { TableMetadata } from '@/ui/layout/table/types/TableMetadata';
export type MockedTableType = {
labelPlural: string;
fieldsCount: number;
};
export const mockedTableMetadata: TableMetadata<MockedTableType> = {
tableId: 'SettingsObjectDetail',
fields: [
{
fieldName: 'labelPlural',
fieldType: 'string',
align: 'left',
fieldLabel: 'Name',
},
{
fieldName: 'fieldsCount',
fieldType: 'number',
align: 'right',
fieldLabel: 'Fields Count',
},
],
};
export const mockedTableData = [
{
labelPlural: 'Opportunities',
fieldsCount: 11,
},
{
labelPlural: 'Contact',
fieldsCount: 3,
},
{
labelPlural: 'Leads',
fieldsCount: 4,
},
{
labelPlural: 'Tasks',
fieldsCount: 5,
},
];
export const tableDataSortedBylabelInAscendingOrder = [
{ labelPlural: 'Contact', fieldsCount: 3 },
{ labelPlural: 'Leads', fieldsCount: 4 },
{ labelPlural: 'Opportunities', fieldsCount: 11 },
{ labelPlural: 'Tasks', fieldsCount: 5 },
];
export const tableDataSortedBylabelInDescendingOrder = [
{ labelPlural: 'Tasks', fieldsCount: 5 },
{ labelPlural: 'Opportunities', fieldsCount: 11 },
{ labelPlural: 'Leads', fieldsCount: 4 },
{ labelPlural: 'Contact', fieldsCount: 3 },
];
export const tableDataSortedByFieldsCountInAscendingOrder = [
{ labelPlural: 'Contact', fieldsCount: 3 },
{ labelPlural: 'Leads', fieldsCount: 4 },
{ labelPlural: 'Tasks', fieldsCount: 5 },
{ labelPlural: 'Opportunities', fieldsCount: 11 },
];
export const tableDataSortedByFieldsCountInDescendingOrder = [
{ labelPlural: 'Opportunities', fieldsCount: 11 },
{ labelPlural: 'Tasks', fieldsCount: 5 },
{ labelPlural: 'Leads', fieldsCount: 4 },
{ labelPlural: 'Contact', fieldsCount: 3 },
];