diff --git a/apps/charterafrica/contrib/dokku/Dockerfile b/apps/charterafrica/contrib/dokku/Dockerfile index b59a2e385..481de4776 100644 --- a/apps/charterafrica/contrib/dokku/Dockerfile +++ b/apps/charterafrica/contrib/dokku/Dockerfile @@ -1 +1 @@ -FROM codeforafrica/charterafrica-ui:0.1.30 +FROM codeforafrica/charterafrica-ui:0.1.31 diff --git a/apps/charterafrica/next-env.d.ts b/apps/charterafrica/next-env.d.ts index 4f11a03dc..a4a7b3f5c 100644 --- a/apps/charterafrica/next-env.d.ts +++ b/apps/charterafrica/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information. diff --git a/apps/charterafrica/package.json b/apps/charterafrica/package.json index b6fca2c7a..6af5bfbbd 100644 --- a/apps/charterafrica/package.json +++ b/apps/charterafrica/package.json @@ -1,6 +1,6 @@ { "name": "charterafrica", - "version": "0.1.30", + "version": "0.1.31", "private": true, "author": "Code for Africa ", "description": "This is the official code for https://charter.africa site", diff --git a/apps/charterafrica/src/payload/globals/FocalCountries.js b/apps/charterafrica/src/payload/globals/FocalCountries.js index 6a48011c2..660c73bd8 100644 --- a/apps/charterafrica/src/payload/globals/FocalCountries.js +++ b/apps/charterafrica/src/payload/globals/FocalCountries.js @@ -1,5 +1,5 @@ import { slateEditor } from "@payloadcms/richtext-slate"; -import { array } from "payload/dist/fields/validations"; +import { text } from "payload/dist/fields/validations"; import linkGroup from "../fields/linkGroup"; import richText from "../fields/richText"; @@ -67,7 +67,7 @@ const FocalCountries = { ) { return t("charterafrica.site:uniqueCountries"); } - return array(val, options); + return text(val, options); }, admin: { width: "50%", diff --git a/apps/charterafrica/src/payload/globals/Footer.js b/apps/charterafrica/src/payload/globals/Footer.js index af6251078..ced5131f4 100644 --- a/apps/charterafrica/src/payload/globals/Footer.js +++ b/apps/charterafrica/src/payload/globals/Footer.js @@ -1,8 +1,36 @@ import { slateEditor } from "@payloadcms/richtext-slate"; -import { text, array } from "payload/dist/fields/validations"; +import { text } from "payload/dist/fields/validations"; import linkArray from "../fields/linkArray"; import richText from "../fields/richText"; +import validateUniqueArrayFieldSelect from "../utils/validateUniqueArrayFieldSelect"; + +const socialMediaOptions = [ + { + value: "facebook", + label: "Facebook", + }, + { + value: "github", + label: "Github", + }, + { + value: "instagram", + label: "Instagram", + }, + { + value: "linkedin", + label: "LinkedIn", + }, + { + value: "slack", + label: "Slack", + }, + { + value: "twitter", + label: "Twitter", + }, +]; const Footer = { slug: "footer", @@ -120,48 +148,19 @@ const Footer = { pt: "Media", }, type: "select", - options: [ - { - value: "facebook", - label: "Facebook", - }, - { - value: "github", - label: "Github", - }, - { - value: "instagram", - label: "Instagram", - }, - { - value: "linkedin", - label: "LinkedIn", - }, - { - value: "slack", - label: "Slack", - }, - { - value: "twitter", - label: "Twitter", - }, - ], + options: socialMediaOptions, unique: true, required: true, admin: { isClearable: false, isSortable: true, }, - validate: (val, options) => { - const { data, t } = options || {}; - if ( - data?.connect?.links?.filter((l) => l.media === val)?.length > - 1 - ) { - return t("charterafrica.site:uniqueMedia"); - } - return array(val, options); - }, + validate: validateUniqueArrayFieldSelect( + "links", + "media", + socialMediaOptions, + "charterafrica.site:uniqueMedia", + ), }, { name: "url", diff --git a/apps/charterafrica/src/payload/globals/Settings.js b/apps/charterafrica/src/payload/globals/Settings.js index 0263d0e4c..d5bbd7b24 100644 --- a/apps/charterafrica/src/payload/globals/Settings.js +++ b/apps/charterafrica/src/payload/globals/Settings.js @@ -1,6 +1,5 @@ -import { array } from "payload/dist/fields/validations"; - import { locales } from "../utils/locales"; +import validateUniqueArrayFieldSelect from "../utils/validateUniqueArrayFieldSelect"; const Settings = { slug: "settings", @@ -78,15 +77,12 @@ const Settings = { isClearable: false, isSortable: true, }, - validate: (val, options) => { - const { data, t } = options || {}; - if ( - data?.languages?.filter((l) => l.locale === val)?.length > 1 - ) { - return t("charterafrica.site:uniqueLocales"); - } - return array(val, options); - }, + validate: validateUniqueArrayFieldSelect( + "languages", + "locale", + locales, + "charterafrica.site:uniqueLocales", + ), }, { name: "label",