New uploads are drafts: only their creator and moderators see them, nobody can get or wear them, and they're deleted if not published within 30 days (their catalogs get delete changes). The creator reviews the info and publishes it. Editing a product's info is a permission check now (product:edit): moderators can edit anyone's with a reason the creator sees, lock fields (product:lock; locked fields need product:edit-locked) and lower ratings (product:rate-lower, not below its files'). Every change is kept in the product's info history, with who and why, and can be undone by the same rules. Products can be unlisted (out of search and lists, the link still works) and tagged; lists filter by tag and catalog. The console has a Products section (everyone's for moderators, by status) and a drafts to-do. A product's own category is left for later: the hub has no list of IMVU's categories to pick from. Co-Authored-By: Claude Opus 5.5 <[email protected]>
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { Empty, ProductCard } from "@/components/products";
|
|
import Link from "next/link";
|
|
import { PageHeader } from "@/components/status";
|
|
import { Button, buttonVariants } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
import { api, getMe, unwrap } from "@/lib/api";
|
|
|
|
export const metadata: Metadata = { title: "Products" };
|
|
|
|
export default async function Products({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ q?: string | string[]; creator?: string | string[]; tag?: string | string[] }>;
|
|
}) {
|
|
const params = await searchParams;
|
|
const one = (v: string | string[] | undefined, max: number) => (typeof v === "string" ? v.trim().slice(0, max) : "");
|
|
const q = one(params.q, 100);
|
|
const creator = one(params.creator, 64);
|
|
const tag = one(params.tag, 24);
|
|
const [me, { products }] = await Promise.all([
|
|
getMe(),
|
|
api.products
|
|
.get({ query: { ...(q ? { q } : {}), ...(creator ? { creator } : {}), ...(tag ? { tag } : {}) } })
|
|
.then(unwrap),
|
|
]);
|
|
|
|
return (
|
|
<>
|
|
<div className="flex flex-wrap items-start justify-between gap-4">
|
|
<PageHeader title="Products">
|
|
{[creator && `By ${creator}.`, tag && `Tagged “${tag}”.`].filter(Boolean).join(" ") || "Community products for T5DE."}
|
|
</PageHeader>
|
|
{me && (
|
|
<Link href="/products/new" className={buttonVariants({ className: "px-4" })}>
|
|
New product
|
|
</Link>
|
|
)}
|
|
</div>
|
|
<form action="/products" className="mb-6 flex w-full max-w-md gap-2">
|
|
<Input type="search" name="q" defaultValue={q} placeholder="Search products" aria-label="Search" />
|
|
{creator && <input type="hidden" name="creator" value={creator} />}
|
|
{tag && <input type="hidden" name="tag" value={tag} />}
|
|
<Button type="submit" variant="outline">
|
|
Search
|
|
</Button>
|
|
</form>
|
|
{products.length === 0 ? (
|
|
<Empty>{q || tag || creator ? "Nothing found." : "No products yet."}</Empty>
|
|
) : (
|
|
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
{products.map((p) => (
|
|
<li key={p.id}>
|
|
<ProductCard product={p} />
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)}
|
|
</>
|
|
);
|
|
}
|