From b1d24de3ee4a2ea729ca4238f624b96b83e2974a Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Tue, 19 Sep 2023 12:46:17 +0300 Subject: [PATCH] Add published on field --- .../src/payload/fields/publishedOn.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 apps/codeforafrica/src/payload/fields/publishedOn.js diff --git a/apps/codeforafrica/src/payload/fields/publishedOn.js b/apps/codeforafrica/src/payload/fields/publishedOn.js new file mode 100644 index 000000000..f735543a8 --- /dev/null +++ b/apps/codeforafrica/src/payload/fields/publishedOn.js @@ -0,0 +1,22 @@ +import { deepmerge } from "@mui/utils"; + +const publishedOn = (overrides) => + deepmerge( + { + name: "publishedOn", + type: "date", + required: true, + hooks: { + beforeValidate: [({ value }) => (value ? new Date(value) : new Date())], + }, + admin: { + date: { + pickerAppearance: "dayAndTime", + }, + position: "sidebar", + }, + }, + overrides, + ); + +export default publishedOn;