People directories, ministries, organization contacts (migrations 062 to 064)

- People tags (062): Data → People tags (Musicians seeded); a person's
  Directories repeater tags them and their Specialty line shows on
  their tile. A People directory section preset shows a tag's first
  12 and links to its full page, /directory/<tag>, with page meta and
  a sitemap entry. Tiles' details panels show a person's links.
- Ministries (063): a new organization kind. A group picks its
  ministry and its page says "Ministry: <name>", linked to the
  ministry's website. Ministries have no public page, list, sitemap
  or timeline entry, and aren't offered where a record links to its
  organization. organizations is rebuilt for the kind CHECK.
- Organization contacts (064): Data → Contact types; a private
  Contacts repeater on each organization (editors and up, readRole on
  a child collection). Tools → Newsletter → Recipients filters them
  by type, kind, region and published and downloads a Mailchimp CSV.
- A trigger refusing a save with a sentence is shown as that message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-03 22:57:34 -05:00
parent 07e56bfd20
commit 0ed7315156
38 changed files with 1108 additions and 29 deletions

View file

@ -69,6 +69,7 @@ const TeamDetail = lazyPage(() => import("./pages/TeamDetail.tsx"))
const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx"))
const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx"))
const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx"))
const DirectoryPage = lazyPage(() => import("./pages/DirectoryPage.tsx"))
/*Admin Pages*/
const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx"))
@ -100,6 +101,7 @@ export default function App() {
<Route path="/awards/:id" element={<AwardDetail />} />
<Route path="/people/:id" element={<PersonDetail />} />
<Route path="/blog/:id" element={<BlogPost />} />
<Route path="/directory/:id" element={<DirectoryPage />} />
<Route path="organization" element={<SitePage key="organization" id="organization" />} />
<Route path="resources" element={<SitePage key="resources" id="resources" />} />
<Route path="history" element={<SitePage key="history" id="history" />} />

View file

@ -396,6 +396,19 @@
text-underline-offset: 2px;
}
/* A directory person's links: one per line's worth, wrapping. */
.pl__links {
display: flex;
flex-wrap: wrap;
gap: 0.25rem 0.75rem;
}
.pl__links a {
display: inline-flex;
align-items: center;
gap: 0.3rem;
}
.pl__bio-text {
margin: 0;
font-size: 0.9375rem;

View file

@ -19,6 +19,7 @@ import { mediaUrl, initials } from "../lib/media.ts";
import { useSmallImage } from "../lib/useSmallImage.ts";
import { paletteFill } from "../lib/color.ts";
import { useReadingMode } from "../lib/readingMode.ts";
import PlatformIcon from "./PlatformIcon.tsx";
import "./PeopleTiles.css";
/**
@ -96,6 +97,8 @@ export interface Person {
pronouns?: string | null;
location_label?: string | null;
public_email?: string | null;
/** Their website, music and social links (a directory's people). */
links?: PersonLink[] | null;
org?: string | { id?: string; name: string; href?: string } | null;
bio?: string | string[] | null;
accent?: string;
@ -105,6 +108,13 @@ export interface Person {
isOwner?: boolean;
}
export interface PersonLink {
kind?: string;
platform?: string | null;
label: string;
url: string;
}
/** A person named by slug. Any other field overrides the record. */
export interface PersonRef extends Partial<Omit<Person, "name">> {
peopleslug: string;
@ -881,6 +891,19 @@ function DetailPanel({
</dd>
</div>
)}
{person.links?.length ? (
<div className="pl__fact">
<dt>Links</dt>
<dd className="pl__links">
{person.links.map((link) => (
<a key={link.url} href={link.url} target="_blank" rel="noreferrer">
<PlatformIcon platform={link.platform} />
{link.label}
</a>
))}
</dd>
</div>
) : null}
</dl>
{paragraphs.filter(Boolean).map((paragraph, index) => (
@ -931,6 +954,11 @@ function ReadingPeople({ groups, level }: { groups: PeopleGroup[]; level: 3 | 4
Email: <a href={`mailto:${person.public_email}`}>{person.public_email}</a>
</p>
)}
{person.links?.map((link) => (
<p key={link.url}>
<a href={link.url}>{link.label}</a>
</p>
))}
{bio.filter(Boolean).map((paragraph, i) => (
<p key={i}>{paragraph}</p>
))}
@ -1022,7 +1050,11 @@ function hasDetails(person: Person): boolean {
return true;
}
return Boolean(
person.pronouns || resolveOrg(person.org) || person.location_label || person.public_email,
person.pronouns ||
resolveOrg(person.org) ||
person.location_label ||
person.public_email ||
person.links?.length,
);
}

View file

@ -0,0 +1,222 @@
/* ═══════════════════════════════════════════════════════════════
NEWSLETTER RECIPIENTS (Tools → Newsletter)
Organization contacts (064_org_contacts.sql) as a mailing list:
pick contact types, organization kinds and a region, see who
matches, and download a CSV that Mailchimp (or a spreadsheet)
imports. Contacts are added on each organization; their types are
Data → Contact types. Private, so editors and up only (the API
says no to anyone else too: GET /admin/contacts).
═══════════════════════════════════════════════════════════════ */
import { DownloadSimple } from '@phosphor-icons/react'
import { useEffect, useState } from 'react'
import { get } from '../../lib/api.ts'
type Option = { id: string; label: string }
type Contact = {
name: string | null
email: string | null
phone: string | null
type_name: string
org_name: string
org_kind: string
region_name: string | null
}
/* The organization kinds, as the CHECK on organizations.kind has them. */
const KINDS: Array<[string, string]> = [
['national', 'National'],
['region', 'Regions'],
['group', 'Groups'],
['partner', 'Partners'],
['ministry', 'Ministries'],
]
/* How many matches show under the filters; the CSV has them all. */
const PREVIEW_ROWS = 8
const MUTED = 'var(--color-muted)'
const input =
'border border-muted/25 bg-surface px-3 py-2 text-sm text-body outline-none focus:border-brand focus:ring-2 focus:ring-brand/25'
const button =
'btn inline-flex items-center gap-2 border border-brand px-4 py-2 text-sm text-link transition-colors hover:bg-tint disabled:opacity-50'
const toggle = (list: string[], value: string) =>
list.includes(value) ? list.filter((v) => v !== value) : [...list, value]
/* "Jane Q. Doe" → Jane, Q. Doe: Mailchimp's First and Last Name. */
function splitName(name: string | null): [string, string] {
const parts = (name ?? '').trim().split(/\s+/).filter(Boolean)
return [parts[0] ?? '', parts.slice(1).join(' ')]
}
const csvCell = (value: string | null) => {
const text = value ?? ''
return /[",\n]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text
}
function toCsv(rows: Contact[]): string {
const head = ['Email', 'First Name', 'Last Name', 'Phone', 'Organization', 'Kind', 'Region', 'Contact type']
const lines = rows.map((row) => {
const [first, last] = splitName(row.name)
return [row.email, first, last, row.phone, row.org_name, row.org_kind, row.region_name, row.type_name]
.map(csvCell)
.join(',')
})
return [head.join(','), ...lines].join('\n')
}
export default function NewsletterRecipients() {
const [types, setTypes] = useState<Option[]>([])
const [regions, setRegions] = useState<Option[]>([])
const [picked, setPicked] = useState<string[]>([])
const [kinds, setKinds] = useState<string[]>([])
const [region, setRegion] = useState('')
const [unpublished, setUnpublished] = useState(false)
const [contacts, setContacts] = useState<Contact[] | null>(null)
const [error, setError] = useState<string | null>(null)
useEffect(() => {
get('/admin/options?only=contact_types,regions', { ttl: 0 })
.then((data: { options: { contact_types: Option[]; regions: Option[] } }) => {
setTypes(data.options.contact_types)
setRegions(data.options.regions)
})
.catch((err) => setError(err instanceof Error ? err.message : 'Couldn’t load the contact types.'))
}, [])
useEffect(() => {
const query = new URLSearchParams()
if (picked.length) query.set('types', picked.join(','))
if (kinds.length) query.set('kinds', kinds.join(','))
if (region) query.set('region', region)
if (unpublished) query.set('unpublished', '1')
let live = true
get(`/admin/contacts?${query}`, { ttl: 0 })
.then((data: { contacts: Contact[] }) => {
if (!live) return
setContacts(data.contacts)
setError(null)
})
.catch((err) => live && setError(err instanceof Error ? err.message : 'Couldn’t load the contacts.'))
return () => {
live = false
}
}, [picked, kinds, region, unpublished])
const withEmail = contacts?.filter((row) => row.email) ?? []
function download() {
const blob = new Blob([toCsv(withEmail)], { type: 'text/csv' })
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = `newsletter-recipients-${new Date().toISOString().slice(0, 10)}.csv`
link.click()
URL.revokeObjectURL(link.href)
}
return (
<section className="mt-10 border-l-4 border-brand bg-raised p-5 shadow-sm">
<h2 className="text-lg font-bold text-link">Recipients</h2>
<p className="mt-1 text-sm" style={{ color: MUTED }}>
Organization contacts as a mailing list. Add contacts on each organization; make their types under Data → Contact
types. Nothing picked in a filter means all of it.
</p>
<div className="mt-4 grid gap-5 md:grid-cols-3">
<fieldset>
<legend className="text-sm font-semibold text-body">Contact types</legend>
{types.length === 0 && (
<p className="mt-1 text-sm" style={{ color: MUTED }}>
None yet: add them under Data → Contact types.
</p>
)}
{types.map((type) => (
<label key={type.id} className="mt-1 flex items-center gap-2 text-sm text-body">
<input type="checkbox" checked={picked.includes(type.id)} onChange={() => setPicked(toggle(picked, type.id))} />
{type.label}
</label>
))}
</fieldset>
<fieldset>
<legend className="text-sm font-semibold text-body">Organization kinds</legend>
{KINDS.map(([kind, label]) => (
<label key={kind} className="mt-1 flex items-center gap-2 text-sm text-body">
<input type="checkbox" checked={kinds.includes(kind)} onChange={() => setKinds(toggle(kinds, kind))} />
{label}
</label>
))}
</fieldset>
<div>
<label className="block text-sm font-semibold text-body">
Region
<select value={region} onChange={(e) => setRegion(e.target.value)} className={`mt-1 block w-full ${input}`}>
<option value="">Default: every region</option>
{regions.map((r) => (
<option key={r.id} value={r.id}>
{r.label}
</option>
))}
</select>
</label>
<p className="mt-1 text-xs" style={{ color: MUTED }}>
The region itself and the groups in it
</p>
<label className="mt-3 flex items-center gap-2 text-sm text-body">
<input type="checkbox" checked={unpublished} onChange={(e) => setUnpublished(e.target.checked)} />
Include unpublished organizations
</label>
</div>
</div>
<div className="mt-5 flex flex-wrap items-center gap-3">
<button type="button" onClick={download} className={button} disabled={withEmail.length === 0}>
<DownloadSimple weight="bold" aria-hidden="true" />
Download CSV
</button>
<p role="status" className={`text-sm ${error ? 'text-danger' : ''}`} style={error ? undefined : { color: MUTED }}>
{error ??
(contacts === null
? 'Loading…'
: `${withEmail.length} with an email` +
(contacts.length > withEmail.length ? ` (${contacts.length - withEmail.length} more have only a phone, left out)` : ''))}
</p>
</div>
{withEmail.length > 0 && (
<div className="mt-4 overflow-x-auto">
<table className="w-full text-left text-sm">
<thead>
<tr className="text-xs" style={{ color: MUTED }}>
<th className="py-1 pr-4 font-semibold">Email</th>
<th className="py-1 pr-4 font-semibold">Name</th>
<th className="py-1 pr-4 font-semibold">Organization</th>
<th className="py-1 pr-4 font-semibold">Type</th>
</tr>
</thead>
<tbody>
{withEmail.slice(0, PREVIEW_ROWS).map((row, index) => (
<tr key={`${row.email}-${index}`} className="border-t border-muted/15 text-body">
<td className="py-1 pr-4">{row.email}</td>
<td className="py-1 pr-4">{row.name || '-'}</td>
<td className="py-1 pr-4">{row.org_name}</td>
<td className="py-1 pr-4">{row.type_name}</td>
</tr>
))}
</tbody>
</table>
{withEmail.length > PREVIEW_ROWS && (
<p className="mt-2 text-xs" style={{ color: MUTED }}>
and {withEmail.length - PREVIEW_ROWS} more in the CSV
</p>
)}
</div>
)}
</section>
)
}

View file

@ -27,6 +27,8 @@ import { timeline } from "./adminSchema/timeline.ts";
import { frontPage } from "./adminSchema/frontPage.ts";
import { blogPosts } from "./adminSchema/blog.ts";
import { siteSettings } from "./adminSchema/siteSettings.ts";
import { personTagTypes } from "./adminSchema/personTags.ts";
import { contactTypes } from "./adminSchema/contactTypes.ts";
import {
communityPage,
retreatsPage,
@ -39,6 +41,8 @@ export const ADMIN_ENTITIES: Record<string, any> = {
organizations,
events,
people,
person_tag_types: personTagTypes,
contact_types: contactTypes,
teams,
awards,
timeline,

View file

@ -0,0 +1,32 @@
/* ── Contact types (064_org_contacts.sql) ────────────────────────
Data → Contact types: the roles an organization's contacts hold,
eg. Minister, General info. Contacts are added on each
organization; Tools → Newsletter → Recipients exports them by
type. A type still in use can't be deleted. Server side:
server/src/admin-schema/contactTypes.js. */
export const contactTypes = {
key: "contact_types",
label: "Contact types",
singular: "contact type",
idLabel: "URL ID",
slugFrom: "name",
list: {
columns: [
{ key: "name", label: "Name", primary: true },
{ key: "sort_order", label: "Order" },
],
filters: [],
},
groups: [
{
legend: "Contact type",
fields: [
{ path: "name", label: "Name", required: true, help: "eg. Minister, General info" },
{ path: "sort_order", label: "Sort order", widget: "number" },
],
},
],
};

View file

@ -20,7 +20,7 @@ export const organizations = {
{ key: "is_listed", label: "Listed", widget: "bool" },
],
filters: [
{ key: "kind", label: "Kind", options: ["national", "region", "group", "partner"] },
{ key: "kind", label: "Kind", options: ["national", "region", "group", "partner", "ministry"] },
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
],
@ -34,9 +34,9 @@ export const organizations = {
path: "kind",
label: "Kind",
widget: "select",
options: ["national", "region", "group", "partner"],
options: ["national", "region", "group", "partner", "ministry"],
required: true,
help: "Changing this swaps which extra fields apply",
help: "Changing this swaps which extra fields apply. A ministry (a Unity church) has no page; its groups name it",
},
{ path: "name", label: "Name", required: true },
{ path: "short_name", label: "Short name" },
@ -70,6 +70,14 @@ export const organizations = {
optionsFrom: "regions",
blankLabel: "Default: none",
},
{
path: "group.ministry_id",
label: "Ministry",
widget: "select",
optionsFrom: "ministries",
blankLabel: "Default: none",
help: "The Unity ministry it belongs to, named on its page (linked to the ministry's website)",
},
{ path: "group.meets", label: "Meets", help: "2nd Sundays, 6:00pm" },
{ path: "group.started", label: "Started", help: "Since 2021" },
],
@ -101,6 +109,25 @@ export const organizations = {
{ path: "note", label: "Note", help: "details to explain why it's half or other note" },
],
},
{
key: "contacts",
label: "Contacts",
note:
"Private: never on the public site, and only editors and up see them. " +
"Tools → Newsletter → Recipients exports them. Types are made under Data → Contact types.",
addLabel: "Add contact",
title: (row, options) =>
[options?.contact_types?.find((t) => t.id === row.type_id)?.label, row.name || row.email]
.filter(Boolean)
.join(" · ") || "New contact",
blank: { type_id: "", name: "", email: "", phone: "" },
fields: [
{ path: "type_id", label: "Type", widget: "select", optionsFrom: "contact_types", required: true },
{ path: "name", label: "Name" },
{ path: "email", label: "Email", help: "An email or a phone is needed" },
{ path: "phone", label: "Phone" },
],
},
linksChild,
blocksChild,
],

View file

@ -32,6 +32,12 @@ export const people = {
{ path: "sort_name", label: "Sort name", help: "Doe, Jane" },
{ path: "pronouns", label: "Pronouns" },
{ path: "tagline", label: "Tagline", full: true },
{
path: "specialty",
label: "Specialty",
full: true,
help: "One line shown in directories, eg. Vocals, piano · Gospel, folk",
},
{ path: "photo", label: "Photo", widget: "image", resolve: mediaUrl, full: true },
{
path: "primary_org_id",
@ -80,6 +86,24 @@ export const people = {
],
children: [
{
key: "tags",
label: "Directories",
note: "Tags that list this person in a directory, eg. Musicians. Tags are made under Data → People tags.",
addLabel: "Add tag",
title: (row, options) =>
options?.person_tag_types?.find((t) => t.id === row.tag_id)?.label ?? "New tag",
blank: { tag_id: "" },
fields: [
{
path: "tag_id",
label: "Tag",
widget: "select",
optionsFrom: "person_tag_types",
required: true,
},
],
},
{
key: "affiliations",
label: "Roles and organizations",

View file

@ -0,0 +1,35 @@
/* ── People tags (062_people_tags.sql) ───────────────────────────
Data → People tags: what a person can be tagged as for a
directory (Musicians first). Which people carry a tag is edited on
the person; a page shows a tag's people with the People directory
preset, and every tag has its full page at /directory/<URL ID>.
Server side: server/src/admin-schema/personTags.js. */
export const personTagTypes = {
key: "person_tag_types",
label: "People tags",
singular: "tag",
idLabel: "URL ID",
slugFrom: "name",
list: {
columns: [
{ key: "name", label: "Name", primary: true },
{ key: "blurb", label: "Intro" },
{ key: "sort_order", label: "Order" },
],
filters: [],
},
groups: [
{
legend: "Tag",
note: "Its full directory is at /directory/ and its URL ID, eg. /directory/musician.",
fields: [
{ path: "name", label: "Name", required: true, help: "The directory's title, eg. Musicians" },
{ path: "blurb", label: "Intro", widget: "textarea", full: true, help: "A line under the full directory's title" },
{ path: "sort_order", label: "Sort order", widget: "number" },
],
},
],
};

View file

@ -18,6 +18,7 @@ const PRESETS = {
partner_list: "Partner organization cards",
events: "Event carousel or grid",
timeline: "Timeline",
people_directory: "People directory (a tag's people)",
};
const ACCENT_OPTIONS = [
@ -99,6 +100,19 @@ const sectionsChild = (presets: string[]) => ({
},
]
: []),
...(presets.includes("people_directory")
? [
{
path: "tag_id",
label: "Directory: tag",
widget: "select",
optionsFrom: "person_tag_types",
blankLabel: "Default: none (shows nothing)",
help: "Shows the first of its people and links to the full directory",
when: { path: "preset", value: "people_directory" },
},
]
: []),
...(presets.includes("group_map")
? [
{
@ -139,7 +153,7 @@ const sitePage = (id: string, label: string, presets: string[], more: Record<str
export const communityPage = sitePage(
"community",
"Community page",
["community_blog", "group_map", "region_list", "partner_list"],
["community_blog", "group_map", "region_list", "partner_list", "people_directory"],
{
groups: [
{
@ -209,6 +223,6 @@ export const communityPage = sitePage(
);
export const retreatsPage = sitePage("retreats", "Retreats page", ["events"]);
export const resourcesPage = sitePage("resources", "Resources page", []);
export const organizationPage = sitePage("organization", "Organization page", []);
export const resourcesPage = sitePage("resources", "Resources page", ["people_directory"]);
export const organizationPage = sitePage("organization", "Organization page", ["people_directory"]);
export const historyPage = sitePage("history", "History page", ["timeline"]);

View file

@ -246,6 +246,9 @@ export type OrganizationRecord = {
region_id?: string | null
region_name?: string | null
region_color?: string | null
/** A group's Unity ministry: no page of its own, so its website. */
ministry_name?: string | null
ministry_url?: string | null
meets?: string | null
started?: string | null
}

19
src/lib/useDirectory.ts Normal file
View file

@ -0,0 +1,19 @@
/* A people directory: a tag's name, intro and people (GET
/api/directories/:tag, 062_people_tags.sql), for the People
directory preset and the full page at /directory/:id. */
import type { Person } from '../components/PeopleTiles.tsx'
import { detailPath } from './hrefs.ts'
import { useRecord } from './useRecord.ts'
export type DirectoryPerson = Person & { id: string; specialty: string | null }
export type DirectoryRecord = {
id: string
name: string
blurb: string | null
people: DirectoryPerson[]
}
export const useDirectory = (id: string | undefined) =>
useRecord<DirectoryRecord>(detailPath('/directories', id), 'directory')

View file

@ -15,6 +15,8 @@ export type SitePageSection = {
scope_id?: string | null
event_type?: string | null
view?: string | null
/** A people_directory preset's tag (Data → People tags). */
tag_id?: string | null
blocks: ContentBlock[]
}

View file

@ -0,0 +1,50 @@
/* ═══════════════════════════════════════════════════════════════
DIRECTORY PAGE: /directory/:id
A people tag's full directory (Data → People tags), eg.
/directory/musician: its name and intro, then everyone carrying
the tag (PeopleDirectory, no limit). A page section can show the
first of them with the People directory preset, linking here.
═══════════════════════════════════════════════════════════════ */
import { useParams } from 'react-router-dom'
import PageShell from '../components/PageShell.tsx'
import PageState from '../components/PageState.tsx'
import PeopleDirectory from './sections/PeopleDirectory.tsx'
import { useDirectory } from '../lib/useDirectory.ts'
import { BRAND } from '../lib/color.ts'
export default function DirectoryPage() {
const { id } = useParams()
const { data: directory, loading, error, notFound, reload } = useDirectory(id)
if (!directory) {
return (
<PageState
loading={loading}
error={error}
notFound={notFound}
onRetry={reload}
noun="directory"
backTo="/community"
backLabel="Community"
/>
)
}
return (
<PageShell
title={directory.name}
intro={directory.blurb ?? undefined}
sections={[
{
id: 'people',
title: '',
accent: BRAND,
content: <PeopleDirectory tag={directory.id} accent={BRAND} />,
},
]}
/>
)
}

View file

@ -251,6 +251,25 @@ function Facts({
</span>
)}
{org.kind === 'group' && org.details.ministry_name && (
<span style={{ color: BODY }}>
Ministry:{' '}
{org.details.ministry_url ? (
<a
href={org.details.ministry_url}
target="_blank"
rel="noreferrer"
className="font-medium hover:underline"
style={{ color: accentText(accent) }}
>
{org.details.ministry_name}
</a>
) : (
org.details.ministry_name
)}
</span>
)}
{org.kind === 'group' && org.details.meets && (
<span style={{ color: BODY }}>Meets {org.details.meets}</span>
)}

View file

@ -31,6 +31,7 @@ import OrgListCards from './sections/OrgList-Card.tsx'
import EventListCards, { EventCardsToggle } from './sections/EventList-Cards.tsx'
import CommunityBlog from './sections/CommunityBlog.tsx'
import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
import PeopleDirectory, { DIRECTORY_PREVIEW } from './sections/PeopleDirectory.tsx'
/* Year the program starts: decades ending before it get the
pre-program look on the timeline. */
@ -84,6 +85,10 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
},
}),
timeline: () => ({ Component: Timeline }),
people_directory: (section) => ({
Component: PeopleDirectory,
props: { tag: section.tag_id, limit: DIRECTORY_PREVIEW },
}),
}
export default function SitePage({ id }: { id: string }) {

View file

@ -14,6 +14,9 @@
unpublished blog post: its blocks and picks as the post's body,
opened in the post's editor to finish.
Under it, Recipients exports organization contacts as a mailing
list (NewsletterRecipients.tsx), for editors and up.
Picked blog posts are read from their public pages, so only a
post visitors can open makes it in, with its excerpt and cover.
Links and images are the live site's (SITE_ORIGIN), since an
@ -30,6 +33,7 @@ import { canDelete, canWrite } from '../../lib/roles.ts'
import { slugify } from '../../lib/adminSchema.ts'
import { blocksChild, BLOCK_TYPES } from '../../lib/adminSchema/shared.ts'
import { Repeater } from '../../components/admin/fields.tsx'
import NewsletterRecipients from '../../components/admin/NewsletterRecipients.tsx'
import { useEvents } from '../../lib/eventData.ts'
import { useFrontPage, type FeaturedCard } from '../../lib/useFrontPage.ts'
import type { BlogPostRecord } from '../../lib/useBlog.ts'
@ -603,6 +607,8 @@ export default function AdminNewsletter() {
/>
</div>
</div>
{canWrite(user) && <NewsletterRecipients />}
</div>
)
}

View file

@ -60,6 +60,11 @@ export const DATA_NAV = {
label: "Organizations",
blurb: "The national organization, regions, groups and partners.",
},
{
to: "/admin/contact_types",
label: "Contact types",
blurb: "Roles an organization's contacts hold, eg. Minister. Contacts are added on the organization.",
},
{
to: "/admin/teams",
label: "Teams",
@ -75,6 +80,11 @@ export const DATA_NAV = {
label: "People",
blurb: "Bios, contact details, affiliations and awards received.",
},
{
to: "/admin/person_tag_types",
label: "People tags",
blurb: "Directories people can be tagged into, eg. Musicians. Who carries a tag is edited on the person.",
},
{
to: "/admin/blog_posts",
label: "Blog posts",

View file

@ -0,0 +1,80 @@
/* ═══════════════════════════════════════════════════════════════
PEOPLE DIRECTORY
A tag's people (Data → People tags, eg. Musicians) as person
tiles: the People directory preset on a page, and the whole list
on the tag's own page (DirectoryPage.tsx, /directory/:id).
<PeopleDirectory tag="musician" limit={DIRECTORY_PREVIEW} />
Each tile's line under the name is the person's specialty (eg.
"Vocals, piano · Gospel, folk"), or their tagline without one;
their details panel adds their links. With a limit, the first that
many show and a link leads to the full directory.
═══════════════════════════════════════════════════════════════ */
import { ArrowRight } from '@phosphor-icons/react'
import { Link } from 'react-router-dom'
import { PeopleTilesView } from '../../components/PeopleTiles.tsx'
import { useDirectory } from '../../lib/useDirectory.ts'
import { accentText, BRAND } from '../../lib/color.ts'
/* How many people a section shows before "See the full directory". */
export const DIRECTORY_PREVIEW = 12
export const directoryHref = (tag: string) => `/directory/${encodeURIComponent(tag)}`
type PeopleDirectoryProps = {
tag?: string | null
/** Show this many, then a link to the full directory. */
limit?: number
accent?: string
}
export default function PeopleDirectory({ tag, limit, accent = BRAND }: PeopleDirectoryProps) {
const { data: directory, loading, error, notFound } = useDirectory(tag ?? undefined)
if (!tag || notFound) {
return (
<div className="mx-auto max-w-6xl px-6">
<p className="notice">· This directory isn’t set up yet ·</p>
</div>
)
}
if (!directory) {
return (
<div className="mx-auto max-w-6xl px-6">
{error ? (
<p className="text-danger">Couldn’t load the directory. {error}</p>
) : (
loading && <div className="skeleton" role="status" aria-label="Loading the directory" />
)}
</div>
)
}
const people = directory.people.map((person) => ({ ...person, title: person.specialty || person.tagline }))
const shown = limit ? people.slice(0, limit) : people
return (
<div className="mx-auto max-w-6xl px-6">
<PeopleTilesView
groups={[{ id: directory.id, people: shown }]}
accent={accent}
emptyMessage={`No ${directory.name.toLowerCase()} listed yet.`}
/>
{limit && people.length > 0 && (
<Link
to={directoryHref(directory.id)}
className="mt-8 inline-block btn border px-5 py-2 text-sm transition-colors hover:bg-tint"
style={{ borderColor: accent, color: accentText(accent) }}
>
{people.length > limit ? `See all ${people.length} ${directory.name.toLowerCase()}` : 'Open the full directory'}{' '}
<ArrowRight size="1em" weight="bold" className="inline align-[-0.125em]" aria-hidden="true" />
</Link>
)}
</div>
)
}