From dc8bc7268783a1a2cc11576d7a68743e42f9dfc9 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Tue, 25 Feb 2025 19:30:56 +0800 Subject: [PATCH] aff --- .../main/courses/components/CourseList.tsx | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/apps/web/src/app/main/courses/components/CourseList.tsx b/apps/web/src/app/main/courses/components/CourseList.tsx index 4550795..97001f0 100755 --- a/apps/web/src/app/main/courses/components/CourseList.tsx +++ b/apps/web/src/app/main/courses/components/CourseList.tsx @@ -1,6 +1,6 @@ -import { Pagination, Empty } from "antd"; +import { Pagination, Empty, Skeleton } from "antd"; import CourseCard from "./CourseCard"; -import { CourseDto, Prisma } from "@nice/common"; +import { courseDetailSelect, CourseDto, Prisma } from "@nice/common"; import { api } from "@nice/client"; import { DefaultArgs } from "@prisma/client/runtime/library"; import { useEffect, useMemo, useState } from "react"; @@ -11,6 +11,8 @@ interface CourseListProps { where?: Prisma.PostWhereInput; select?: Prisma.PostSelect; }; + cols?: number; + showPagination?: boolean; } interface CoursesPagnationProps { data: { @@ -19,10 +21,15 @@ interface CoursesPagnationProps { }; isLoading: boolean; } -export default function CourseList({ params }: CourseListProps) { +export default function CourseList({ + params, + cols = 3, + showPagination = true, +}: CourseListProps) { const [currentPage, setCurrentPage] = useState(params?.page || 1); const { data, isLoading }: CoursesPagnationProps = api.post.findManyWithPagination.useQuery({ + select: courseDetailSelect, ...params, page: currentPage, }); @@ -51,20 +58,26 @@ export default function CourseList({ params }: CourseListProps) {
{courses.length > 0 ? ( <> -
- {courses.map((course) => ( - - ))} -
-
- +
+ {isLoading ? ( + + ) : ( + courses.map((course) => ( + + )) + )}
+ {showPagination && ( +
+ +
+ )} ) : (