Website: products, library, catalogs and their console page
/products (search), product pages with revisions, getting and staying on a revision, retracting; /products/:id/edit; /create and new revisions upload from the browser straight to the catalog with a token from the hub; /library; /catalogs (directory, registering with a once-shown key); /console/catalogs to approve or reject. Every page now sends a nonce-based CSP (proxy.ts), so product descriptions can't run scripts. buttonVariants now merges classes, so outline links get their border. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b4f6fce9df
commit
51d5bb5ff3
24 files changed
+1064
-5
No files matched your search
@@ -0,0 +1,26 @@
|
||||
"use server";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { api, ApiError, unwrap } from "@/lib/api";
|
||||
import { field } from "@/lib/actions";
|
||||
|
||||
export type RegisterState = { error?: string; registered?: { id: string; name: string; key: string } } | null;
|
||||
|
||||
/** Registers a catalog; its key is in the answer, the only time it's shown. */
|
||||
export async function registerCatalog(_: RegisterState, form: FormData): Promise<RegisterState> {
|
||||
try {
|
||||
const { catalog, key } = unwrap(
|
||||
await api.catalogs.post({
|
||||
name: field(form, "name"),
|
||||
url: field(form, "url"),
|
||||
contact: field(form, "contact"),
|
||||
visibility: field(form, "visibility"),
|
||||
membership: field(form, "membership"),
|
||||
}),
|
||||
);
|
||||
revalidatePath("/catalogs");
|
||||
return { registered: { id: catalog.id, name: catalog.name, key } };
|
||||
} catch (e) {
|
||||
if (e instanceof ApiError) return { error: e.message };
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user