diff --git a/apps/codeforafrica/public/images/cms/blocks/contact_form.jpg b/apps/codeforafrica/public/images/cms/blocks/contact_form.jpg new file mode 100644 index 000000000..06aeb1bc6 Binary files /dev/null and b/apps/codeforafrica/public/images/cms/blocks/contact_form.jpg differ diff --git a/apps/codeforafrica/src/lib/data/rest/index.js b/apps/codeforafrica/src/lib/data/rest/index.js index 80c11bb13..b74fd48d6 100644 --- a/apps/codeforafrica/src/lib/data/rest/index.js +++ b/apps/codeforafrica/src/lib/data/rest/index.js @@ -37,6 +37,6 @@ export const api = { export async function getPageStaticProps(context) { const props = await getPageProps(api, context); return { - props, + props: props || {}, }; } diff --git a/apps/codeforafrica/src/pages/[...slugs].page.js b/apps/codeforafrica/src/pages/[...slugs].page.js index 4557ba5fa..4ea31a5ab 100644 --- a/apps/codeforafrica/src/pages/[...slugs].page.js +++ b/apps/codeforafrica/src/pages/[...slugs].page.js @@ -1,6 +1,7 @@ import React from "react"; import { SWRConfig } from "swr"; +import ContactForm from "@/codeforafrica/components/ContactForm"; import CustomPageHeader from "@/codeforafrica/components/CustomPageHeader"; import FeaturedProjects from "@/codeforafrica/components/FeaturedProjects"; import GetInvolved from "@/codeforafrica/components/GetInvolved"; @@ -14,6 +15,7 @@ import { getPageServerSideProps } from "@/codeforafrica/lib/data"; const componentsBySlugs = { hero: Hero, "page-header": PageHeader, + "contact-form": ContactForm, "custom-page-header": CustomPageHeader, "meet-our-team": MeetOurTeam, "news-stories": NewsAndStories, diff --git a/apps/codeforafrica/src/payload/blocks/ContactForm.js b/apps/codeforafrica/src/payload/blocks/ContactForm.js new file mode 100644 index 000000000..6d3c01832 --- /dev/null +++ b/apps/codeforafrica/src/payload/blocks/ContactForm.js @@ -0,0 +1,18 @@ +const ContactForm = { + slug: "contact-form", + imageURL: "/images/cms/blocks/contact_form.jpg", + imageAltText: "Contact From Code", + fields: [ + { + name: "embedCode", + type: "code", + label: "Embed Code", + required: true, + admin: { + language: "html", + }, + }, + ], +}; + +export default ContactForm; diff --git a/apps/codeforafrica/src/payload/collections/Pages.js b/apps/codeforafrica/src/payload/collections/Pages.js index a8e034e7b..0c72bd215 100644 --- a/apps/codeforafrica/src/payload/collections/Pages.js +++ b/apps/codeforafrica/src/payload/collections/Pages.js @@ -1,3 +1,4 @@ +import ContactForm from "../blocks/ContactForm"; import CustomPageHeader from "../blocks/CustomPageHeader"; import Error from "../blocks/Error"; import Hero from "../blocks/Hero"; @@ -37,7 +38,14 @@ const Pages = { // each other e.g. while alphabecially CustomPageHeader should be with C, // it's functiaonally equivalent with PageHeader so we keep it next to // PageHeader - blocks: [Error, Hero, PageHeader, CustomPageHeader, OurPartners], + blocks: [ + ContactForm, + Error, + Hero, + PageHeader, + CustomPageHeader, + OurPartners, + ], admin: { initCollapsed: true, },