diff --git a/src/app/curator/homework/page.tsx b/src/app/curator/homework/page.tsx index 87752df..af512ee 100644 --- a/src/app/curator/homework/page.tsx +++ b/src/app/curator/homework/page.tsx @@ -1,13 +1,12 @@ import { prisma } from "@/lib/prisma"; import Link from "next/link"; -import { HomeworkFilters } from "@/components/admin/homework-filters"; import { Suspense } from "react"; const PAGE_SIZE = 20; interface Props { searchParams: Promise<{ - search?: string; + q?: string; status?: string; courseId?: string; page?: string; @@ -15,20 +14,22 @@ interface Props { } export default async function HomeworkListPage({ searchParams }: Props) { - const { search = "", status = "", courseId = "", page = "1" } = await searchParams; - const currentPage = Math.max(1, parseInt(page) || 1); + const sp = await searchParams; + const q = sp.q ?? ""; + const status = sp.status ?? ""; + const courseId = sp.courseId ?? ""; + const currentPage = Math.max(1, parseInt(sp.page ?? "1") || 1); const skip = (currentPage - 1) * PAGE_SIZE; // Build where clause const where = { - ...(search + ...(q ? { - user: { - OR: [ - { name: { contains: search, mode: "insensitive" as const } }, - { email: { contains: search, mode: "insensitive" as const } }, - ], - }, + OR: [ + { user: { name: { contains: q, mode: "insensitive" as const } } }, + { user: { email: { contains: q, mode: "insensitive" as const } } }, + { homework: { lesson: { title: { contains: q, mode: "insensitive" as const } } } }, + ], } : {}), ...(courseId @@ -38,10 +39,8 @@ export default async function HomeworkListPage({ searchParams }: Props) { }, } : {}), - ...(status === "pending" ? { status: "PENDING" } : {}), - ...(status === "reviewing" ? { status: "REVIEWING" } : {}), - ...(status === "approved" ? { status: "APPROVED" } : {}), - ...(status === "rejected" ? { status: "REJECTED" } : {}), + ...(status === "pending" ? { feedbacks: { none: {} } } : {}), + ...(status === "reviewed" ? { feedbacks: { some: {} } } : {}), }; const [submissions, total, courses] = await Promise.all([ @@ -71,17 +70,25 @@ export default async function HomeworkListPage({ searchParams }: Props) { const totalPages = Math.ceil(total / PAGE_SIZE); - const pendingCount = submissions.filter((s) => s.status === "PENDING").length; - function pageUrl(p: number) { const params = new URLSearchParams(); - if (search) params.set("search", search); + if (q) params.set("q", q); if (status) params.set("status", status); if (courseId) params.set("courseId", courseId); params.set("page", String(p)); return `/curator/homework?${params.toString()}`; } + const inputStyle: React.CSSProperties = { + border: "2px solid var(--border)", + background: "var(--background)", + outline: "none", + padding: "0.4rem 0.75rem", + fontSize: "0.8rem", + fontFamily: "inherit", + color: "var(--foreground)", + }; + return (
- {total} {total === 1 ? "работа" : "работ"} · {pendingCount} ожидают проверки + {total} {total === 1 ? "работа" : "работ"}
{s.user.name}
@@ -137,9 +188,9 @@ export default async function HomeworkListPage({ searchParams }: Props) {{new Date(s.submittedAt).toLocaleDateString("ru-RU")} @@ -186,7 +237,7 @@ export default async function HomeworkListPage({ searchParams }: Props) { → )} - стр. {currentPage} из {totalPages} + Страница {currentPage} из {totalPages} · Всего: {total}