import type { GlobalConfig } from 'payload'
import { anyone, isEditorOrAdmin } from '../access/roles'

// The images that were picsum placeholders. Each is an optional upload; the content
// endpoint only emits keys that have a real upload, so unset keys fall back to the
// built-in branded placeholders shipped in the front-end. No regressions.
const img = (name: string, desc: string) => ({
  name, type: 'upload' as const, relationTo: 'media' as const, admin: { description: desc },
})

export const Images: GlobalConfig = {
  slug: 'images',
  admin: { group: 'Content' },
  access: { read: anyone, update: isEditorOrAdmin },
  versions: { drafts: true },
  fields: [
    img('hero3pl', '3PL hero photo (portrait 4:5).'),
    img('hero3plMobile', '3PL hero photo (mobile).'),
    img('rentalHeroAlt', 'Rental ambient background.'),
    img('partnerForm', 'Partner section background.'),
    img('appBackground', 'EPCO Care app section background.'),
  ],
}
