diff --git a/apps/judicial-system/web/src/components/Table/AppealCasesTable/AppealCasesTable.tsx b/apps/judicial-system/web/src/components/Table/AppealCasesTable/AppealCasesTable.tsx index 61ce59fff810..6fb79f9e981d 100644 --- a/apps/judicial-system/web/src/components/Table/AppealCasesTable/AppealCasesTable.tsx +++ b/apps/judicial-system/web/src/components/Table/AppealCasesTable/AppealCasesTable.tsx @@ -77,7 +77,7 @@ const AppealCasesTable: React.FC = (props) => { }, { title: capitalize(formatMessage(core.defendant, { suffix: 'i' })), - sortable: { isSortable: true, key: 'defendant' }, + sortable: { isSortable: true, key: 'defendants' }, }, { title: formatMessage(tables.type), diff --git a/apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx b/apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx index c790a0965991..d37095f23706 100644 --- a/apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx +++ b/apps/judicial-system/web/src/components/Table/PastCasesTable/PastCasesTable.tsx @@ -53,7 +53,7 @@ const PastCasesTable: React.FC> = (props) => { const { isOpeningCaseId, handleOpenCase, LoadingIndicator, showLoading } = useCaseList() const { sortedData, requestSort, getClassNamesFor, isActiveColumn } = - useSortCases('createdAt', 'descending', cases) + useSortCases('created', 'descending', cases) const { withdrawAppealMenuOption, @@ -108,10 +108,10 @@ const PastCasesTable: React.FC> = (props) => { title={capitalize( formatMessage(core.defendant, { suffix: 'i' }), )} - onClick={() => requestSort('defendant')} - sortAsc={getClassNamesFor('defendant') === 'ascending'} - sortDes={getClassNamesFor('defendant') === 'descending'} - isActive={isActiveColumn('defendant')} + onClick={() => requestSort('defendants')} + sortAsc={getClassNamesFor('defendants') === 'ascending'} + sortDes={getClassNamesFor('defendants') === 'descending'} + isActive={isActiveColumn('defendants')} /> @@ -120,10 +120,10 @@ const PastCasesTable: React.FC> = (props) => { title={capitalize( formatMessage(tables.created, { suffix: 'i' }), )} - onClick={() => requestSort('createdAt')} - sortAsc={getClassNamesFor('createdAt') === 'ascending'} - sortDes={getClassNamesFor('createdAt') === 'descending'} - isActive={isActiveColumn('createdAt')} + onClick={() => requestSort('created')} + sortAsc={getClassNamesFor('created') === 'ascending'} + sortDes={getClassNamesFor('created') === 'descending'} + isActive={isActiveColumn('created')} /> diff --git a/apps/judicial-system/web/src/components/Table/SortButton/SortButton.tsx b/apps/judicial-system/web/src/components/Table/SortButton/SortButton.tsx index a2d7e36c6799..e7ea61d4b754 100644 --- a/apps/judicial-system/web/src/components/Table/SortButton/SortButton.tsx +++ b/apps/judicial-system/web/src/components/Table/SortButton/SortButton.tsx @@ -39,6 +39,7 @@ const SortButton: React.FC = (props) => { > +

Sort button

) } diff --git a/apps/judicial-system/web/src/components/Table/Table.spec.tsx b/apps/judicial-system/web/src/components/Table/Table.spec.tsx new file mode 100644 index 000000000000..daa89b04555d --- /dev/null +++ b/apps/judicial-system/web/src/components/Table/Table.spec.tsx @@ -0,0 +1,91 @@ +import faker from 'faker' +import { act, render, screen } from '@testing-library/react' +import userEvent from '@testing-library/user-event' + +import { CaseListEntry } from '@island.is/judicial-system-web/src/graphql/schema' +import { + ApolloProviderWrapper, + IntlProviderWrapper, +} from '@island.is/judicial-system-web/src/utils/testHelpers' + +import { sortableTableColumn } from '../../types' +import Table from './Table' + +import '@testing-library/react' + +jest.mock('next/router', () => ({ + useRouter() { + return { + pathname: '', + query: { + id: 'test_id', + }, + } + }, +})) + +describe('Table', () => { + it('should sort by deadline', async () => { + const user = userEvent.setup() + + const thead = [ + { + title: 'Title', + sortable: { + isSortable: true, + key: 'indictmentAppealDeadline' as sortableTableColumn, + }, + }, + ] + + const data: CaseListEntry[] = [ + { + created: '2021-01-01T00:00:00Z', + id: faker.datatype.uuid(), + indictmentAppealDeadline: '2021-01-01T00:00:00Z', + }, + { + created: '2021-01-02T00:00:00Z', + id: faker.datatype.uuid(), + indictmentAppealDeadline: '2021-01-02T00:00:00Z', + }, + ] + + const columns = [ + { + cell: (row: CaseListEntry) =>

{row.indictmentAppealDeadline}

, + }, + ] + + render( + + + + + , + ) + + await act(async () => { + await user.click( + await screen.findByTestId('indictmentAppealDeadlineSortButton'), + ) + }) + + const tableRows = await screen.findAllByTestId('tableRow') + + // The first click sorts by ascending order, so the first row should be the one with the earliest date + expect(tableRows[0]).toHaveTextContent('2021-01-01T00:00:00Z') + expect(tableRows[1]).toHaveTextContent('2021-01-02T00:00:00Z') + + await act(async () => { + await user.click( + await screen.findByTestId('indictmentAppealDeadlineSortButton'), + ) + }) + + // The second click sorts by descending order, so the first row should be the one with the latest date + const tableRows2 = await screen.findAllByTestId('tableRow') + expect(tableRows2[0]).toHaveTextContent('2021-01-02T00:00:00Z') + expect(tableRows2[1]).toHaveTextContent('2021-01-01T00:00:00Z') + }) +}) diff --git a/apps/judicial-system/web/src/components/Table/Table.tsx b/apps/judicial-system/web/src/components/Table/Table.tsx index d14dec363cc1..51abbc83881f 100644 --- a/apps/judicial-system/web/src/components/Table/Table.tsx +++ b/apps/judicial-system/web/src/components/Table/Table.tsx @@ -1,4 +1,10 @@ -import React, { PropsWithChildren, ReactNode, useContext, useMemo } from 'react' +import React, { + FC, + PropsWithChildren, + ReactNode, + useContext, + useMemo, +} from 'react' import { useIntl } from 'react-intl' import { useLocalStorage } from 'react-use' import parseISO from 'date-fns/parseISO' @@ -23,13 +29,15 @@ import TableSkeleton from './TableSkeleton/TableSkeleton' import { table as strings } from './Table.strings' import * as styles from './Table.css' +interface Sortable { + isSortable: boolean + key: sortableTableColumn +} + interface TableProps { thead: { title: string - sortable?: { - isSortable: boolean - key: sortableTableColumn - } + sortable?: Sortable }[] data: CaseListEntry[] columns: { cell: (row: CaseListEntry) => ReactNode }[] @@ -41,7 +49,7 @@ interface TableWrapperProps { loading: boolean } -export const TableWrapper: React.FC> = ({ +export const TableWrapper: FC> = ({ loading, children, }) => ( @@ -80,7 +88,7 @@ export const useTable = () => { return { requestSort, getClassNamesFor, sortConfig, setSortConfig } } -const Table: React.FC = (props) => { +const Table: FC = (props) => { const { thead, data, columns, generateContextMenuItems, onClick } = props const { isOpeningCaseId, handleOpenCase, LoadingIndicator, showLoading } = useCaseList() @@ -95,17 +103,17 @@ const Table: React.FC = (props) => { data.sort((a: CaseListEntry, b: CaseListEntry) => { const getColumnValue = (entry: CaseListEntry) => { if ( - sortConfig.column === 'defendant' && + sortConfig.column === 'defendants' && entry.defendants && - entry.defendants.length > 0 + entry.defendants.length > 0 && + entry.defendants[0].name ) { - return entry.defendants[0].name ?? '' + return entry.defendants[0].name } - if (sortConfig.column === 'courtDate') { - return entry.courtDate ?? '' - } - return entry.created + + return entry[sortConfig.column]?.toString() } + const compareResult = compareLocaleIS( getColumnValue(a), getColumnValue(b), @@ -169,7 +177,7 @@ const Table: React.FC = (props) => { sortAsc={getClassNamesFor(th.sortable.key) === 'ascending'} sortDes={getClassNamesFor(th.sortable.key) === 'descending'} isActive={sortConfig?.column === th.sortable.key} - dataTestid="accusedNameSortButton" + dataTestid={`${th.sortable.key}SortButton`} /> ) : ( @@ -194,6 +202,7 @@ const Table: React.FC = (props) => { handleOpenCase(row.id) } }} + data-testid="tableRow" > {columns.map((td) => ( @@ -196,10 +196,10 @@ const ActiveCases: React.FC> = (props) => { title={capitalize( formatMessage(tables.created, { suffix: 'i' }), )} - onClick={() => requestSort('createdAt')} - sortAsc={getClassNamesFor('createdAt') === 'ascending'} - sortDes={getClassNamesFor('createdAt') === 'descending'} - isActive={sortConfig?.column === 'createdAt'} + onClick={() => requestSort('created')} + sortAsc={getClassNamesFor('created') === 'ascending'} + sortDes={getClassNamesFor('created') === 'descending'} + isActive={sortConfig?.column === 'created'} dataTestid="createdAtSortButton" /> diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx b/apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx index e63b29e59189..13e0dfa6665f 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx +++ b/apps/judicial-system/web/src/routes/Shared/Cases/PrisonCases.tsx @@ -70,14 +70,14 @@ export const PrisonCases: React.FC = () => { }, { title: capitalize(formatMessage(core.defendant, { suffix: 'i' })), - sortable: { isSortable: true, key: 'defendant' }, + sortable: { isSortable: true, key: 'defendants' }, }, { title: formatMessage(tables.type), }, { title: capitalize(formatMessage(tables.created)), - sortable: { isSortable: true, key: 'createdAt' }, + sortable: { isSortable: true, key: 'created' }, }, { title: formatMessage(tables.state) }, { diff --git a/apps/judicial-system/web/src/types/index.ts b/apps/judicial-system/web/src/types/index.ts index 214127f7c17a..cd8eb2ca0210 100644 --- a/apps/judicial-system/web/src/types/index.ts +++ b/apps/judicial-system/web/src/types/index.ts @@ -1,6 +1,7 @@ import { CourtDocument, SubstanceMap } from '@island.is/judicial-system/types' import { Case, + CaseListEntry, IndictmentCount, } from '@island.is/judicial-system-web/src/graphql/schema' @@ -18,11 +19,7 @@ export enum LoginErrorCodes { } export type directionType = 'ascending' | 'descending' -export type sortableTableColumn = - | 'defendant' - | 'createdAt' - | 'courtDate' - | 'appealedDate' +export type sortableTableColumn = keyof CaseListEntry export interface SortConfig { column: sortableTableColumn diff --git a/apps/judicial-system/web/src/utils/hooks/useSort/useSortCases.ts b/apps/judicial-system/web/src/utils/hooks/useSort/useSortCases.ts index b6912209a5c9..9fa8023ba261 100644 --- a/apps/judicial-system/web/src/utils/hooks/useSort/useSortCases.ts +++ b/apps/judicial-system/web/src/utils/hooks/useSort/useSortCases.ts @@ -5,7 +5,7 @@ import { sortableTableColumn } from '@island.is/judicial-system-web/src/types' import { compareLocaleIS } from '@island.is/judicial-system-web/src/utils/sortHelper' const useSortCases = ( - defaultColumn: string, + defaultColumn: sortableTableColumn, defaultDirection: 'ascending' | 'descending', data: CaseListEntry[], ) => { @@ -14,7 +14,7 @@ const useSortCases = ( direction: defaultDirection, }) - const requestSort = (column: string) => { + const requestSort = (column: sortableTableColumn) => { let direction: 'ascending' | 'descending' = 'ascending' if (sortConfig.column === column && sortConfig.direction === 'ascending') { @@ -24,7 +24,7 @@ const useSortCases = ( setSortConfig({ column, direction }) } - const getClassNamesFor = (column: string) => { + const getClassNamesFor = (column: sortableTableColumn) => { if (!sortConfig) { return } @@ -43,7 +43,7 @@ const useSortCases = ( return [...data].sort((a, b) => { const getColumnValue = (entry: CaseListEntry) => { if ( - sortConfig.column === 'defendant' && + sortConfig.column === 'defendants' && entry.defendants && entry.defendants.length > 0 ) { diff --git a/apps/judicial-system/web/src/utils/testHelpers.tsx b/apps/judicial-system/web/src/utils/testHelpers.tsx index c85e14f81cec..a8bfa94c562c 100644 --- a/apps/judicial-system/web/src/utils/testHelpers.tsx +++ b/apps/judicial-system/web/src/utils/testHelpers.tsx @@ -1,13 +1,17 @@ -import React, { ReactNode } from 'react' +import React, { FC, PropsWithChildren, ReactNode } from 'react' import { createIntl, IntlProvider } from 'react-intl' +import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client' import { FormContext, UserContext } from '../components' -import { UserRole } from '../graphql/schema' -import { TempCase } from '../types' +import { Case, UserRole } from '../graphql/schema' import { mockUser } from './mocks' -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const IntlProviderWrapper = ({ children }: any) => { +export const formatMessage = createIntl({ + locale: 'is', + onError: jest.fn, +}).formatMessage + +export const IntlProviderWrapper: FC = ({ children }) => { return ( { ) } -export const formatMessage = createIntl({ - locale: 'is', - onError: jest.fn, -}).formatMessage +export const ApolloProviderWrapper: FC = ({ children }) => { + return ( + + {children} + + ) +} -export const FormContextWrapper = ({ - theCase, - children, -}: { - theCase: TempCase - children?: ReactNode -}) => { +export const FormContextWrapper: FC< + PropsWithChildren<{ theCase: Case; children: ReactNode }> +> = ({ theCase, children }) => { return ( { +export const UserContextWrapper: FC< + PropsWithChildren<{ userRole: UserRole; children: ReactNode }> +> = ({ userRole, children }) => { return (
diff --git a/apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx b/apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx index ff1bd156f268..02789830d308 100644 --- a/apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx +++ b/apps/judicial-system/web/src/routes/Court/components/CasesAwaitingAssignmentTable/CasesAwaitingAssignmentTable.tsx @@ -51,7 +51,7 @@ const CasesAwaitingAssignmentTable: React.FC< title: capitalize( formatMessage(core.defendant, { suffix: 'i' }), ), - sortable: { isSortable: true, key: 'defendant' }, + sortable: { isSortable: true, key: 'defendants' }, }, { title: formatMessage(tables.type), @@ -60,7 +60,7 @@ const CasesAwaitingAssignmentTable: React.FC< title: capitalize( formatMessage(tables.created, { suffix: 'i' }), ), - sortable: { isSortable: true, key: 'createdAt' }, + sortable: { isSortable: true, key: 'created' }, }, { title: formatMessage(tables.state) }, ]} diff --git a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx index 202644596241..974fde5bc010 100644 --- a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx +++ b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx @@ -112,14 +112,14 @@ const CasesInProgressTable: FC = (props) => { title: capitalize( formatMessage(core.defendant, { suffix: 'i' }), ), - sortable: { isSortable: true, key: 'defendant' }, + sortable: { isSortable: true, key: 'defendants' }, }, { title: formatMessage(tables.type) }, { title: capitalize( formatMessage(tables.created, { suffix: 'i' }), ), - sortable: { isSortable: true, key: 'createdAt' }, + sortable: { isSortable: true, key: 'created' }, }, { title: formatMessage(tables.state) }, { diff --git a/apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx b/apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx index d3d9049aed16..29271595b532 100644 --- a/apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx +++ b/apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx @@ -45,7 +45,7 @@ export const DefenderCasesTable: React.FC> = ( const { formatMessage } = useIntl() const { cases, showingCompletedCases, loading } = props const { sortedData, requestSort, getClassNamesFor, isActiveColumn } = - useSortCases('createdAt', 'descending', cases) + useSortCases('created', 'descending', cases) const { isOpeningCaseId, LoadingIndicator, showLoading, handleOpenCase } = useCaseList() @@ -74,10 +74,10 @@ export const DefenderCasesTable: React.FC> = ( title={capitalize( formatMessage(core.defendant, { suffix: 'i' }), )} - onClick={() => requestSort('defendant')} - sortAsc={getClassNamesFor('defendant') === 'ascending'} - sortDes={getClassNamesFor('defendant') === 'descending'} - isActive={isActiveColumn('defendant')} + onClick={() => requestSort('defendants')} + sortAsc={getClassNamesFor('defendants') === 'ascending'} + sortDes={getClassNamesFor('defendants') === 'descending'} + isActive={isActiveColumn('defendants')} dataTestid="accusedNameSortButton" /> @@ -91,10 +91,10 @@ export const DefenderCasesTable: React.FC> = ( title={capitalize( formatMessage(tables.created, { suffix: 'i' }), )} - onClick={() => requestSort('createdAt')} - sortAsc={getClassNamesFor('createdAt') === 'ascending'} - sortDes={getClassNamesFor('createdAt') === 'descending'} - isActive={isActiveColumn('createdAt')} + onClick={() => requestSort('created')} + sortAsc={getClassNamesFor('created') === 'ascending'} + sortDes={getClassNamesFor('created') === 'descending'} + isActive={isActiveColumn('created')} /> diff --git a/apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx b/apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx index c62cfa2a1be8..1cddc7476c5b 100644 --- a/apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx +++ b/apps/judicial-system/web/src/routes/Prosecutor/components/CasesAwaitingConfirmationTable/CasesAwaitingConfirmationTable.tsx @@ -58,14 +58,14 @@ const CasesAwaitingConfirmationTable: React.FC< title: capitalize( formatMessage(core.defendant, { suffix: 'i' }), ), - sortable: { isSortable: true, key: 'defendant' }, + sortable: { isSortable: true, key: 'defendants' }, }, { title: formatMessage(tables.type), }, { title: capitalize(formatMessage(tables.created)), - sortable: { isSortable: true, key: 'createdAt' }, + sortable: { isSortable: true, key: 'created' }, }, { title: formatMessage(tables.state) }, { diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx index 8661615c2a46..5da228617a54 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx @@ -49,10 +49,16 @@ const CasesForReview: React.FC = ({ title: capitalize( formatMessage(core.defendant, { suffix: 'i' }), ), - sortable: { isSortable: true, key: 'defendant' }, + sortable: { isSortable: true, key: 'defendants' }, }, { title: formatMessage(tables.state) }, - { title: formatMessage(tables.deadline) }, + { + title: formatMessage(tables.deadline), + sortable: { + isSortable: true, + key: 'indictmentAppealDeadline', + }, + }, ]} data={cases} generateContextMenuItems={(row) => { diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx index ac8a40e59f23..6b99ebe85eb3 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { FC } from 'react' import { useIntl } from 'react-intl' import { AnimatePresence } from 'framer-motion' @@ -27,10 +27,7 @@ interface CasesForReviewTableProps { cases: CaseListEntry[] } -const CasesForReview: React.FC = ({ - loading, - cases, -}) => { +const CasesForReview: FC = ({ loading, cases }) => { const { formatMessage } = useIntl() const { openCaseInNewTabMenuItem } = useContextMenu() @@ -49,11 +46,20 @@ const CasesForReview: React.FC = ({ title: capitalize( formatMessage(core.defendant, { suffix: 'i' }), ), - sortable: { isSortable: true, key: 'defendant' }, + sortable: { + isSortable: true, + key: 'defendants', + }, }, { title: formatMessage(tables.state) }, { title: formatMessage(tables.prosecutorName) }, - { title: formatMessage(tables.deadline) }, + { + title: formatMessage(tables.deadline), + sortable: { + isSortable: true, + key: 'indictmentAppealDeadline', + }, + }, ]} data={cases} generateContextMenuItems={(row) => { @@ -85,12 +91,10 @@ const CasesForReview: React.FC = ({ ), }, { - cell: (row: CaseListEntry) => ( - {row.indictmentReviewer?.name} - ), + cell: (row) => {row.indictmentReviewer?.name}, }, { - cell: (row: CaseListEntry) => ( + cell: (row) => ( {formatDate(row.indictmentAppealDeadline, 'P')} ), }, diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx index 9569db67b06e..f8f9ed5831d8 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx @@ -75,7 +75,7 @@ const CasesReviewed: FC = ({ loading, cases }) => { title: capitalize( formatMessage(core.defendant, { suffix: 'i' }), ), - sortable: { isSortable: true, key: 'defendant' }, + sortable: { isSortable: true, key: 'defendants' }, }, { title: formatMessage(tables.reviewDecision) }, { title: formatMessage(tables.verdictViewState) }, diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx b/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx index 217e87df2a0d..7c1a2df0743f 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx +++ b/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx @@ -83,7 +83,7 @@ const ActiveCases: React.FC> = (props) => { cases.sort((a: CaseListEntry, b: CaseListEntry) => { const getColumnValue = (entry: CaseListEntry) => { if ( - sortConfig.column === 'defendant' && + sortConfig.column === 'defendants' && entry.defendants && entry.defendants.length > 0 ) { @@ -179,10 +179,10 @@ const ActiveCases: React.FC> = (props) => { title={capitalize( formatMessage(core.defendant, { suffix: 'i' }), )} - onClick={() => requestSort('defendant')} - sortAsc={getClassNamesFor('defendant') === 'ascending'} - sortDes={getClassNamesFor('defendant') === 'descending'} - isActive={sortConfig?.column === 'defendant'} + onClick={() => requestSort('defendants')} + sortAsc={getClassNamesFor('defendants') === 'ascending'} + sortDes={getClassNamesFor('defendants') === 'descending'} + isActive={sortConfig?.column === 'defendants'} dataTestid="accusedNameSortButton" />