Skip to content

Commit

Permalink
Add summary profile to firestore model (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedidiahC authored Jul 23, 2023
1 parent 5171a0e commit f6a697e
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "firebase/firestore";
import { db } from "../../../services/firebase/firebaseConfig";
import { Collections } from "../../../services/firebase/names";
import { Social } from "../../../features/organisation-profile/components/summary";
import { Social } from "../organisationSummary";

export interface IPeopleSpotlight {
name: string;
Expand Down
35 changes: 29 additions & 6 deletions src/data/model/organisationSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,49 @@ import {
} from "firebase/firestore";
import { db } from "../../services/firebase/firebaseConfig";
import { Collections } from "../../services/firebase/names";
import { SocialType } from "../enums/social-type.enum";

export type Social = {
socialType: SocialType;
url: string;
};

export interface IOrganisationSummary {
videoUrl?: string;
websiteUrl?: string;
donationUrl?: string;
mission?: string;
email?: string;
socials?: Social[];
}

export class OrganisationSummary implements IOrganisationSummary {
orgId: string;
videoUrl?: string;
videoUrl: string;
websiteUrl: string;
donationUrl?: string;

donationUrl: string;
mission: string;
email: string;
socials: Social[];

// potentially create reference to parent organisation object, if queries require it

constructor(
_orgId: string,
_videoUrl: string,
_websiteUrl: string,
_videoUrl?: string,
_donationUrl?: string
_donationUrl: string,
_mission: string,
_email: string,
_socials: Social[]
) {
this.orgId = _orgId;
this.videoUrl = _videoUrl;
this.websiteUrl = _websiteUrl;
this.donationUrl = _donationUrl;
this.mission = _mission;
this.email = _email;
this.socials = _socials ?? [];
}

toString() {
Expand All @@ -49,6 +66,9 @@ export const organisationSummaryConverter: FirestoreDataConverter<OrganisationSu
videoUrl: data.videoUrl,
websiteUrl: data.websiteUrl,
donationUrl: data.donationUrl,
mission: data.mission,
email: data.email,
socials: data.socials
};
},
fromFirestore(
Expand All @@ -60,7 +80,10 @@ export const organisationSummaryConverter: FirestoreDataConverter<OrganisationSu
snapshot.id,
data.videoUrl,
data.websiteUrl,
data.donationUrl
data.donationUrl,
data.mission,
data.email,
data.socials
);
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/features/common/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
} from "@chakra-ui/react";
import "../page-style.scss";
import { SocialType } from "../../data/enums/social-type.enum";
import { Social } from "../organisation-profile/components/summary";
import { GetIconForSocials } from "../../utilities/icon-mappings";
import { Social } from "../../data/model/organisationSummary";

const Footer: React.FC = () => {
const socials: Social[] = [
Expand Down
84 changes: 83 additions & 1 deletion src/features/firestore-mock/test-data/test-organisations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export const testOrg1Summary: IOrganisationSummary = {
videoUrl: "https://youtu.be/oznr-1-poSU",
websiteUrl: faker.internet.url(),
donationUrl: faker.internet.url(),
mission: "Advocacy group that hopes to empower youth with practical, hands on and holistic self-care strategies.",
email: faker.internet.email(),
socials: [
{
socialType: SocialType.Youtube,
url: "https://www.youtube.com/",
}
]
};

export const testOrg1OurStory: IProfileContent[] = [
Expand Down Expand Up @@ -142,6 +150,31 @@ export const testOrg2Summary: IOrganisationSummary = {
videoUrl: "https://youtu.be/oznr-1-poSU",
websiteUrl: faker.internet.url(),
donationUrl: faker.internet.url(),
mission:
"Non-profit society providing support services, cohesion activities and community for those struggling with OCD.",
email: faker.internet.email(),
socials: [
{
socialType: SocialType.Youtube,
url: "https://www.youtube.com/",
},
{
socialType: SocialType.Facebook,
url: "https://www.facebook.com/",
},
{
socialType: SocialType.LinkedIn,
url: "https://www.linkedin.com/",
},
{
socialType: SocialType.Instagram,
url: "https://www.instagram.com/",
},
{
socialType: SocialType.TikTok,
url: "https://www.tiktok.com/",
},
]
};

export const testOrg2OurStory: IProfileContent[] = [
Expand Down Expand Up @@ -258,6 +291,30 @@ export const testOrg3Summary: IOrganisationSummary = {
videoUrl: "https://youtu.be/oznr-1-poSU",
websiteUrl: faker.internet.url(),
donationUrl: faker.internet.url(),
mission: "Training provider and podcast commited to cultivating resilience and positive mental wellness.",
email: faker.internet.email(),
socials: [
{
socialType: SocialType.Youtube,
url: "https://www.youtube.com/",
},
{
socialType: SocialType.Facebook,
url: "https://www.facebook.com/",
},
{
socialType: SocialType.LinkedIn,
url: "https://www.linkedin.com/",
},
{
socialType: SocialType.Instagram,
url: "https://www.instagram.com/",
},
{
socialType: SocialType.TikTok,
url: "https://www.tiktok.com/",
},
]
};

export const testOrg3OurStory: IProfileContent[] = [
Expand Down Expand Up @@ -371,9 +428,34 @@ export const testOrg4: IOrganisation = {
};

export const testOrg4Summary: IOrganisationSummary = {
videoUrl: "https://youtu.be/oznr-1-poSU",
videoUrl: "https://www.youtube.com/embed/oznr-1-poSU",
websiteUrl: faker.internet.url(),
donationUrl: faker.internet.url(),
mission:
"We support the recovery journeys of persons with mental health challenges and encourage help seeking among those at risk.",
email: faker.internet.email(),
socials: [
{
socialType: SocialType.Youtube,
url: "https://www.youtube.com/",
},
{
socialType: SocialType.Facebook,
url: "https://www.facebook.com/",
},
{
socialType: SocialType.LinkedIn,
url: "https://www.linkedin.com/",
},
{
socialType: SocialType.Instagram,
url: "https://www.instagram.com/",
},
{
socialType: SocialType.TikTok,
url: "https://www.tiktok.com/",
},
]
};

export const testOrg4OurStory: IProfileContent[] = [
Expand Down
85 changes: 23 additions & 62 deletions src/features/organisation-profile/components/summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,13 @@ import { ReactComponent as ShieldCheckIcon } from "../../../assets/icons/checked
import { ReactComponent as LinkIcon } from "../../../assets/icons/link.svg";
import { ReactComponent as MailIcon } from "../../../assets/icons/mail.svg";
import "../scss/summary.scss";
import { SocialType } from "../../../data/enums/social-type.enum";
import {
GetIconForIssue,
GetIconForSocials,
} from "../../../utilities/icon-mappings";
import { Specialisation } from "../../../data/enums/specialisation.enum";

export type Social = {
socialType: SocialType;
url: string;
};

type SummaryProps = {
videoUrl: string;
name: string;
mission: string;
mentalHealthType: Specialisation; // maximum two focus areas
website: string;
email: string;
isApproved: boolean;
socials: Social[];
};
import { useEffect, useState } from "react";
import { Organisation } from "../../../data/model/organisation";
import { OrganisationSummary, getOrganisationSummary } from "../../../data/model/organisationSummary";

const iframeStyle = {
width: "100%",
Expand Down Expand Up @@ -67,41 +52,17 @@ const websiteButtonStyle = {
};

// TODO add input of type SummaryProps
const Summary: React.FC = () => {
const testDetails: SummaryProps = {
videoUrl: "https://www.youtube.com/embed/oznr-1-poSU",
name: "Resilience Collective (RC)",
mission:
"We support the recovery journeys of persons with mental health challenges and encourage help seeking among those at risk.",
mentalHealthType: Specialisation.AntiStigmatism,
website: "https://www.google.com",
email: "[email protected]",
isApproved: true,
socials: [
{
socialType: SocialType.Youtube,
url: "https://www.youtube.com/",
},
{
socialType: SocialType.Facebook,
url: "https://www.facebook.com/",
},
{
socialType: SocialType.LinkedIn,
url: "https://www.linkedin.com/",
},
{
socialType: SocialType.Instagram,
url: "https://www.instagram.com/",
},
{
socialType: SocialType.TikTok,
url: "https://www.tiktok.com/",
},
],
};
const Summary: React.FC<{ org : Organisation }> = ({ org }) => {

const [orgSummary, setOrgSummary] = useState<OrganisationSummary>();

// Load organisation summary details.
useEffect(() => {
getOrganisationSummary(org.id).then((orgSummary) => setOrgSummary(orgSummary));
}, []);

// dynamically generate social icons based on organisation data
const socialIconsView = testDetails.socials.map((item, index) => {
const getSocialIconsView = (summary : OrganisationSummary) => summary.socials.map((item, index) => {
return (
<Box key={index}>
<a href={item.url}>{GetIconForSocials(item.socialType)}</a>
Expand All @@ -123,8 +84,8 @@ const Summary: React.FC = () => {
width: "100%",
height: "100%",
}}
src={testDetails.videoUrl}
title={testDetails.name}
src={orgSummary?.videoUrl}
title={org.name}
allow="web-share"
></iframe>
</Box>
Expand All @@ -135,24 +96,24 @@ const Summary: React.FC = () => {
<VStack spacing="30px">
{/* Organisation Name */}
<HStack justifyContent="flex start" className="title">
<Text>{testDetails.name}</Text>
{testDetails.isApproved && <ShieldCheckIcon />}
<Text>{org.name}</Text>
{org.verified && <ShieldCheckIcon />}
</HStack>

{/* Mental Health Issue*/}
<HStack className="mentalHealthIssueView" spacing="10px">
{GetIconForIssue(testDetails.mentalHealthType)}
{GetIconForIssue(org.mainSpecialisation)}
<Text className="mentalHealthIssueText">
{testDetails.mentalHealthType}
{org.mainSpecialisation}
</Text>
</HStack>

{/* Mission Statement */}
<Text className="missionText">{testDetails.mission}</Text>
<Text className="missionText">{orgSummary?.mission}</Text> { /* TODO: Add mission statement to OrganisationSummary model. */ }

{/* Links */}
<Stack className="linksStyle" direction="row" spacing="10px">
<a href={testDetails.website}>
<a href={orgSummary?.websiteUrl}>
<Button
sx={websiteButtonStyle}
flex={1}
Expand All @@ -162,7 +123,7 @@ const Summary: React.FC = () => {
</Button>
</a>

<a href={`mailto:${testDetails.email}`}>
<a href={`mailto:${orgSummary?.websiteUrl}`}> { /* TODO: Add email to OrganisationSummary model. */ }
<Button
rightIcon={<MailIcon />}
sx={emailButtonStyle}
Expand All @@ -175,7 +136,7 @@ const Summary: React.FC = () => {
</Stack>

{/* Socials */}
<HStack>{socialIconsView}</HStack>
<HStack>{orgSummary !== undefined ? getSocialIconsView(orgSummary) : ""}</HStack>
</VStack>
</Box>
</HStack>
Expand Down
2 changes: 1 addition & 1 deletion src/features/organisation-profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function OrgProfilePage() {
<NavigationBar />
<VStack className="page-width page-padding" align="stretch" spacing="0px">
<OrgBreadCrumb org={org} />
<Summary />
{org !== undefined && <Summary org={org} />}
<Services />
{org !== undefined && <Profile org={org} />}
{/* {org !== undefined && <SimilarOrgs org={org} />} */}
Expand Down

0 comments on commit f6a697e

Please sign in to comment.