From a79559d290c0f54988658e48db0cb2bf948dffb8 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Wed, 11 Nov 2026 03:45:43 -0600 Subject: [PATCH] Admin preview: a map block's sections made as the API makes them The preview handed MapBlock the form's sections (location_keys text), so adding one crashed the page on section.keys. It now builds them as shape.js does: keys the venue still has, empty ones dropped, the venue cut to them. Co-Authored-By: Claude Opus 5.5 --- src/components/admin/fields.tsx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/admin/fields.tsx b/src/components/admin/fields.tsx index 8ff6ebe..0d35925 100644 --- a/src/components/admin/fields.tsx +++ b/src/components/admin/fields.tsx @@ -135,9 +135,21 @@ const PREVIEWS = { // the person, so it's looked up in the select options (a name, no // photo: the options carry no more). // A venue and an item's event and map location come from the - // options the same way (088): an event as its title only. + // options the same way (088): an event as its title only. A map + // block's sections (094) are made as the API makes them (shape.js): + // their keys the venue still has, the venue cut to those. contentBlock: (row, options) => { const venue = venueFromOption(options?.venues?.find((v) => v.id === row.venue_id)); + const known = new Map((venue?.locations ?? []).map((l) => [l.key, l])); + const sections = (row.map_sections ?? []) + .map((section) => ({ + name: section.name, + keys: (section.location_keys ?? "").split(",").filter((key) => known.has(key)), + })) + .filter((section) => section.keys.length); + const mapped = venue && sections.length + ? { ...venue, locations: [...new Set(sections.flatMap((section) => section.keys))].map((key) => known.get(key)) } + : venue; const shape = (item) => { const person = item.person_id ? options?.people?.find((p) => p.id === item.person_id) : null; const event = item.event_id ? options?.events?.find((e) => e.id === item.event_id) : null; @@ -151,7 +163,11 @@ const PREVIEWS = { items: (item.items ?? []).map(shape), }; }; - return ; + return ( + + ); }, };