-
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 #116 from samvera/user-profile-cms
Include content from Contentful for Samvera User Profiles
- Loading branch information
Showing
5 changed files
with
100 additions
and
165 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from "react"; | ||
|
||
const Card = ({ header, children, className }) => { | ||
return ( | ||
<div | ||
key={header} | ||
className={`overflow-hidden bg-white divide-y divide-gray-200 rounded-lg shadow ${className}`} | ||
> | ||
{header && <h3 className="px-4 py-5 sm:px-6">{header}</h3>} | ||
<div className="px-4 py-5 sm:p-6">{children}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Card; |
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,73 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
import Breadcrumbs from "components/Breadcrumbs"; | ||
import Card from "components/layout/Card"; | ||
import Layout from "../layout/Layout"; | ||
import Main from "components/layout/Main"; | ||
import MarkdownContent from "components/MarkdownContent"; | ||
import RichTextContent from "components/RichTextContent"; | ||
import getContentful from "lib/get-contentful"; | ||
|
||
function classNames(...classes) { | ||
return classes.filter(Boolean).join(" "); | ||
} | ||
|
||
export default function UserProfilesPage({ config, content, frontmatter }) { | ||
const contentful = getContentful(); | ||
const [userProfiles, setUserProfiles] = useState([]); | ||
|
||
useEffect(() => { | ||
async function fetchData() { | ||
const userProfiles = await contentful.getEntries({ | ||
content_type: "userProfile", | ||
}); | ||
|
||
if (!userProfiles.items) { | ||
return console.error("Error getting userProfiles."); | ||
} | ||
setUserProfiles(userProfiles.items); | ||
} | ||
|
||
fetchData(); | ||
}, [contentful]); | ||
console.log("userProfiles", userProfiles); | ||
|
||
return ( | ||
<Layout title={`${frontmatter.title} - ${config.parentDirLabel} - Samvera`}> | ||
<Breadcrumbs | ||
items={[ | ||
{ | ||
href: "/", | ||
label: config.parentDirLabel, | ||
}, | ||
{ | ||
label: frontmatter.title, | ||
}, | ||
]} | ||
/> | ||
|
||
<h1>{frontmatter.title}</h1> | ||
|
||
<MarkdownContent content={content} /> | ||
<Main> | ||
<h2>Community Profiles</h2> | ||
{userProfiles | ||
.filter((user) => !user.fields.isManager) | ||
.map(({ fields: { title, content } }, actionIdx) => ( | ||
<Card key={title} header={title} className="mb-10"> | ||
<RichTextContent content={content} /> | ||
</Card> | ||
))} | ||
|
||
<h2 className="pt-12">Manager Profiles</h2> | ||
{userProfiles | ||
.filter((user) => user.fields.isManager) | ||
.map(({ fields: { title, content } }, actionIdx) => ( | ||
<Card key={title} header={title} className="mb-10"> | ||
<RichTextContent content={content} /> | ||
</Card> | ||
))} | ||
</Main> | ||
</Layout> | ||
); | ||
} |
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