feat(cms): partner categories, publication permission and CMS-managed references copy (MITHOME-131)

Per the managed web operations research (PLATFM-13), a client must not be
shown as a "partner" and names/logos need written permission. Partners
now carry a required relationship category and a publication permission
(default: none) with the permission's location and review date; only
entries with written permission, a category and a logo are public.

The homepage shows clients ("Akik már minket választottak") and other
relationships in separate blocks via ReferencesSection; every partner
shows its relationship type. The section copy moved from a hard-coded
constant into the Home global (localized). The 20260929_partner_references
migration marks Angele Pihenőház as a client reference with written
permission (owner-confirmed), hides any other uncategorised entry, and
seeds the copy in hu + en. The JSON seed uses the same source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Do Siki
2026-09-29 17:17:05 +02:00
co-authored by Claude Opus 5.5
parent 526f413bfd
commit 5f9a53ed18
14 changed files with 475 additions and 71 deletions
+33
View File
@@ -0,0 +1,33 @@
import { groupReferences, publicPartners } from './partner-references'
const logo = { url: '/media/logo.png', alt: 'Logo' }
describe('publicPartners (MITHOME-131)', () => {
it('should show only entries with a written permission, a known category and a logo', () => {
const docs = [
{ name: 'Angele Pihenőház', url: 'https://angelepihenohaz.hu', relationship: 'client-reference', publicationPermission: 'granted', logo },
{ name: 'Pending', url: 'https://p.example', relationship: 'client-reference', publicationPermission: 'pending', logo },
{ name: 'No permission', url: 'https://n.example', relationship: 'technology-partner', publicationPermission: 'none', logo },
{ name: 'Uncategorised', url: 'https://u.example', publicationPermission: 'granted', logo },
{ name: 'No logo', url: 'https://l.example', relationship: 'supplier', publicationPermission: 'granted', logo: null },
]
expect(publicPartners(docs).map((p) => p.name)).toEqual(['Angele Pihenőház'])
})
it('should fall back to the name as logo alt text', () => {
const [partner] = publicPartners([
{ name: 'Acme', url: 'https://acme.example', relationship: 'supplier', publicationPermission: 'granted', logo: { url: '/x.png' } },
])
expect(partner.logo).toEqual({ url: '/x.png', alt: 'Acme' })
})
})
describe('groupReferences', () => {
it('should never present a client as a partner', () => {
const view = (name: string, relationship: 'client-reference' | 'infrastructure') => ({ name, url: '', relationship, logo })
expect(groupReferences([view('Client', 'client-reference'), view('DC', 'infrastructure')])).toEqual({
clients: [view('Client', 'client-reference')],
partners: [view('DC', 'infrastructure')],
})
})
})
+71
View File
@@ -0,0 +1,71 @@
/**
* 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<Relationship, string> = {
'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<Permission, string> = {
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'),
}
}
+5 -12
View File
@@ -17,6 +17,7 @@ import config from '@payload-config'
import type { Locale } from './i18n'
import { resolveCtaHref, type CtaLink } from './cta-link'
import { readGated } from './translation-gate'
import { publicPartners, type PartnerView } from './partner-references'
let cached: ReturnType<typeof getPayload> | undefined
@@ -105,19 +106,11 @@ export async function getLegalPage(slug: 'adatvedelem' | 'hasznalati-feltetelek'
})
}
export type PartnerView = { name: string; url: string; logo: { url: string; alt: string } }
export type { PartnerView } from './partner-references'
/** MITHOME-131: only entries with a written permission, a category and a logo. */
export async function getPartners(): Promise<PartnerView[]> {
const payload = await payloadClient()
const result = await payload.find({ collection: 'partners', limit: 100, sort: 'name' })
return result.docs
.filter((doc) => typeof doc.logo === 'object' && doc.logo?.url)
.map((doc) => ({
name: doc.name,
url: doc.url,
logo: {
url: (doc.logo as { url: string }).url,
alt: (doc.logo as { alt?: string }).alt ?? doc.name,
},
}))
const result = await payload.find({ collection: 'partners', limit: 100, sort: 'name', depth: 1 })
return publicPartners(result.docs)
}