The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
refactor: strongly type keys of sorts
Sammy Teilletbe947bdc8f10
diff --git a/front/src/components/table/table-header/SortAndFilterBar.tsx b/front/src/components/table/table-header/SortAndFilterBar.tsxindex df2e09ab41b..1e028fc3d99 100644--- a/front/src/components/table/table-header/SortAndFilterBar.tsx+++ b/front/src/components/table/table-header/SortAndFilterBar.tsx@@ -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;};diff --git a/front/src/pages/people/People.tsx b/front/src/pages/people/People.tsxindex 72c701ff11c..0678495eea9 100644--- a/front/src/pages/people/People.tsx+++ b/front/src/pages/people/People.tsx@@ -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',