refactor: move sorts in peolpe-table

This commit is contained in:
Sammy Teillet 2023-04-24 14:59:53 +02:00
parent 99aa39f2ba
commit 19903219c3
No known key found for this signature in database
GPG Key ID: 687E513E74D28696
2 changed files with 20 additions and 24 deletions

View File

@ -1,14 +1,9 @@
import { import { faUser, faList } from '@fortawesome/pro-regular-svg-icons';
faUser,
faList,
faCalendar,
faEnvelope,
} from '@fortawesome/pro-regular-svg-icons';
import WithTopBarContainer from '../../layout/containers/WithTopBarContainer'; import WithTopBarContainer from '../../layout/containers/WithTopBarContainer';
import Table from '../../components/table/Table'; import Table from '../../components/table/Table';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { peopleColumns } from './people-table'; import { peopleColumns, sortsAvailable } from './people-table';
import { GraphqlPerson, mapPerson } from '../../interfaces/person.interface'; import { mapPerson } from '../../interfaces/person.interface';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import { SortType } from '../../components/table/table-header/SortAndFilterBar'; import { SortType } from '../../components/table/table-header/SortAndFilterBar';
import { OrderBy, usePeopleQuery } from '../../services/people'; import { OrderBy, usePeopleQuery } from '../../services/people';
@ -32,21 +27,6 @@ const reduceSortsToOrderBy = (sorts: Array<SortType>): OrderBy[] => {
return [mappedSorts]; return [mappedSorts];
}; };
const sortsAvailable = [
{
id: 'created_at',
label: 'Created at',
order: 'asc',
icon: faCalendar,
},
{
id: 'email',
label: 'Email',
order: 'asc',
icon: faEnvelope,
},
] satisfies Array<SortType<keyof GraphqlPerson>>;
function People() { function People() {
const [, setSorts] = useState([] as Array<SortType>); const [, setSorts] = useState([] as Array<SortType>);
const [orderBy, setOrderBy] = useState(defaultOrderBy); const [orderBy, setOrderBy] = useState(defaultOrderBy);

View File

@ -15,8 +15,24 @@ import Checkbox from '../../components/form/Checkbox';
import HorizontalyAlignedContainer from '../../layout/containers/HorizontalyAlignedContainer'; import HorizontalyAlignedContainer from '../../layout/containers/HorizontalyAlignedContainer';
import CompanyChip from '../../components/chips/CompanyChip'; import CompanyChip from '../../components/chips/CompanyChip';
import PersonChip from '../../components/chips/PersonChip'; import PersonChip from '../../components/chips/PersonChip';
import { Person } from '../../interfaces/person.interface'; import { GraphqlPerson, Person } from '../../interfaces/person.interface';
import PipeChip from '../../components/chips/PipeChip'; import PipeChip from '../../components/chips/PipeChip';
import { SortType } from '../../components/table/table-header/SortAndFilterBar';
export const sortsAvailable = [
{
id: 'created_at',
label: 'Created at',
order: 'asc',
icon: faCalendar,
},
{
id: 'email',
label: 'Email',
order: 'asc',
icon: faEnvelope,
},
] satisfies Array<SortType<keyof GraphqlPerson>>;
const columnHelper = createColumnHelper<Person>(); const columnHelper = createColumnHelper<Person>();
export const peopleColumns = [ export const peopleColumns = [