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 ( + + ); }, };