/** * MITHOME-131: partner / reference rules (managed web operations research, * PLATFM-13, "Partner- és referenciaprogram"). * * - A client must not be presented as a "partner": every entry carries its * real relationship category, and clients are shown separately. * - Only entries with a written publication permission ("granted") and a * usable logo appear publicly. */ export const RELATIONSHIPS = [ 'client-reference', 'technology-partner', 'infrastructure', 'supplier', 'technology-used', 'professional-partner', ] as const export type Relationship = (typeof RELATIONSHIPS)[number] export const RELATIONSHIP_LABELS: Record = { 'client-reference': 'Ügyfélreferencia', 'technology-partner': 'Technológiai partner', infrastructure: 'Infrastruktúra-szolgáltató', supplier: 'Beszállító', 'technology-used': 'Használt technológia (nem partnerség)', 'professional-partner': 'Szakmai partner', } export const PERMISSIONS = ['granted', 'pending', 'none'] as const export type Permission = (typeof PERMISSIONS)[number] export const PERMISSION_LABELS: Record = { granted: 'Írásban engedélyezett', pending: 'Egyeztetés alatt', none: 'Nincs engedély', } export type PartnerView = { name: string url: string relationship: Relationship logo: { url: string; alt: string } } type PartnerDoc = { name: string url: string relationship?: string | null publicationPermission?: string | null logo?: unknown } const isRelationship = (value: unknown): value is Relationship => typeof value === 'string' && (RELATIONSHIPS as readonly string[]).includes(value) /** Publicly showable entries: written permission, known category, usable logo. */ export function publicPartners(docs: readonly PartnerDoc[]): PartnerView[] { return docs.flatMap((doc) => { const logo = doc.logo as { url?: string; alt?: string } | null | undefined if (doc.publicationPermission !== 'granted' || !isRelationship(doc.relationship) || !logo?.url) return [] return [{ name: doc.name, url: doc.url, relationship: doc.relationship, logo: { url: logo.url, alt: logo.alt ?? doc.name } }] }) } /** Clients and every other relationship are shown in separate blocks. */ export function groupReferences(partners: readonly PartnerView[]) { return { clients: partners.filter((p) => p.relationship === 'client-reference'), partners: partners.filter((p) => p.relationship !== 'client-reference'), } }