import type { Field } from 'payload' import { preistraegerIndexContent } from '@/spa/preistraegerIndexContent' const uploadField = (name: string, label: string, description?: string): Field => ({ name, type: 'upload', relationTo: 'media', label, admin: description ? { description } : undefined, }) const text = (name: string, label: string, defaultValue?: string): Field => ({ name, type: 'text', label, defaultValue, }) const textarea = (name: string, label: string, defaultValue?: string): Field => ({ name, type: 'textarea', label, defaultValue, }) const ctaGroup = (name: string, label: string, labelDefault: string, urlDefault: string): Field => ({ name, label, type: 'group', fields: [text('label', 'Label', labelDefault), text('url', 'URL', urlDefault)], }) const sectionAdmin = (description: string) => ({ description, initCollapsed: true, }) export const preistraegerIndexFields: Field[] = [ { name: 'preistraegerIndex', label: 'Preisträger index page content', type: 'group', admin: { description: 'Edit the Preisträger listing page chrome. Individual winner cards are managed through the Preisträger collection.', }, fields: [ { name: 'hero', label: '01 · Hero image', type: 'group', admin: sectionAdmin('Large image above the filters. Upload an image or keep the migrated URL fallback.'), fields: [ uploadField('image', 'Hero image'), text('imageUrl', 'Fallback image URL', preistraegerIndexContent.hero.imageUrl), text('imageAlt', 'Image alt text', preistraegerIndexContent.hero.imageAlt), ], }, { name: 'breadcrumb', label: '02 · Breadcrumb bar', type: 'group', admin: sectionAdmin('Small page label below the image.'), fields: [text('label', 'Label', preistraegerIndexContent.breadcrumb.label)], }, { name: 'filters', label: '03 · Filters', type: 'group', admin: sectionAdmin('Filter placeholders, toggle label, and reset label.'), fields: [ text('categoryPlaceholder', 'Category placeholder', preistraegerIndexContent.filters.categoryPlaceholder), text('searchPlaceholder', 'Search placeholder', preistraegerIndexContent.filters.searchPlaceholder), textarea('storyHeading', 'Story heading', preistraegerIndexContent.filters.storyHeading), text('mediaIcon', 'Media icon', preistraegerIndexContent.filters.mediaIcon), text('mediaLabel', 'Media label', preistraegerIndexContent.filters.mediaLabel), text('resetLabel', 'Reset label', preistraegerIndexContent.filters.resetLabel), ], }, { name: 'count', label: '04 · Count bar', type: 'group', admin: sectionAdmin('Label after the filtered result count.'), fields: [text('label', 'Count label', preistraegerIndexContent.count.label)], }, { name: 'empty', label: '05 · Empty state', type: 'group', admin: sectionAdmin('Message when filters return no winners.'), fields: [textarea('message', 'Empty message', preistraegerIndexContent.empty.message)], }, { name: 'card', label: '06 · Winner cards', type: 'group', admin: sectionAdmin('Hover label shown on winner cards.'), fields: [ uploadField('fallbackImage', 'Fallback card image', `Current frontend fallback image: /images/${preistraegerIndexContent.card.fallbackImageFilename}`), text('hoverLabel', 'Hover label', preistraegerIndexContent.card.hoverLabel), { name: 'fallbackWinner', label: 'Missing winner field fallbacks', type: 'group', fields: [ text('name', 'Name', preistraegerIndexContent.card.fallbackWinner.name), text('category', 'Category', preistraegerIndexContent.card.fallbackWinner.category), text('awardType', 'Award type', preistraegerIndexContent.card.fallbackWinner.awardType), text('location', 'Location', preistraegerIndexContent.card.fallbackWinner.location), text('industry', 'Industry', preistraegerIndexContent.card.fallbackWinner.industry), ], }, ], }, { name: 'cta', label: '07 · Bottom CTA', type: 'group', admin: sectionAdmin('Bottom application and membership CTA.'), fields: [ textarea('text', 'CTA text', preistraegerIndexContent.cta.text), ctaGroup('primaryCta', 'Primary CTA', preistraegerIndexContent.cta.primaryCta.label, preistraegerIndexContent.cta.primaryCta.url), text('secondaryPrefix', 'Secondary prefix', preistraegerIndexContent.cta.secondaryPrefix), ctaGroup('secondaryCta', 'Secondary CTA', preistraegerIndexContent.cta.secondaryCta.label, preistraegerIndexContent.cta.secondaryCta.url), ], }, ], }, ]