diff --git a/payload.config.ts b/payload.config.ts deleted file mode 100644 index 706a573..0000000 --- a/payload.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { buildConfig } from 'payload' -import { mongooseAdapter } from '@payloadcms/db-mongodb' - -export default buildConfig({ - secret: process.env.PAYLOAD_SECRET || '', - db: mongooseAdapter({ - url: process.env.DATABASE_URL || '', - // connectOptions: { - // dbName: 'wdcc-ayo', - // }, - }), - collections: [ - // add collections - ], -}) diff --git a/src/collections/Partners.ts b/src/collections/Partners.ts new file mode 100644 index 0000000..06bbf9b --- /dev/null +++ b/src/collections/Partners.ts @@ -0,0 +1,57 @@ +import type { CollectionConfig } from 'payload' + +/** + * Partners collection: + * + * - name: partner name + * - partnerType: category of partner, using placeholder options until confirmed + * - logo: uploaded partner logo from the Media collection + * - websiteUrl: optional partner website link + * - isActive: controls whether this partner should be shown on the frontend + */ + +export const Partners: CollectionConfig = { + slug: 'partners', + + admin: { + useAsTitle: 'name', + defaultColumns: ['name', 'partnerType', 'websiteUrl', 'isActive'], + }, + + fields: [ + { + name: 'name', + type: 'text', + required: true, + }, + { + name: 'partnerType', + type: 'select', + label: 'Partner Type', + defaultValue: 'partner', + options: [ + // PLACEHOLDERS: Need to confirm with client about options + { label: 'Partner', value: 'partner' }, + { label: 'Sponsor', value: 'sponsor' }, + { label: 'Supporter', value: 'supporter' }, + ], + }, + { + name: 'logo', + type: 'upload', + relationTo: 'media', + required: true, + }, + { + name: 'websiteUrl', + type: 'text', + label: 'Website URL', + }, + { + name: 'isActive', + type: 'checkbox', + label: 'Active', + defaultValue: true, + }, + ], +} diff --git a/src/collections/Templates.ts b/src/collections/Templates.ts new file mode 100644 index 0000000..9fcba74 --- /dev/null +++ b/src/collections/Templates.ts @@ -0,0 +1,47 @@ +import type { Field } from 'payload' + +/** + * Payload field templates / examples + */ + +export const TextFieldExample: Field = { + name: 'title', // Data Fields have a `name` property. This is the key used to store the field's value + type: 'text', // Saves a string to the database and provides the Admin Panel with a simple text input +} + +// Select type: Provides a dropdown-style interface for choosing options from a predefined list +export const SelectFieldExample: Field = { + name: 'category', + type: 'select', + options: [ + { label: 'Blog', value: 'blog' }, + { label: 'Alumni Story', value: 'alumni_story' }, + ], +} + +// Upload type: Allows for the selection of a Document from a Collection supporting Uploads +export const UploadFieldExample: Field = { + name: 'logo', + type: 'upload', + relationTo: 'media', // Which collection this field links to (media in this case) +} + +// Array type: Used when you need to have a set of repeating Fields +export const ArrayFieldExample: Field = { + name: 'performances', + type: 'array', + fields: [ + { + name: 'dateTime', + type: 'date', + }, + { + name: 'venue', + type: 'text', + }, + { + name: 'bookingUrl', + type: 'text', + }, + ], +} diff --git a/src/payload-types.ts b/src/payload-types.ts index 4765db9..e90e259 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -69,6 +69,7 @@ export interface Config { collections: { users: User; media: Media; + partners: Partner; 'payload-kv': PayloadKv; 'payload-locked-documents': PayloadLockedDocument; 'payload-preferences': PayloadPreference; @@ -78,6 +79,7 @@ export interface Config { collectionsSelect: { users: UsersSelect | UsersSelect; media: MediaSelect | MediaSelect; + partners: PartnersSelect | PartnersSelect; 'payload-kv': PayloadKvSelect | PayloadKvSelect; 'payload-locked-documents': PayloadLockedDocumentsSelect | PayloadLockedDocumentsSelect; 'payload-preferences': PayloadPreferencesSelect | PayloadPreferencesSelect; @@ -161,6 +163,20 @@ export interface Media { focalX?: number | null; focalY?: number | null; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "partners". + */ +export interface Partner { + id: string; + name: string; + partnerType?: ('partner' | 'sponsor' | 'supporter') | null; + logo: string | Media; + websiteUrl?: string | null; + isActive?: boolean | null; + updatedAt: string; + createdAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-kv". @@ -192,6 +208,10 @@ export interface PayloadLockedDocument { | ({ relationTo: 'media'; value: string | Media; + } | null) + | ({ + relationTo: 'partners'; + value: string | Partner; } | null); globalSlug?: string | null; user: { @@ -275,6 +295,19 @@ export interface MediaSelect { focalX?: T; focalY?: T; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "partners_select". + */ +export interface PartnersSelect { + name?: T; + partnerType?: T; + logo?: T; + websiteUrl?: T; + isActive?: T; + updatedAt?: T; + createdAt?: T; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-kv_select". diff --git a/src/payload.config.ts b/src/payload.config.ts index e8474cd..d49c200 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -7,6 +7,7 @@ import sharp from 'sharp' import { Users } from './collections/Users' import { Media } from './collections/Media' +import { Partners } from './collections/Partners' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) @@ -18,7 +19,7 @@ export default buildConfig({ baseDir: path.resolve(dirname), }, }, - collections: [Users, Media], + collections: [Users, Media, Partners], editor: lexicalEditor(), secret: process.env.PAYLOAD_SECRET || '', typescript: {