import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { membership as membershipLabel } from "@/components/catalogs"; import { ActionForm, SubmitButton } from "@/components/forms"; import { PageHeader, Tag } from "@/components/status"; import { buttonVariants } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { api, getMe, unwrap } from "@/lib/api"; import { membership } from "../../console/catalogs/actions"; export const metadata: Metadata = { title: "Catalog" }; export default async function CatalogPage({ params, searchParams, }: { params: Promise<{ id: string }>; searchParams: Promise<{ invite?: string | string[] }>; }) { const { id } = await params; const raw = (await searchParams).invite; const invite = typeof raw === "string" && /^[a-z0-9]{1,32}$/.test(raw) ? raw : ""; const [me, answer] = await Promise.all([getMe(), api.catalogs({ id }).get()]); if (answer.error) notFound(); const data = unwrap(answer); const c = data.catalog; const manage = data.permissions.includes("audit:read"); return (
{membershipLabel[c.membership] ?? c.membership} {c.maxRating === "general" && General audiences} {data.membership === "member" && Member} {data.membership === "requested" && Asked to join} {data.membership === "banned" && Banned}
Products {data.hosted.products} Takedown Contact {c.contact}
Membership {c.membership === "open" ? "Anyone on T5DE can get its products." : c.membership === "approval" ? "Ask to join; its team decides. Anyone can see its products on others." : "Join with an invitation. Anyone can see its products on others."} {!me ? ( Sign in to join ) : data.membership === "banned" ? (

This catalog's team banned you from it.

) : data.membership === "member" || data.membership === "requested" ? ( {data.membership === "member" ? "Leave" : "Withdraw request"} ) : c.membership === "open" ? (

Nothing to join: get its products from their pages.

) : c.membership === "invite" && !invite ? (

You need an invitation link from its team.

) : ( {invite ? "Accept invitation" : "Ask to join"} )}
{manage && ( Manage )}
); }