sort course
This commit is contained in:
@@ -843,6 +843,7 @@ export class Info_imageService {
|
||||
export type TDataReadCourses = {
|
||||
limit?: number
|
||||
skip?: number
|
||||
sort?: string
|
||||
}
|
||||
export type TDataCreate = {
|
||||
requestBody: CourseCreate
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user