diff --git a/src/collections/CommonEvents.ts b/src/collections/CommonEvents.ts new file mode 100644 index 0000000..06de98f --- /dev/null +++ b/src/collections/CommonEvents.ts @@ -0,0 +1,49 @@ +import { isEvents } from '@/access/isEvents'; +import type { CollectionConfig } from 'payload'; + +export const CommonEvents: CollectionConfig = { + slug: 'common-events', + admin: { + useAsTitle: 'name', + }, + fields: [ + { + name: 'name', + type: 'text', + required: true, + }, + { + name: 'description', + type: 'textarea', + required: false, + }, + { + name: 'upcomingDates', + type: 'array', + required: false, + fields: [ + { + name: 'date', + type: 'date', + required: true, + }, + { + name: 'notes', + type: 'text', + required: false, + }, + ], + minRows: 0, + maxRows: 50, + }, + ], + access: { + create: isEvents, + update: isEvents, + delete: isEvents, + read: () => true, + }, + versions: { + drafts: true, + }, +}; diff --git a/src/payload-types.ts b/src/payload-types.ts index 7b061a1..fd149c6 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -69,6 +69,7 @@ export interface Config { users: User; media: Media; events: Event; + 'common-events': CommonEvent; sponsors: Sponsor; 'tech-stack': TechStack; projects: Project; @@ -84,6 +85,7 @@ export interface Config { users: UsersSelect | UsersSelect; media: MediaSelect | MediaSelect; events: EventsSelect | EventsSelect; + 'common-events': CommonEventsSelect | CommonEventsSelect; sponsors: SponsorsSelect | SponsorsSelect; 'tech-stack': TechStackSelect | TechStackSelect; projects: ProjectsSelect | ProjectsSelect; @@ -135,10 +137,6 @@ export interface UserAuthOperations { /** This interface was referenced by `Config`'s JSON-Schema via the `definition` "users". */ export interface User { id: string; - email: string; - emailVerified?: string | null; - name?: string | null; - image?: string | null; /** Users can have one or many roles */ roles?: | ( @@ -152,16 +150,23 @@ export interface User { | 'exec' )[] | null; - accounts?: + updatedAt: string; + createdAt: string; + email: string; + resetPasswordToken?: string | null; + resetPasswordExpiration?: string | null; + salt?: string | null; + hash?: string | null; + loginAttempts?: number | null; + lockUntil?: string | null; + sessions?: | { - id?: string | null; - provider: string; - providerAccountId: string; - type: string; + id: string; + createdAt?: string | null; + expiresAt: string; }[] | null; - updatedAt: string; - createdAt: string; + password?: string | null; } /** This interface was referenced by `Config`'s JSON-Schema via the `definition` "media". */ export interface Media { @@ -216,6 +221,22 @@ export interface Event { createdAt: string; _status?: ('draft' | 'published') | null; } +/** This interface was referenced by `Config`'s JSON-Schema via the `definition` "common-events". */ +export interface CommonEvent { + id: string; + name: string; + description?: string | null; + upcomingDates?: + | { + date: string; + notes?: string | null; + id?: string | null; + }[] + | null; + updatedAt: string; + createdAt: string; + _status?: ('draft' | 'published') | null; +} /** * Please upload a banner image to media before filling in sponsor. * @@ -325,6 +346,10 @@ export interface PayloadLockedDocument { relationTo: 'events'; value: string | Event; } | null) + | ({ + relationTo: 'common-events'; + value: string | CommonEvent; + } | null) | ({ relationTo: 'sponsors'; value: string | Sponsor; @@ -393,22 +418,23 @@ export interface PayloadMigration { } /** This interface was referenced by `Config`'s JSON-Schema via the `definition` "users_select". */ export interface UsersSelect { - id?: T; - email?: T; - emailVerified?: T; - name?: T; - image?: T; roles?: T; - accounts?: + updatedAt?: T; + createdAt?: T; + email?: T; + resetPasswordToken?: T; + resetPasswordExpiration?: T; + salt?: T; + hash?: T; + loginAttempts?: T; + lockUntil?: T; + sessions?: | T | { id?: T; - provider?: T; - providerAccountId?: T; - type?: T; + createdAt?: T; + expiresAt?: T; }; - updatedAt?: T; - createdAt?: T; } /** This interface was referenced by `Config`'s JSON-Schema via the `definition` "media_select". */ export interface MediaSelect { @@ -450,6 +476,24 @@ export interface EventsSelect { createdAt?: T; _status?: T; } +/** + * This interface was referenced by `Config`'s JSON-Schema via the `definition` + * "common-events_select". + */ +export interface CommonEventsSelect { + name?: T; + description?: T; + upcomingDates?: + | T + | { + date?: T; + notes?: T; + id?: T; + }; + updatedAt?: T; + createdAt?: T; + _status?: T; +} /** This interface was referenced by `Config`'s JSON-Schema via the `definition` "sponsors_select". */ export interface SponsorsSelect { 'Company name'?: T; diff --git a/src/payload.config.ts b/src/payload.config.ts index d6b9b5b..f86d6fb 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -9,6 +9,7 @@ import sharp from 'sharp'; import { fileURLToPath } from 'url'; import { authConfig } from './auth.config'; import { CommitteeMembers } from './collections/CommitteeMembers'; +import { CommonEvents } from './collections/CommonEvents'; import { Events } from './collections/Events'; import { Gallery } from './collections/Gallery'; import { KnownSpamMessages } from './collections/KnownSpamMessages'; @@ -91,6 +92,7 @@ export default buildConfig({ Users, Media, Events, + CommonEvents, Sponsors, Tech_Stack, Projects,