Skip to content

Commit

Permalink
Add Our offices
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed Oct 9, 2023
1 parent 3121a87 commit b5a54a4
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const OfficeAddressesRoot = styled(Box)(({ theme, ownerState }) => ({
}));

const OfficeAddresses = React.forwardRef(function OfficeAddresses(props, ref) {
const { addresses = [], height = 700, map, title, apiKey, ...other } = props;
const { addresses = [], height = 700, map, title } = props;
const [activeAddress, setActiveAddress] = React.useState(
addresses?.[0] ?? null,
);
Expand All @@ -33,13 +33,8 @@ const OfficeAddresses = React.forwardRef(function OfficeAddresses(props, ref) {
}
const ownerState = { height };
const mapStyle = { height, width: "100%", ...map?.style };
const position = {
lng: activeAddress?.location?.[0],
lat: activeAddress?.location?.[1],
};
return (
<OfficeAddressesRoot
{...other}
sx={{ mt: { xs: 2.5, md: 10 } }}
ownerState={ownerState}
ref={ref}
Expand All @@ -55,13 +50,7 @@ const OfficeAddresses = React.forwardRef(function OfficeAddresses(props, ref) {
zIndex: -1,
}}
>
<GoogleMap
{...map}
{...activeAddress}
position={position}
center={position}
style={mapStyle}
/>
<GoogleMap {...map} {...activeAddress} style={mapStyle} />
</Box>
<Section
sx={{
Expand Down
2 changes: 2 additions & 0 deletions apps/codeforafrica/src/lib/data/blockify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import getInvolved from "./get-involved";
import hero from "./hero";
import meetOurTeam from "./meetOurTeam";
import ourImpact from "./our-impact";
import ourOffices from "./ourOffices";
import ourTeam from "./ourTeam";
import ourWork from "./ourWork";
import posts from "./posts";
Expand All @@ -17,6 +18,7 @@ const propsifyBlockBySlug = {
"our-impact": ourImpact,
"our-team": ourTeam,
"our-work": ourWork,
"our-offices": ourOffices,
// post-list to avoid conflict with posts collection in payload
"post-list": posts,
};
Expand Down
30 changes: 30 additions & 0 deletions apps/codeforafrica/src/lib/data/blockify/ourOffices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function ourOffices(block) {
const addresses = block.addresses.map((item) => ({
...item,
position: {
lng: item?.location?.[0],
lat: item?.location?.[1],
},
center: {
lng: item?.location?.[0],
lat: item?.location?.[1],
},
}));
return {
...block,
slug: block.blockType,
addresses,
map: {
apiKey: process.env.GOOGLE_API_KEY ?? null,
zoom: 20,
zoomControl: false,
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
rotateControl: false,
fullscreenControl: false,
},
};
}

export default ourOffices;
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/pages/[...slugs].page.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const componentsBySlugs = {
"our-guiding-principles": GuidingPrinciplesCardList,
"our-impact": OurImpact,
"our-mission": OurMission,
"our-address": OfficeAddresses,
"our-offices": OfficeAddresses,
"our-partners": OurPartners,
"our-team": OurTeam,
"our-work": Projects,
Expand Down
29 changes: 0 additions & 29 deletions apps/codeforafrica/src/payload/blocks/OurAddress.js

This file was deleted.

19 changes: 19 additions & 0 deletions apps/codeforafrica/src/payload/blocks/OurOffices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const OurOffices = {
slug: "our-offices",
fields: [
{
name: "title",
type: "text",
required: true,
},
{
type: "relationship",
relationTo: "locations",
hasMany: true,
name: "addresses",
required: true,
},
],
};

export default OurOffices;
4 changes: 2 additions & 2 deletions apps/codeforafrica/src/payload/collections/Pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import GuidingPrinciples from "../blocks/GuidingPrinciples";
import Hero from "../blocks/Hero";
import JoinOurSlack from "../blocks/JoinOurSlack";
import MeetOurTeam from "../blocks/MeetOurTeam";
import OurAddress from "../blocks/OurAddress";
import OurImpact from "../blocks/OurImpact";
import OurMission from "../blocks/OurMission";
import OurOffices from "../blocks/OurOffices";
import OurPartners from "../blocks/OurPartners";
import OurTeam from "../blocks/OurTeam";
import OurWork from "../blocks/OurWork";
Expand Down Expand Up @@ -64,7 +64,7 @@ const Pages = {
PageHeader,
Posts,
CustomPageHeader,
OurAddress,
OurOffices,
OurImpact,
OurMission,
OurPartners,
Expand Down

0 comments on commit b5a54a4

Please sign in to comment.