// The identity form's pure helpers (6R.14), unit-tested in tests/identity.test.mjs. The new // colours' defaults are data (the venue's own colours), so this file is in the colour guard's DATA. export const LOGOS = ['main', 'light', 'dark', 'icon'] export const CONTACT = ['phone', 'phone2', 'email', 'address', 'website', 'google', 'facebook', 'instagram', 'tiktok', 'tripadvisor', 'whatsapp', 'viber'] export const CONTACT_MAX = { phone: 40, phone2: 40, whatsapp: 40, viber: 40, email: 120, google: 300 } // else 200 (routers/identity.py) export const MAX_COLOURS = 12 /** A new colour: the first a deep blue, the next ones white (the owner changes them). */ export const newColour = (n, name) => ({ name, colour: n === 0 ? '#1e3a8a' : '#ffffff' }) /** The identity as PUT /api/identity takes it (logos as media ids, empty texts as null). */ export function identityBody(d) { return { name: (d.name || '').trim(), slogan: (d.slogan || '').trim() || null, colours: (d.colours || []).map(c => ({ name: (c.name || '').trim(), colour: c.colour })), logos: Object.fromEntries(LOGOS.map(k => [k, d.logos?.[k]?.id ?? null])), wifi: { ssid: d.wifi?.ssid || null, password: d.wifi?.password || null, security: d.wifi?.security || 'WPA', hidden: !!d.wifi?.hidden, note: d.wifi?.note || null }, contact: Object.fromEntries(CONTACT.map(k => [k, (d.contact?.[k] || '').trim() || null])), } }