Skip to content

Commit

Permalink
Add contact form block
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Sep 15, 2023
1 parent a8f7d53 commit d7c13c7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/rest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export const api = {
export async function getPageStaticProps(context) {
const props = await getPageProps(api, context);
return {
props,
props: props || {},
};
}
2 changes: 2 additions & 0 deletions apps/codeforafrica/src/pages/[...slugs].page.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions apps/codeforafrica/src/payload/blocks/ContactForm.js
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 9 additions & 1 deletion apps/codeforafrica/src/payload/collections/Pages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ContactForm from "../blocks/ContactForm";
import CustomPageHeader from "../blocks/CustomPageHeader";
import Error from "../blocks/Error";
import Hero from "../blocks/Hero";
Expand Down Expand Up @@ -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,
},
Expand Down

0 comments on commit d7c13c7

Please sign in to comment.