Sammy/t 131 i see a ascending descending option in (#73)

* refactor: use safe css selector

* feature: onclick update the order option

* feature: set option in the dropdown

* feature: display icon for sort options

* refactor: indent key so react does not complain of conflicting keys

* feature: align icon and text

* feature: fix size of icon to align text

* feature: create design for TopOption in dropdown

* refactor: set font weight in style

* feature: finalise design of TopOption

* refactor: rename option to sort

* refactor: remove order from the sortType

* refactor: move sort mapper in service

* test: selection of Descending in SortDropdownButton

* refactor: fix styme-component warning

* feature: add sorting by people

* refactor: set SortFields types for tables

* feature: add sort by company

* refactor: rename sortFields to singular

* refactor: rename option to SortDirection
This commit is contained in:
Sammy Teillet
2023-04-25 16:29:08 +02:00
committed by GitHub
parent 463b5f4ec9
commit a93c92c65c
14 changed files with 270 additions and 69 deletions

View File

@ -9,15 +9,15 @@ import {
import TableHeader from './table-header/TableHeader';
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import styled from '@emotion/styled';
import { SortType } from './table-header/SortAndFilterBar';
import { SelectedSortType, SortType } from './table-header/SortAndFilterBar';
type OwnProps<TData> = {
type OwnProps<TData, SortField> = {
data: Array<TData>;
columns: Array<ColumnDef<TData, any>>;
viewName: string;
viewIcon?: IconProp;
onSortsUpdate?: (sorts: Array<SortType>) => void;
sortsAvailable?: Array<SortType>;
onSortsUpdate?: (sorts: Array<SelectedSortType<SortField>>) => void;
sortsAvailable?: Array<SortType<SortField>>;
};
const StyledTable = styled.table`
@ -71,14 +71,14 @@ const StyledTableScrollableContainer = styled.div`
flex: 1;
`;
function Table<TData>({
function Table<TData, SortField extends string>({
data,
columns,
viewName,
viewIcon,
onSortsUpdate,
sortsAvailable,
}: OwnProps<TData>) {
}: OwnProps<TData, SortField>) {
const table = useReactTable({
data,
columns,