From e154bff4e4364ad4319c573564c3e625cb30e8e7 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 22 Jul 2022 05:54:33 +0100 Subject: [PATCH] Events collection should only use two date/time fields; turn off timestaps for collections --- src/collections/EventTypes.ts | 1 + src/collections/Events.ts | 53 ++++++++--------------------------- src/payload-types.ts | 6 ---- 3 files changed, 13 insertions(+), 47 deletions(-) diff --git a/src/collections/EventTypes.ts b/src/collections/EventTypes.ts index 27c9d3f..5441456 100644 --- a/src/collections/EventTypes.ts +++ b/src/collections/EventTypes.ts @@ -5,6 +5,7 @@ const EventTypes: CollectionConfig = { admin: { useAsTitle: 'name' }, + timestamps: false, fields: [ { name: 'name', diff --git a/src/collections/Events.ts b/src/collections/Events.ts index 8c508f2..3f11e84 100644 --- a/src/collections/Events.ts +++ b/src/collections/Events.ts @@ -5,6 +5,7 @@ const Events: CollectionConfig = { admin: { useAsTitle: 'name' }, + timestamps: false, fields: [ { name: 'name', @@ -25,24 +26,26 @@ const Events: CollectionConfig = { type: 'row', fields: [ { - name: 'startDate', - label: 'Start Date', + name: 'startTime', + label: 'Start Time', type: 'date', required: true, admin: { width: '50%', date: { - pickerAppearance: 'dayOnly' + displayFormat: 'MMM d, yyy HH:mm', + timeFormat: 'HH:mm', + timeIntervals: 15 } } }, { - name: 'endDate', - label: 'End Date', + name: 'endTime', + label: 'End Time', type: 'date', validate: (val, { siblingData }) => { const end = new Date(val).getTime(); - const start = new Date(siblingData.startDate).getTime(); + const start = new Date(siblingData.startTime).getTime(); if (end >= start) return true; @@ -52,41 +55,9 @@ const Events: CollectionConfig = { admin: { width: '50%', date: { - pickerAppearance: 'dayOnly' - } - } - } - ] - }, - { - type: 'row', - fields: [ - { - name: 'startTime', - label: 'Start Time', - type: 'date', - required: true, - admin: { - width: '50%', - date: { - pickerAppearance: 'timeOnly', - timeIntervals: 15, - displayFormat: 'HH:mm', - timeFormat: 'HH:mm' - } - } - }, - { - name: 'endTime', - label: 'End Time', - type: 'date', - admin: { - width: '50%', - date: { - pickerAppearance: 'timeOnly', - timeIntervals: 15, - displayFormat: 'HH:mm', - timeFormat: 'HH:mm' + displayFormat: 'MMM d, yyy HH:mm', + timeFormat: 'HH:mm', + timeIntervals: 15 } } } diff --git a/src/payload-types.ts b/src/payload-types.ts index ca641c2..a20d50d 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -27,8 +27,6 @@ export interface User { export interface EventType { id: string; name: string; - createdAt: string; - updatedAt: string; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -41,10 +39,6 @@ export interface Event { value: string | EventType; relationTo: 'event-types'; }; - startDate: string; - endDate?: string; startTime: string; endTime?: string; - createdAt: string; - updatedAt: string; }