import { BookOpen, Inbox } from "lucide-react" import { getTextbooks } from "@/modules/textbooks/data-access" import { TextbookCard } from "@/modules/textbooks/components/textbook-card" import { TextbookFilters } from "@/modules/textbooks/components/textbook-filters" import { getDemoStudentUser } from "@/modules/homework/data-access" import { EmptyState } from "@/shared/components/ui/empty-state" import { Button } from "@/shared/components/ui/button" import Link from "next/link" export const dynamic = "force-dynamic" type SearchParams = { [key: string]: string | string[] | undefined } const getParam = (params: SearchParams, key: string) => { const v = params[key] return Array.isArray(v) ? v[0] : v } export default async function StudentTextbooksPage({ searchParams, }: { searchParams: Promise }) { const [student, sp] = await Promise.all([getDemoStudentUser(), searchParams]) if (!student) { return (

Textbooks

Browse your course textbooks.

) } const q = getParam(sp, "q") || undefined const subject = getParam(sp, "subject") || undefined const grade = getParam(sp, "grade") || undefined const textbooks = await getTextbooks(q, subject, grade) const hasFilters = Boolean(q || (subject && subject !== "all") || (grade && grade !== "all")) return (

Textbooks

Browse your course textbooks.

{textbooks.length === 0 ? ( ) : (
{textbooks.map((textbook) => ( ))}
)}
) }