refactor: strongly type keys of sorts

This commit is contained in:
Sammy Teillet
2023-04-24 14:02:38 +02:00
parent 095a6886ae
commit be947bdc8f
2 changed files with 4 additions and 4 deletions

View File

@ -8,10 +8,10 @@ type OwnProps = {
onRemoveSort: (sortId: string) => void;
};
export type SortType = {
export type SortType<SortIds = string> = {
label: string;
order: 'asc' | 'desc';
id: string;
id: SortIds;
icon?: IconProp;
};

View File

@ -3,7 +3,7 @@ import WithTopBarContainer from '../../layout/containers/WithTopBarContainer';
import Table from '../../components/table/Table';
import styled from '@emotion/styled';
import { peopleColumns } from './people-table';
import { mapPerson } from '../../interfaces/person.interface';
import { GraphqlPerson, mapPerson } from '../../interfaces/person.interface';
import { useState } from 'react';
import { SortType } from '../../components/table/table-header/SortAndFilterBar';
import { OrderBy, usePeopleQuery } from '../../services/people';
@ -38,7 +38,7 @@ function People() {
const { data } = usePeopleQuery(orderBy);
const sortsAvailable: Array<SortType> = [
const sortsAvailable: Array<SortType<keyof GraphqlPerson>> = [
{
id: 'created_at',
label: 'Created at',