Skip to content

Commit

Permalink
Fix validations for fields in charter Africa
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed Sep 11, 2024
1 parent b10d351 commit d78354b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
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.
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
61 changes: 33 additions & 28 deletions apps/charterafrica/src/payload/globals/Footer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
import { slateEditor } from "@payloadcms/richtext-slate";
import { text, array } from "payload/dist/fields/validations";
import { text, select } from "payload/dist/fields/validations";

import linkArray from "../fields/linkArray";
import richText from "../fields/richText";

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",
access: {
Expand Down Expand Up @@ -120,32 +147,7 @@ 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: {
Expand All @@ -160,7 +162,10 @@ const Footer = {
) {
return t("charterafrica.site:uniqueMedia");
}
return array(val, options);
return select(val, {
...options,
options: socialMediaOptions,
});
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions apps/charterafrica/src/payload/globals/Settings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { array } from "payload/dist/fields/validations";
import { select } from "payload/dist/fields/validations";

import { locales } from "../utils/locales";

Expand Down Expand Up @@ -85,7 +85,7 @@ const Settings = {
) {
return t("charterafrica.site:uniqueLocales");
}
return array(val, options);
return select(val, { ...options, options: locales });
},
},
{
Expand Down

0 comments on commit d78354b

Please sign in to comment.