import { auth } from "@/lib/auth" import { redirect } from "next/navigation" import { getUserCollections, getGlobalCollections } from "@/actions/collections" import Link from "next/link" export default async function CollectionsPage() { const session = await auth() if (!session?.user) { redirect("/login") } const [userCollectionsResult, globalCollectionsResult] = await Promise.all([ getUserCollections(), getGlobalCollections(), ]) const userCollections = userCollectionsResult.success ? userCollectionsResult.data || [] : [] const globalCollections = globalCollectionsResult.success ? globalCollectionsResult.data || [] : [] return (

Collections

Organize your hanzi into collections for learning

Create Collection
{/* User Collections */}

My Collections

{userCollections.length === 0 ? (

You don't have any collections yet.

Create Your First Collection
) : (
{userCollections.map((collection) => (

{collection.name}

{collection.description && (

{collection.description}

)}
{collection.hanziCount} {collection.isPublic ? "Public" : "Private"}

Created {new Date(collection.createdAt).toLocaleDateString()}

))}
)}
{/* Global Collections (HSK) */}

HSK Collections

{globalCollections.length === 0 ? (

No HSK collections available yet. Ask an admin to create them.

) : (
{globalCollections.map((collection) => (

{collection.name}

HSK
{collection.description && (

{collection.description}

)}
{collection.hanziCount} hanzi
))}
)}
) }