-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #578 from CodeForAfrica/ft/codeforafrica-remove-st…
…aticprops Remove static props and fix layout
- Loading branch information
Showing
8 changed files
with
122 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,35 @@ | ||
import { Box } from "@mui/material"; | ||
|
||
import ErrorHero from "@/codeforafrica/components/ErrorHero"; | ||
import Page from "@/codeforafrica/components/Page"; | ||
import RelatedStories from "@/codeforafrica/components/RelatedStories"; | ||
|
||
function ErrorPage({ sections, ...props }) { | ||
return ( | ||
<Page {...props}> | ||
{sections?.map((section) => { | ||
switch (section.slug) { | ||
case "hero": | ||
return ( | ||
<ErrorHero | ||
title={section.title} | ||
subtitle={section.subtitle} | ||
key={section.slug} | ||
{...props} | ||
/> | ||
); | ||
case "news-stories": | ||
return ( | ||
<Box | ||
key={section.slug} | ||
sx={{ | ||
bgcolor: { xs: "inherit", sm: "background.default" }, | ||
}} | ||
> | ||
<RelatedStories | ||
{...section} | ||
sx={{ px: { xs: "20px", sm: 0 } }} | ||
/> | ||
</Box> | ||
); | ||
default: | ||
return null; | ||
} | ||
})} | ||
</Page> | ||
); | ||
return sections?.map((section) => { | ||
switch (section.slug) { | ||
case "hero": | ||
return ( | ||
<ErrorHero | ||
title={section.title} | ||
subtitle={section.subtitle} | ||
key={section.slug} | ||
{...props} | ||
/> | ||
); | ||
case "news-stories": | ||
return ( | ||
<Box | ||
key={section.slug} | ||
sx={{ | ||
bgcolor: { xs: "inherit", sm: "background.default" }, | ||
}} | ||
> | ||
<RelatedStories {...section} sx={{ px: { xs: "20px", sm: 0 } }} /> | ||
</Box> | ||
); | ||
default: | ||
return null; | ||
} | ||
}); | ||
} | ||
|
||
export default ErrorPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import payload from "payload"; | ||
|
||
async function findPage(slug, options) { | ||
return payload.find({ | ||
...options, | ||
collection: "pages", | ||
where: { | ||
...options?.where, | ||
slug: { | ||
equals: slug, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
async function getCollection(collection, options) { | ||
return payload.find({ | ||
limit: 0, | ||
...options, | ||
collection, | ||
}); | ||
} | ||
|
||
async function findGlobal(slug, options) { | ||
return payload.findGlobal({ | ||
...options, | ||
slug, | ||
}); | ||
} | ||
|
||
async function createCollection(collection, data, options) { | ||
return payload.create({ | ||
collection, | ||
data, | ||
...options, | ||
}); | ||
} | ||
|
||
async function deleteCollection(collection, options) { | ||
return payload.delete({ | ||
...options, | ||
collection, | ||
}); | ||
} | ||
|
||
async function updateCollection(collection, id, data, options) { | ||
const args = { | ||
...options, | ||
collection, | ||
id, | ||
data, | ||
}; | ||
return payload.update(args); | ||
} | ||
const api = { | ||
createCollection, | ||
deleteCollection, | ||
findGlobal, | ||
findPage, | ||
getCollection, | ||
updateCollection, | ||
}; | ||
|
||
export default api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`/404 renders unchanged 1`] = ` | ||
<div> | ||
<main /> | ||
</div> | ||
`; | ||
exports[`/404 renders unchanged 1`] = `<div />`; |