Skip to content

Commit

Permalink
Merge pull request #883 from CodeForAfrica/fix-charterafrica-issues
Browse files Browse the repository at this point in the history
Fix charterafrica issues
  • Loading branch information
koechkevin authored Sep 11, 2024
2 parents b10d351 + 5015187 commit bb06b0d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 53 deletions.
2 changes: 1 addition & 1 deletion apps/charterafrica/contrib/dokku/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM codeforafrica/charterafrica-ui:0.1.30
FROM codeforafrica/charterafrica-ui:0.1.31
2 changes: 1 addition & 1 deletion apps/charterafrica/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// 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.
2 changes: 1 addition & 1 deletion apps/charterafrica/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "charterafrica",
"version": "0.1.30",
"version": "0.1.31",
"private": true,
"author": "Code for Africa <[email protected]>",
"description": "This is the official code for https://charter.africa site",
Expand Down
4 changes: 2 additions & 2 deletions apps/charterafrica/src/payload/globals/FocalCountries.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -67,7 +67,7 @@ const FocalCountries = {
) {
return t("charterafrica.site:uniqueCountries");
}
return array(val, options);
return text(val, options);
},
admin: {
width: "50%",
Expand Down
73 changes: 36 additions & 37 deletions apps/charterafrica/src/payload/globals/Footer.js
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
18 changes: 7 additions & 11 deletions apps/charterafrica/src/payload/globals/Settings.js
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit bb06b0d

Please sign in to comment.