refactor: strongly type keys of sorts
This commit is contained in:
@ -8,10 +8,10 @@ type OwnProps = {
|
|||||||
onRemoveSort: (sortId: string) => void;
|
onRemoveSort: (sortId: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SortType = {
|
export type SortType<SortIds = string> = {
|
||||||
label: string;
|
label: string;
|
||||||
order: 'asc' | 'desc';
|
order: 'asc' | 'desc';
|
||||||
id: string;
|
id: SortIds;
|
||||||
icon?: IconProp;
|
icon?: IconProp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ 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 } from './people-table';
|
||||||
import { mapPerson } from '../../interfaces/person.interface';
|
import { GraphqlPerson, mapPerson } from '../../interfaces/person.interface';
|
||||||
import { useState } from 'react';
|
import { 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';
|
||||||
@ -38,7 +38,7 @@ function People() {
|
|||||||
|
|
||||||
const { data } = usePeopleQuery(orderBy);
|
const { data } = usePeopleQuery(orderBy);
|
||||||
|
|
||||||
const sortsAvailable: Array<SortType> = [
|
const sortsAvailable: Array<SortType<keyof GraphqlPerson>> = [
|
||||||
{
|
{
|
||||||
id: 'created_at',
|
id: 'created_at',
|
||||||
label: 'Created at',
|
label: 'Created at',
|
||||||
|
|||||||
Reference in New Issue
Block a user