Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions payload.config.ts

This file was deleted.

57 changes: 57 additions & 0 deletions src/collections/Partners.ts
Original file line number Diff line number Diff line change
@@ -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,
},
],
}
47 changes: 47 additions & 0 deletions src/collections/Templates.ts
Original file line number Diff line number Diff line change
@@ -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',
},
],
}
33 changes: 33 additions & 0 deletions src/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface Config {
collections: {
users: User;
media: Media;
partners: Partner;
'payload-kv': PayloadKv;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
Expand All @@ -78,6 +79,7 @@ export interface Config {
collectionsSelect: {
users: UsersSelect<false> | UsersSelect<true>;
media: MediaSelect<false> | MediaSelect<true>;
partners: PartnersSelect<false> | PartnersSelect<true>;
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
Expand Down Expand Up @@ -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".
Expand Down Expand Up @@ -192,6 +208,10 @@ export interface PayloadLockedDocument {
| ({
relationTo: 'media';
value: string | Media;
} | null)
| ({
relationTo: 'partners';
value: string | Partner;
} | null);
globalSlug?: string | null;
user: {
Expand Down Expand Up @@ -275,6 +295,19 @@ export interface MediaSelect<T extends boolean = true> {
focalX?: T;
focalY?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "partners_select".
*/
export interface PartnersSelect<T extends boolean = true> {
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".
Expand Down
3 changes: 2 additions & 1 deletion src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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: {
Expand Down
Loading