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 {
faUser,
faList,
faCalendar,
faEnvelope,
} from '@fortawesome/pro-regular-svg-icons';
import { faUser, faList } from '@fortawesome/pro-regular-svg-icons';
import WithTopBarContainer from '../../layout/containers/WithTopBarContainer';
import Table from '../../components/table/Table';
import styled from '@emotion/styled';
import { peopleColumns } from './people-table';
import { GraphqlPerson, mapPerson } from '../../interfaces/person.interface';
import { peopleColumns, sortsAvailable } from './people-table';
import { mapPerson } from '../../interfaces/person.interface';
import { useCallback, useState } from 'react';
import { SortType } from '../../components/table/table-header/SortAndFilterBar';
import { OrderBy, usePeopleQuery } from '../../services/people';
@ -32,21 +27,6 @@ const reduceSortsToOrderBy = (sorts: Array<SortType>): OrderBy[] => {
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() {
const [, setSorts] = useState([] as Array<SortType>);
const [orderBy, setOrderBy] = useState(defaultOrderBy);

View File

@ -15,8 +15,24 @@ import Checkbox from '../../components/form/Checkbox';
import HorizontalyAlignedContainer from '../../layout/containers/HorizontalyAlignedContainer';
import CompanyChip from '../../components/chips/CompanyChip';
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 { 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>();
export const peopleColumns = [