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
This commit is contained in:
Sammy Teillet
2023-05-05 16:22:47 +02:00
committed by GitHub
parent f022bf8335
commit b8cd842633
21 changed files with 253 additions and 156 deletions

View File

@ -5,12 +5,12 @@ import { useState, useCallback } from 'react';
import {
CompaniesSelectedSortType,
defaultOrderBy,
reduceSortsToOrderBy,
useCompaniesQuery,
} from '../../services/companies';
import Table from '../../components/table/Table';
import { mapCompany } from '../../interfaces/company.interface';
import { companiesColumns, sortsAvailable } from './companies-table';
import { reduceSortsToOrderBy } from '../../components/table/table-header/helpers';
const StyledCompaniesContainer = styled.div`
display: flex;

View File

@ -1,6 +1,6 @@
import { createColumnHelper } from '@tanstack/react-table';
import { Company } from '../../interfaces/company.interface';
import { OrderByFields, updateCompany } from '../../services/companies';
import { updateCompany } from '../../services/companies';
import ColumnHead from '../../components/table/ColumnHead';
import Checkbox from '../../components/form/Checkbox';
import CompanyChip from '../../components/chips/CompanyChip';
@ -17,21 +17,24 @@ import {
} from 'react-icons/fa';
import ClickableCell from '../../components/table/ClickableCell';
import PersonChip from '../../components/chips/PersonChip';
import { SortType } from '../../components/table/table-header/interface';
import EditableChip from '../../components/table/editable-cell/EditableChip';
import { SortType } from '../../components/table/table-header/interface';
import { Companies_Order_By } from '../../generated/graphql';
export const sortsAvailable = [
{
key: 'name',
label: 'Name',
icon: undefined,
_type: 'default_sort',
},
{
key: 'domain_name',
label: 'Domain',
icon: undefined,
_type: 'default_sort',
},
] satisfies Array<SortType<OrderByFields>>;
] satisfies Array<SortType<Companies_Order_By>>;
const columnHelper = createColumnHelper<Company>();
export const companiesColumns = [