sort course
This commit is contained in:
parent
e0e2c05f7b
commit
a0bd4d25b1
|
@ -843,6 +843,7 @@ export class Info_imageService {
|
||||||
export type TDataReadCourses = {
|
export type TDataReadCourses = {
|
||||||
limit?: number
|
limit?: number
|
||||||
skip?: number
|
skip?: number
|
||||||
|
sort?: string
|
||||||
}
|
}
|
||||||
export type TDataCreate = {
|
export type TDataCreate = {
|
||||||
requestBody: CourseCreate
|
requestBody: CourseCreate
|
||||||
|
|
|
@ -38,7 +38,7 @@ const PER_PAGE = 100
|
||||||
function getcoursesQueryOptions({ page }: { page: number }) {
|
function getcoursesQueryOptions({ page }: { page: number }) {
|
||||||
return {
|
return {
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
CoursesService.readCourses({ skip: (page - 1) * PER_PAGE, limit: PER_PAGE }),
|
CoursesService.readCourses({ skip: (page - 1) * PER_PAGE, limit: PER_PAGE, }),
|
||||||
queryKey: ["courses", { page }],
|
queryKey: ["courses", { page }],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,10 @@ function CoursesTable() {
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
...getcoursesQueryOptions({ page }),
|
...getcoursesQueryOptions({ page }),
|
||||||
placeholderData: (prevData) => prevData,
|
placeholderData: (prevData) => prevData,
|
||||||
|
select: (data) => ({
|
||||||
|
...data,
|
||||||
|
data: [...data.data].sort((a, b) => a.index - b.index)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const hasNextPage = !isPlaceholderData && courses?.data.length === PER_PAGE
|
const hasNextPage = !isPlaceholderData && courses?.data.length === PER_PAGE
|
||||||
|
|
Loading…
Reference in New Issue