- Backend: the church profile from Accounts (src/accounts/church.ts, kept 10 minutes, last copy kept while Accounts is down), public GET /api/v2/church, and church.changed accepted at POST /api/church/v1/changed (signed with the Accounts link; it answered 404 before). - Frontend: brandAttributes on <html>, @crosscode/ui/fonts.css, body and h1-h3 use the church's pairing, --radius follows its corners; the dashboard and setup screens (data-cc-staff) keep their fonts and 0.5rem. - The shared ChurchFooter on public pages when Accounts is connected (terms and cookie settings below it); header links to the church's other sites. - @crosscode/ui 0.3.0: ChurchFooter takes `bottom`. - Tests: tests/churchProfile.test.ts (8); e2e/church-brand.spec.ts and a /test/profile hook on the e2e Accounts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
771 B
TypeScript
20 lines
771 B
TypeScript
import type { Church } from "@crosscode/contracts";
|
|
import { API_BASE } from "@/lib/api";
|
|
|
|
/**
|
|
* The church profile from the church's Accounts (3.7.0), through the backend's
|
|
* `GET /api/v2/church`: the brand style for `<html>` and the shared footer. null when Accounts
|
|
* isn't connected or the backend can't be reached, and the pages look as they always have.
|
|
* Fetched the same way as getServerSettings, so Next dedupes it within a request.
|
|
*/
|
|
export async function getServerChurch(): Promise<Church | null> {
|
|
if (!API_BASE) return null;
|
|
try {
|
|
const res = await fetch(`${API_BASE}/api/v2/church`, { next: { revalidate: 60 } });
|
|
if (!res.ok) return null;
|
|
return ((await res.json())?.data as Church | null) ?? null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|