- 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>
91 lines
3.7 KiB
TypeScript
91 lines
3.7 KiB
TypeScript
import type { Metadata } from "next";
|
|
import "@crosscode/ui/fonts.css";
|
|
import "./globals.css";
|
|
import { brandAttributes } from "@crosscode/ui";
|
|
import { AuthProvider } from "@/contexts/AuthContext";
|
|
import { SiteSettingsProvider } from "@/contexts/SiteSettingsContext";
|
|
import { ToastProvider } from "@/components/shared/ToastProvider";
|
|
import { BannerBar } from "@/components/shared/BannerBar";
|
|
import { SetupGuard } from "@/components/shared/SetupGuard";
|
|
import HelpFab from "@/components/shared/HelpFab";
|
|
import { CookieConsent } from "@/components/shared/CookieConsent";
|
|
import { ImpersonationBanner } from "@/components/shared/ImpersonationBanner";
|
|
import { SkipLink } from "@/components/layout/SkipLink";
|
|
import { resolveToApiOrigin } from "@/lib/api";
|
|
import { getServerSettings } from "@/lib/serverSettings";
|
|
import { getServerChurch } from "@/lib/serverChurch";
|
|
import { ChurchProvider } from "@/contexts/ChurchContext";
|
|
import { buildThemeCssVars } from "@/lib/colorScale";
|
|
import { appUrl } from "@/lib/siteConfig";
|
|
|
|
const appName = process.env.NEXT_PUBLIC_APP_NAME || 'Cross Code';
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
|
const settings = await getServerSettings();
|
|
const faviconUrl = settings.favicon_url ? resolveToApiOrigin(settings.favicon_url) : null;
|
|
const logoUrl = settings.logo_url ? resolveToApiOrigin(settings.logo_url) : null;
|
|
const displayName = settings.org_name || appName;
|
|
const description = settings.org_tagline || `Manage and register for events with ${displayName}`;
|
|
|
|
return {
|
|
metadataBase: new URL(appUrl),
|
|
title: { default: displayName, template: `%s | ${displayName}` },
|
|
description,
|
|
icons: {
|
|
icon: faviconUrl || "/favicon.ico",
|
|
},
|
|
openGraph: {
|
|
type: "website",
|
|
siteName: displayName,
|
|
title: { default: displayName, template: `%s | ${displayName}` },
|
|
description,
|
|
...(logoUrl ? { images: [{ url: logoUrl }] } : {}),
|
|
},
|
|
twitter: {
|
|
card: "summary_large_image",
|
|
title: displayName,
|
|
description,
|
|
...(logoUrl ? { images: [logoUrl] } : {}),
|
|
},
|
|
// Per-deployment Search Console ownership check (Settings → Organisation).
|
|
...(settings.google_site_verification ? { verification: { google: settings.google_site_verification } } : {}),
|
|
};
|
|
}
|
|
|
|
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
|
const [settings, church] = await Promise.all([getServerSettings(), getServerChurch()]);
|
|
const cssVars = buildThemeCssVars({
|
|
primary: settings.primary_color || settings.accent_color,
|
|
secondary: settings.secondary_color,
|
|
accent: settings.primary_color ? settings.accent_color : undefined,
|
|
});
|
|
|
|
return (
|
|
// The church's fonts and corners from Accounts (3.7.0): used by the public pages; the
|
|
// dashboard and setup screens keep their own (globals.css, data-cc-staff).
|
|
<html lang="en" {...brandAttributes(church?.branding.style)}>
|
|
<body>
|
|
{cssVars && (
|
|
<style id="brand-theme" dangerouslySetInnerHTML={{ __html: `:root{${cssVars}}` }} />
|
|
)}
|
|
<SkipLink />
|
|
<ChurchProvider church={church}>
|
|
<SiteSettingsProvider initialSettings={settings}>
|
|
<AuthProvider>
|
|
<ToastProvider>
|
|
<SetupGuard />
|
|
<ImpersonationBanner />
|
|
<BannerBar />
|
|
{children}
|
|
<HelpFab />
|
|
<CookieConsent />
|
|
</ToastProvider>
|
|
</AuthProvider>
|
|
</SiteSettingsProvider>
|
|
</ChurchProvider>
|
|
</body>
|
|
</html>
|
|
|
|
);
|
|
}
|