Skip to content

Commit

Permalink
Add published on field
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Sep 19, 2023
1 parent 3976618 commit b1d24de
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions apps/codeforafrica/src/payload/fields/publishedOn.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit b1d24de

Please sign in to comment.