diff --git a/src/app/(payload)/admin/importMap.js b/src/app/(payload)/admin/importMap.js index 8ef7021..a3bc0e8 100644 --- a/src/app/(payload)/admin/importMap.js +++ b/src/app/(payload)/admin/importMap.js @@ -1 +1,5 @@ -export const importMap = {} + + +export const importMap = { + +} diff --git a/src/collections/Authors/Authors.ts b/src/collections/Authors/Authors.ts index 909b6d7..c1dde26 100644 --- a/src/collections/Authors/Authors.ts +++ b/src/collections/Authors/Authors.ts @@ -2,15 +2,37 @@ import type { CollectionConfig } from 'payload' export const Authors: CollectionConfig = { slug: 'authors', + admin: { + useAsTitle: 'lf' + }, + fields: [ { - name: 'firstName', + name: 'lf', + label: 'last, first name', + type: 'text', + required: true, + unique: true, + index: true, + }, + { + name: 'fl', + label: 'First and Last Name', type: 'text', }, { - name: 'lastName', - type: 'text', - required: true, - }, + name: "role", + type: 'select', + options: [ + { + label: 'Author', + value: 'Author' + }, + { + label: 'Translator', + value: 'Translator' + }, + ], + } ], } diff --git a/src/collections/Books/Books.ts b/src/collections/Books/Books.ts index 42722cd..88ec9c5 100644 --- a/src/collections/Books/Books.ts +++ b/src/collections/Books/Books.ts @@ -6,10 +6,22 @@ export const Books: CollectionConfig = { { name: "books_id", // This is from the import type: "text", + unique: true, + admin: { + placeholder: "This is only for books that have been imported.", + //readOnly: true, + } }, { name: "title", type: "text", }, + { + name: "authors", + type: "relationship", + relationTo: "authors", + hasMany: true, + maxDepth: 200, + } ], } diff --git a/src/payload-types.ts b/src/payload-types.ts index d3cacc9..2576947 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -69,6 +69,8 @@ export interface Config { collections: { users: User; media: Media; + books: Book; + authors: Author; 'payload-locked-documents': PayloadLockedDocument; 'payload-preferences': PayloadPreference; 'payload-migrations': PayloadMigration; @@ -77,6 +79,8 @@ export interface Config { collectionsSelect: { users: UsersSelect | UsersSelect; media: MediaSelect | MediaSelect; + books: BooksSelect | BooksSelect; + authors: AuthorsSelect | AuthorsSelect; 'payload-locked-documents': PayloadLockedDocumentsSelect | PayloadLockedDocumentsSelect; 'payload-preferences': PayloadPreferencesSelect | PayloadPreferencesSelect; 'payload-migrations': PayloadMigrationsSelect | PayloadMigrationsSelect; @@ -149,6 +153,30 @@ export interface Media { focalX?: number | null; focalY?: number | null; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "books". + */ +export interface Book { + id: number; + books_id?: string | null; + title?: string | null; + authors?: (number | Author)[] | null; + updatedAt: string; + createdAt: string; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "authors". + */ +export interface Author { + id: number; + lf: string; + fl?: string | null; + role?: ('Author' | 'Translator') | null; + updatedAt: string; + createdAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-locked-documents". @@ -163,6 +191,14 @@ export interface PayloadLockedDocument { | ({ relationTo: 'media'; value: number | Media; + } | null) + | ({ + relationTo: 'books'; + value: number | Book; + } | null) + | ({ + relationTo: 'authors'; + value: number | Author; } | null); globalSlug?: string | null; user: { @@ -239,6 +275,28 @@ export interface MediaSelect { focalX?: T; focalY?: T; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "books_select". + */ +export interface BooksSelect { + books_id?: T; + title?: T; + authors?: T; + updatedAt?: T; + createdAt?: T; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "authors_select". + */ +export interface AuthorsSelect { + lf?: T; + fl?: T; + role?: T; + updatedAt?: T; + createdAt?: T; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-locked-documents_select". diff --git a/src/payload.config.ts b/src/payload.config.ts index 5f2c20c..f844eb8 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -1,6 +1,5 @@ // storage-adapter-import-placeholder import { postgresAdapter } from '@payloadcms/db-postgres' -import { payloadCloudPlugin } from '@payloadcms/payload-cloud' import { lexicalEditor } from '@payloadcms/richtext-lexical' import path from 'path' import { buildConfig } from 'payload' @@ -9,6 +8,8 @@ import sharp from 'sharp' import { Users } from './collections/Users' import { Media } from './collections/Media' +import { Books } from './collections/Books/Books' +import { Authors } from './collections/Authors/Authors' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) @@ -19,8 +20,16 @@ export default buildConfig({ importMap: { baseDir: path.resolve(dirname), }, + dateFormat: 'MM/dd/yyyy', }, - collections: [Users, Media], + cors: [process.env.DOMAIN_NAME || ''], + csrf: [process.env.DOMAIN_NAME || ''], + upload: { + limits: { + fileSize: 5000000, // in bytes + }, + }, + collections: [Users, Media, Books, Authors], editor: lexicalEditor(), secret: process.env.PAYLOAD_SECRET || '', typescript: { @@ -33,7 +42,7 @@ export default buildConfig({ }), sharp, plugins: [ - payloadCloudPlugin(), + //payloadCloudPlugin(), // storage-adapter-placeholder ], })