import HeaderWithAuth from "@/components/headerWithAuth"; import Main from "@/components/main"; import { ArrowLeftIcon } from "lucide-react"; import Link from "next/link"; import { notFound } from "next/navigation"; import { isApiError } from "@/lib/api"; import { getCollection } from "@/lib/serverApi"; import { LANGUAGES } from "@/lib/languages"; import type { CollectionResult } from "@/types/api"; import { MenuDialog } from "./menuDialog"; import { getTranslations } from "next-intl/server"; import { WordsSearch } from "./wordsSearch"; export default async function CollectionPage({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; const tCollections = await getTranslations("Collections"); const tc = await getTranslations("Common"); const tl = await getTranslations("Languages"); const tApi = await getTranslations("ApiErrors"); let collection: CollectionResult; try { collection = await getCollection(id); } catch (err) { if (isApiError(err) && err.kind === "not-found") notFound(); const message = isApiError(err) ? tApi(err.kind) : tc("somethingWrong"); return (

{message}

); } const language = LANGUAGES.find((l) => l.id === collection.lang); const words = [...collection.words].reverse(); return (

{tCollections("title")}

{collection.name === "history" ? tc("history") : collection.name}

{collection.words.length} {collection.words.length === 1 ? tc("word") : tc("words")}

{language &&

{tl(language.id)}

}
); }