Skip to content

Commit 614663e

Browse files
Merge pull request #434 from CodeForAfrica/latest_promises
Add Promises block and latest promises block
2 parents bda9f6c + a194a97 commit 614663e

File tree

31 files changed

+1279
-13
lines changed

31 files changed

+1279
-13
lines changed

public/cms/latest-promises.png

15.5 KB
Loading

public/cms/promises-list.png

24 KB
Loading

src/assets/footer-social-fb.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/footer-social-ln.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/footer-social-tw.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/share-icon.svg

Lines changed: 1 addition & 0 deletions
Loading

src/blocks/LatestPromises/index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Block } from "payload";
2+
3+
const LatestPromises: Block = {
4+
slug: "latest-promises",
5+
imageURL: "/cms/latest-promises.png",
6+
labels: {
7+
singular: "Latest Promise",
8+
plural: "Latest Promises",
9+
},
10+
fields: [
11+
{
12+
name: "title",
13+
type: "text",
14+
required: true,
15+
localized: true,
16+
},
17+
{
18+
name: "seeAllLink",
19+
type: "text",
20+
required: false,
21+
localized: true,
22+
admin: {
23+
description:
24+
"Link to the page where all promises can be viewed. E.g. /promises",
25+
},
26+
},
27+
],
28+
};
29+
30+
export default LatestPromises;

src/blocks/PromiseList.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { Block } from "payload";
2+
3+
const PromiseList: Block = {
4+
slug: "promise-list",
5+
imageURL: "/cms/promises-list.png",
6+
labels: {
7+
singular: "Promise List",
8+
plural: "Promise Lists",
9+
},
10+
fields: [
11+
{
12+
name: "title",
13+
type: "text",
14+
required: false,
15+
localized: false,
16+
},
17+
{
18+
name: "filterByLabel",
19+
type: "text",
20+
required: false,
21+
localized: true,
22+
defaultValue: "Filter By",
23+
},
24+
{
25+
name: "sortByLabel",
26+
type: "text",
27+
required: false,
28+
localized: true,
29+
defaultValue: "Sort By",
30+
},
31+
{
32+
name: "filterBy",
33+
type: "select",
34+
hasMany: true,
35+
options: [
36+
{
37+
label: "Status",
38+
value: "status",
39+
},
40+
{
41+
label: "Category",
42+
value: "category",
43+
},
44+
],
45+
defaultValue: "status",
46+
required: false,
47+
localized: false,
48+
},
49+
{
50+
name: "sortBy",
51+
type: "select",
52+
hasMany: true,
53+
54+
options: [
55+
{
56+
label: "Most Recent",
57+
value: "mostRecent",
58+
},
59+
{
60+
label: "Deadline",
61+
value: "deadline",
62+
},
63+
],
64+
defaultValue: "mostRecent",
65+
required: false,
66+
localized: false,
67+
},
68+
],
69+
};
70+
71+
export default PromiseList;

src/collections/Pages/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { ensureUniqueSlug } from "./hooks/ensureUniqueSlug";
33
import newsletterSettingsToBlock from "./hooks/newsletterSettingsToBlock";
44
import Partners from "@/blocks/Partners";
55
import Newsletter from "@/blocks/Newsletter";
6+
import LatestPromises from "@/blocks/LatestPromises";
7+
import PromiseList from "@/blocks/PromiseList";
68
import { slugField } from "@/fields/slug";
79
import { KeyPromises } from "@/blocks/KeyPromises";
810
import { ActNow } from "@/blocks/ActNow";
@@ -41,7 +43,15 @@ export const Pages: CollectionConfig = {
4143
{
4244
name: "blocks",
4345
type: "blocks",
44-
blocks: [ActNow, Hero, Newsletter, Partners, KeyPromises],
46+
blocks: [
47+
ActNow,
48+
Hero,
49+
Newsletter,
50+
Partners,
51+
LatestPromises,
52+
PromiseList,
53+
KeyPromises,
54+
],
4555
},
4656
],
4757
hooks: {

src/components/BlockRenderer.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@ import { Fragment } from "react";
44
import { KeyPromises } from "./KeyPromises";
55
import Newsletter from "./Newsletter";
66
import Partners from "./Partners";
7+
import LatestPromises from "./LatestPromises";
78
import { Hero } from "./Hero";
9+
import Promises from "./Promises";
810

911
type BlockProps = {
1012
blocks: Page["blocks"];
1113
entity?: PoliticalEntity;
1214
};
1315

14-
const blockComponents = {
16+
const blockComponents: Record<string, React.FC<any>> = {
1517
"act-now": ActNow,
1618
hero: Hero,
1719
newsletter: Newsletter,
1820
partners: Partners,
21+
"latest-promises": LatestPromises,
22+
"promise-list": Promises,
1923
"key-promises": KeyPromises,
2024
};
25+
2126
export const BlockRenderer = ({ blocks, entity }: BlockProps) => {
2227
const hasBlocks = blocks && Array.isArray(blocks) && blocks.length > 0;
2328

@@ -31,7 +36,6 @@ export const BlockRenderer = ({ blocks, entity }: BlockProps) => {
3136
if (Block) {
3237
return (
3338
<div key={index}>
34-
{/* @ts-expect-error there may be some mismatch between the expected types here */}
3539
<Block {...block} entitySlug={entity?.slug} />
3640
</div>
3741
);

0 commit comments

Comments
 (0)