diff --git a/src/pages/pegase/home/components/StudyTableDisplay.tsx b/src/pages/pegase/home/components/StudyTableDisplay.tsx index f2b0de3..cf7e054 100644 --- a/src/pages/pegase/home/components/StudyTableDisplay.tsx +++ b/src/pages/pegase/home/components/StudyTableDisplay.tsx @@ -62,7 +62,7 @@ const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) = ), }), - columnHelper.accessor('study_name', { + columnHelper.accessor('name', { header: t('home.@study_name'), cell: ({ getValue, row }) => { const status = row.original.status; @@ -72,7 +72,7 @@ const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) = }, }), - columnHelper.accessor('user_name', { + columnHelper.accessor('createdBy', { header: t('home.@user_name'), cell: ({ getValue }: { getValue: () => string }) => ( @@ -91,7 +91,7 @@ const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) = ), }), - columnHelper.accessor('creation_date', { header: t('home.@creation_date') }), + columnHelper.accessor('creationDate', { header: t('home.@creation_date') }), ]; const [isHeaderHovered, setIsHeaderHovered] = useState(false); @@ -102,7 +102,7 @@ const StudyTableDisplay = ({ searchStudy, projectId }: StudyTableDisplayProps) = function addSortColumn(headers: any[]) { return headers.map((column) => { - const isSortable = column.accessorKey !== 'keywords'; + const isSortable = column.accessorKey !== 'keywords' && column.id !== 'radioColumn'; return { ...column, header: ( diff --git a/src/pages/pegase/home/components/tests/useStudyTableDisplay.test.ts b/src/pages/pegase/home/components/tests/useStudyTableDisplay.test.ts index 3a8b999..d6b01af 100644 --- a/src/pages/pegase/home/components/tests/useStudyTableDisplay.test.ts +++ b/src/pages/pegase/home/components/tests/useStudyTableDisplay.test.ts @@ -16,22 +16,22 @@ describe('useStudyTableDisplay', () => { const mockResponse = { content: [ { - study_name: 'study1', - user_name: 'Luis Perez', + name: 'study1', + createdBy: 'Luis Perez', project: 'Project FE2050', status: 'Closed', horizon: '2050', keywords: 'keyword1', - creation_date: '2023-01-01', + creationDate: '2023-01-01', }, { - study_name: 'study2', - user_name: 'Maria Rojas', + name: 'study2', + createdBy: 'Maria Rojas', project: 'Project PDH27', status: 'Inactive', horizon: '2027', keywords: 'keyword2', - creation_date: '2023-01-01', + creationDate: '2023-01-01', }, ], totalElements: 2, @@ -65,13 +65,13 @@ describe('useStudyTableDisplay', () => { const mockResponse = { content: [ { - study_name: 'study1', - user_name: 'Luis Perez', + name: 'study1', + createdBy: 'Luis Perez', project: 'Project FE2050', status: 'Closed', horizon: '2050', keywords: 'keyword1', - creation_date: '2023-01-01', + creationDate: '2023-01-01', }, ], totalElements: 1, diff --git a/src/pages/pegase/home/components/useStudyTableDisplay.ts b/src/pages/pegase/home/components/useStudyTableDisplay.ts index 9418e3d..7ffc6b5 100644 --- a/src/pages/pegase/home/components/useStudyTableDisplay.ts +++ b/src/pages/pegase/home/components/useStudyTableDisplay.ts @@ -44,12 +44,10 @@ export const useStudyTableDisplay = ({ }, [searchStudy, projectId, sortBy]); useEffect(() => { - const sortParams = Object.entries(sortBy) - .map(([key, order]) => `${key},${order}`) - .join('&sort='); + const [sortColumn, sortDirection] = Object.entries(sortBy)[0] || ['', '']; fetch( - `${BASE_URL}/v1/study/search?page=${current + 1}&size=${intervalSize}&projectId=${projectId}&search=${searchStudy}&sort=${sortParams}`, + `${BASE_URL}/v1/study/search?page=${current + 1}&size=${intervalSize}&projectId=${projectId}&search=${searchStudy}&sortColumn=${sortColumn}&sortDirection=${sortDirection}`, ) .then((response) => response.json()) .then((json) => { diff --git a/src/shared/types/pegase/study.ts b/src/shared/types/pegase/study.ts index 29430fa..00b498c 100644 --- a/src/shared/types/pegase/study.ts +++ b/src/shared/types/pegase/study.ts @@ -6,9 +6,9 @@ export type StudyDTO = { id: number; - study_name: string; - user_name: string; - creation_date: Date; + name: string; + createdBy: string; + creationDate: Date; keywords: string[]; project: string; status: string;