diff --git a/frontend/src/client/services.ts b/frontend/src/client/services.ts index bf35f1c..3806946 100644 --- a/frontend/src/client/services.ts +++ b/frontend/src/client/services.ts @@ -843,6 +843,7 @@ export class Info_imageService { export type TDataReadCourses = { limit?: number skip?: number + sort?: string } export type TDataCreate = { requestBody: CourseCreate diff --git a/frontend/src/routes/_layout/Courses/Courses.tsx b/frontend/src/routes/_layout/Courses/Courses.tsx index 68c42ee..c6f1d0d 100644 --- a/frontend/src/routes/_layout/Courses/Courses.tsx +++ b/frontend/src/routes/_layout/Courses/Courses.tsx @@ -38,7 +38,7 @@ const PER_PAGE = 100 function getcoursesQueryOptions({ page }: { page: number }) { return { queryFn: () => - CoursesService.readCourses({ skip: (page - 1) * PER_PAGE, limit: PER_PAGE }), + CoursesService.readCourses({ skip: (page - 1) * PER_PAGE, limit: PER_PAGE, }), queryKey: ["courses", { page }], } } @@ -59,6 +59,10 @@ function CoursesTable() { } = useQuery({ ...getcoursesQueryOptions({ page }), placeholderData: (prevData) => prevData, + select: (data) => ({ + ...data, + data: [...data.data].sort((a, b) => a.index - b.index) + }) }) const hasNextPage = !isPlaceholderData && courses?.data.length === PER_PAGE