diff --git a/src/components/sectionList/ColumnHeaderSortable.tsx b/src/components/sectionList/ColumnHeaderSortable.tsx index f55f68e3..d5113808 100644 --- a/src/components/sectionList/ColumnHeaderSortable.tsx +++ b/src/components/sectionList/ColumnHeaderSortable.tsx @@ -1,4 +1,8 @@ -import { DataTableColumnHeader, DataTableColumnHeaderProps } from '@dhis2/ui' +import { + DataTableColumnHeader, + DataTableColumnHeaderProps, + DataTableSortDirection, +} from '@dhis2/ui' import React, { useCallback } from 'react' import { SchemaSection, @@ -37,11 +41,11 @@ export const HeaderColumnsSortable = ({ [setSortOrder] ) - const getDataTableSortDirection = (column: SelectedColumn) => { - const allowSort = - column && isValidSortPathForSchema(schema, column.path) + const isSortAllowed = (column: SelectedColumn) => + column && isValidSortPathForSchema(schema, column.path) - if (!allowSort) { + const getDataTableSortDirection = (column: SelectedColumn) => { + if (!isSortAllowed(column)) { return undefined } if (!sortOrder) { @@ -57,7 +61,11 @@ export const HeaderColumnsSortable = ({ {headerColumns.map((headerColumn) => ( diff --git a/src/lib/sectionList/useSectionListSortOrder.ts b/src/lib/sectionList/useSectionListSortOrder.ts index ea114dfe..17bdd252 100644 --- a/src/lib/sectionList/useSectionListSortOrder.ts +++ b/src/lib/sectionList/useSectionListSortOrder.ts @@ -78,5 +78,5 @@ export const useSectionListSortOrder = () => { export const useSortOrderQueryParams = () => { const [sortOrder] = useSectionListSortOrder() - return sortOrder ? formatSortOrderToString(sortOrder) : undefined + return sortOrder ? `${sortOrder[0]}:i${sortOrder[1]}` : undefined } diff --git a/src/pages/DefaultSectionList.tsx b/src/pages/DefaultSectionList.tsx index da8a8b49..d61e3ec8 100644 --- a/src/pages/DefaultSectionList.tsx +++ b/src/pages/DefaultSectionList.tsx @@ -38,6 +38,7 @@ export const DefaultSectionList = ({ filters }: DefaultSectionListProps) => { }, }, } + const { error, data, refetch } = useQuery({ queryKey: [query], queryFn: ({ queryKey: [query], signal }) => {