feat(web): authoring query/mutation hooks + MSW handlers + shadcn select/checkbox/alert-dialog

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 00:22:59 +02:00
parent f3bab3336c
commit b23a48c310
9 changed files with 647 additions and 13 deletions
+30
View File
@@ -32,3 +32,33 @@ export const objectsPage: AdminObjectPage = {
limit: 50,
offset: 0,
};
export type FieldDefinitionView = components["schemas"]["FieldDefinitionView"];
export type TermView = components["schemas"]["TermView"];
export type AuthorityView = components["schemas"]["AuthorityView"];
export const fieldDefinitions: FieldDefinitionView[] = [
{ key: "inscription", data_type: "text", vocabulary_id: null, authority_kind: null,
required: true, group: "Description", labels: [{ lang: "en", label: "Inscription" }, { lang: "sv", label: "Inskription" }] },
{ key: "count_seen", data_type: "integer", vocabulary_id: null, authority_kind: null,
required: false, group: null, labels: [{ lang: "en", label: "Count seen" }] },
{ key: "made_on", data_type: "date", vocabulary_id: null, authority_kind: null,
required: false, group: null, labels: [{ lang: "en", label: "Made on" }] },
{ key: "is_fragment", data_type: "boolean", vocabulary_id: null, authority_kind: null,
required: false, group: null, labels: [{ lang: "en", label: "Is fragment" }] },
{ key: "title_ml", data_type: "localized_text", vocabulary_id: null, authority_kind: null,
required: false, group: null, labels: [{ lang: "en", label: "Title" }] },
{ key: "material", data_type: "term", vocabulary_id: "v-material", authority_kind: null,
required: false, group: null, labels: [{ lang: "en", label: "Material" }] },
{ key: "maker", data_type: "authority", vocabulary_id: null, authority_kind: "person",
required: false, group: null, labels: [{ lang: "en", label: "Maker" }] },
];
export const materialTerms: TermView[] = [
{ id: "t-bronze", external_uri: null, labels: [{ lang: "en", label: "Bronze" }, { lang: "sv", label: "Brons" }] },
{ id: "t-wood", external_uri: null, labels: [{ lang: "en", label: "Wood" }] },
];
export const personAuthorities: AuthorityView[] = [
{ id: "a-ada", kind: "person", external_uri: null, labels: [{ lang: "en", label: "Ada Lovelace" }] },
];
+19 -13
View File
@@ -1,6 +1,6 @@
import { http, HttpResponse } from "msw";
import { amphora, fibula, objectsPage } from "./fixtures";
import { amphora, fibula, fieldDefinitions, materialTerms, objectsPage, personAuthorities } from "./fixtures";
export const handlers = [
http.get("/api/admin/me", () =>
@@ -15,20 +15,26 @@ export const handlers = [
return found ? HttpResponse.json(found) : new HttpResponse(null, { status: 404 });
}),
http.get("/api/admin/field-definitions", () =>
HttpResponse.json([
{
key: "material",
data_type: "term",
vocabulary_id: "v1",
authority_kind: null,
required: false,
group: null,
labels: [{ lang: "en", label: "Material" }],
},
]),
http.get("/api/admin/field-definitions", () => HttpResponse.json(fieldDefinitions)),
http.get("/api/admin/vocabularies/:id/terms", () => HttpResponse.json(materialTerms)),
http.get("/api/admin/authorities", ({ request }) => {
const kind = new URL(request.url).searchParams.get("kind");
return HttpResponse.json(kind === "person" ? personAuthorities : []);
}),
http.post("/api/admin/objects", () =>
HttpResponse.json({ id: "11111111-1111-1111-1111-111111111111" }, { status: 201 }),
),
http.put("/api/admin/objects/:id", () => new HttpResponse(null, { status: 204 })),
http.put("/api/admin/objects/:id/fields", () => new HttpResponse(null, { status: 204 })),
http.delete("/api/admin/objects/:id", () => new HttpResponse(null, { status: 204 })),
http.post("/api/admin/login", () => new HttpResponse(null, { status: 204 })),
http.post("/api/admin/logout", () => new HttpResponse(null, { status: 204 })),