Sign-in steps (password, sign-up, email code, two-step sign-in and its setup with recovery codes, privacy notice, news question), forgot and reset password, the account page, admin (people, deletions, church profile, linked products, settings, notice, licence, audit) and setup. Strict CSP with a nonce per page; church colours from the profile. @crosscode/ui gets its first components (shell, card, fields, buttons). Plan: roles stay in each product (asked 2026-11-18). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
/** The church's branding from the backend, for the server-rendered frame of every page. */
|
|
export type BrandingData = {
|
|
name: string;
|
|
shortName: string | null;
|
|
logoUrl: string | null;
|
|
colours: { primary: string; accent: string | null };
|
|
signupEnabled: boolean;
|
|
setupNeeded: boolean;
|
|
};
|
|
|
|
const api = (process.env.ACCOUNTS_API_URL || "http://127.0.0.1:5200").replace(/\/+$/, "");
|
|
|
|
export async function loadBranding(): Promise<BrandingData> {
|
|
try {
|
|
const res = await fetch(`${api}/api/v2/branding`, { cache: "no-store" });
|
|
if (res.ok) return (await res.json()) as BrandingData;
|
|
} catch {
|
|
// The backend is starting or down: plain defaults, the page still works.
|
|
}
|
|
return { name: "Sign in", shortName: null, logoUrl: null, colours: { primary: "#1f4e79", accent: null }, signupEnabled: true, setupNeeded: false };
|
|
}
|
|
|
|
/** "#1f4e79" → "31 78 121" (Tailwind's rgb(var(--brand) / alpha)), and a darker shade for hover. */
|
|
export function rgbVars(hex: string): { brand: string; dark: string } {
|
|
const m = /^#([0-9a-f]{6})$/i.exec(hex) ?? ["", "1f4e79"];
|
|
const n = parseInt(m[1]!, 16);
|
|
const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255];
|
|
const d = (x: number) => Math.round(x * 0.8);
|
|
return { brand: `${r} ${g} ${b}`, dark: `${d(r)} ${d(g)} ${d(b)}` };
|
|
}
|