events 3.9.0, website 1.9.0, accounts 1.10.0: the church's details from Accounts everywhere
- Events: the Accounts profile's name, logo, icon, colours and contact details win over Events' own settings while Accounts is connected (pages, emails, WhatsApp, PDFs); Settings shows them read-only with a link to Accounts. The Accounts logo is copied for PDFs (PNG and JPEG). Fixes Events keeping its old church after a demo scenario load. - Website: a background per homepage section in the church's colours; "More info" instead of "Register" for events without registration; the shared colour field. - Accounts: the shared colour field in Church profile. - @crosscode/ui 0.4.0: ColourField and isHexColour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,11 +41,22 @@ const PUBLIC_KEYS = [
|
||||
// @desc Get public app settings
|
||||
// @route GET /api/settings
|
||||
// @access Public
|
||||
// The church's own details from its Accounts profile (name, logo, colours, contact): they win over
|
||||
// this site's settings of the same name while Accounts is connected (src/accounts/church.ts).
|
||||
async function fromAccounts() {
|
||||
try {
|
||||
return await require('../accounts/church').churchSettingsNow();
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const getSettings = async (req, res) => {
|
||||
try {
|
||||
const rows = await prisma.appSetting.findMany({ where: { key: { in: PUBLIC_KEYS } } });
|
||||
const [rows, accounts] = await Promise.all([prisma.appSetting.findMany({ where: { key: { in: PUBLIC_KEYS } } }), fromAccounts()]);
|
||||
const settings = {};
|
||||
for (const r of rows) settings[r.key] = r.value;
|
||||
for (const [k, v] of Object.entries(accounts)) if (PUBLIC_KEYS.includes(k)) settings[k] = v;
|
||||
res.json(settings);
|
||||
} catch (e) {
|
||||
res.status(500).json({ message: safeErrorMessage(e) });
|
||||
@@ -79,6 +90,11 @@ const getAllSettings = async (req, res) => {
|
||||
settings[r.key] = r.value;
|
||||
}
|
||||
}
|
||||
// What the site uses for the keys Accounts sets, and which they are, so Settings shows them
|
||||
// read-only with a link to change them in Accounts.
|
||||
const accounts = await fromAccounts();
|
||||
Object.assign(settings, accounts);
|
||||
settings.accounts_managed = Object.keys(accounts).join(',');
|
||||
res.json(settings);
|
||||
} catch (e) {
|
||||
res.status(500).json({ message: safeErrorMessage(e) });
|
||||
@@ -96,7 +112,7 @@ const updateSettings = async (req, res) => {
|
||||
}
|
||||
|
||||
const ops = Object.entries(updates)
|
||||
.filter(([k, v]) => v !== undefined && v !== null && !PRIVATE_KEYS.has(k))
|
||||
.filter(([k, v]) => v !== undefined && v !== null && !PRIVATE_KEYS.has(k) && k !== 'accounts_managed')
|
||||
.map(([key, value]) => {
|
||||
let storedValue = String(value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user