Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/matter-page #222

Merged
merged 4 commits into from Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/app/App.tsx
Expand Up @@ -16,6 +16,7 @@ import { EventPage } from "../pages/EventPage";
import { EventsPage } from "../pages/EventsPage";
import { PersonPage } from "../pages/PersonPage";
import { PeoplePage } from "../pages/PeoplePage";
import { MatterPage } from "../pages/MatterPage";

import { SEARCH_TYPE } from "../pages/SearchPage/types";

Expand Down Expand Up @@ -101,6 +102,9 @@ function App() {
<Route exact path="/people/:id">
<PersonPage />
</Route>
<Route exact path="/matters/:id">
<MatterPage />
</Route>
</Switch>
</Main>
<Footer footerLinksSections={municipality.footerLinksSections} />
Expand Down
1 change: 1 addition & 0 deletions src/assets/LocalizedStrings.tsx
Expand Up @@ -100,6 +100,7 @@ export interface MasterStringsList extends LocalizedStringsMethods {
latest_vote: string;
history: string;
minutes: string;
go_to_matter_details: string;
}

// Note: Add languages to video.js in /src/pages/EventPage/utils when adding new languages
Expand Down
1 change: 1 addition & 0 deletions src/assets/strings/de.ts
Expand Up @@ -89,6 +89,7 @@ const de = {
latest_vote: "Letzte Abstimmung",
history: "Geschichte",
minutes: "Protokoll",
go_to_matter_details: "Gehen Sie zu den vollständigen Rechtsvorschriften",
};

export default de;
1 change: 1 addition & 0 deletions src/assets/strings/en.ts
Expand Up @@ -88,6 +88,7 @@ const en = {
latest_vote: "Latest Vote",
history: "History",
minutes: "Minutes",
go_to_matter_details: "Go to Full Legislation Details",
};

export default en;
1 change: 1 addition & 0 deletions src/assets/strings/es.ts
Expand Up @@ -88,6 +88,7 @@ const es = {
latest_vote: "Último Voto",
history: "Historia",
minutes: "Protocolo",
go_to_matter_details: "Ir a los detalles completos de la legislación",
};

export default es;
13 changes: 7 additions & 6 deletions src/components/Details/Legislation/LegislationIntroduction.tsx
Expand Up @@ -38,12 +38,13 @@ const LegislationIntroduction: FC<LegislationIntroductionProps> = ({
flex: 1,
}}
>
{indexedMatterGrams.map((indexedMatterGram) => (
<div key={indexedMatterGram.id}>
<p style={{ display: "inline", paddingLeft: 11, paddingRight: 11 }}>•</p>
<p style={{ display: "inline" }}>{indexedMatterGram.unstemmed_gram}</p>
</div>
))}
{indexedMatterGrams &&
indexedMatterGrams.map((indexedMatterGram) => (
<div key={indexedMatterGram.id}>
<p style={{ display: "inline", paddingLeft: 11, paddingRight: 11 }}>•</p>
<p style={{ display: "inline" }}>{indexedMatterGram.unstemmed_gram}</p>
</div>
))}
</div>
</div>
</div>
Expand Down
38 changes: 21 additions & 17 deletions src/components/Details/Legislation/LegislationOverview.tsx
Expand Up @@ -63,11 +63,11 @@ export interface LegislationOverviewProps {
/** The latest matter status of the matter */
matterStatus: MatterStatus;
/** The latest event where the matter was a minutes item */
event: Event;
event?: Event;
/** The persons who sponsored the matter */
sponsors: Person[];
/** The latest document of the matter */
document: { name: string; url: string };
document?: { name: string; url: string };
}

const LegislationOverview: FC<LegislationOverviewProps> = ({
Expand Down Expand Up @@ -104,23 +104,27 @@ const LegislationOverview: FC<LegislationOverviewProps> = ({
<div>
<dt>Latest Meeting:</dt>
<dd>
<Link to={`/events/${event.id}`}>
{event.event_datetime.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
})}
</Link>
</dd>
</div>
<div>
<dt>Latest Document:</dt>
<dd>
<a target="_blank" rel="noopener noreferrer" href={document.url}>
{document.name}
</a>
{event && (
<Link to={`/events/${event.id}`}>
{event.event_datetime.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
})}
</Link>
)}
BrianL3 marked this conversation as resolved.
Show resolved Hide resolved
</dd>
</div>
{document && (
<div>
<dt>Latest Document:</dt>
<dd>
<a target="_blank" rel="noopener noreferrer" href={document.url}>
{document.name}
</a>
</dd>
</div>
)}
<div>
<dt>Sponsored by:</dt>
<dd>
Expand Down
11 changes: 6 additions & 5 deletions src/components/Details/MinutesItemsList/MinutesItemsList.tsx
@@ -1,11 +1,12 @@
import React, { FC } from "react";
import styled from "@emotion/styled";
/* import { Link } from "react-router-dom"; */
import { Link } from "react-router-dom";

import DocumentsList from "./DocumentsList";
/* import ChevronDownIcon from "../../Shared/ChevronDownIcon"; */
import ChevronDownIcon from "../../Shared/ChevronDownIcon";

import { Item } from "./types";
import { strings } from "../../../assets/LocalizedStrings";

const ListItem = styled.li({
"& > div:first-of-type": {
Expand Down Expand Up @@ -37,11 +38,11 @@ const MinutesItemsList: FC<MinutesItemsListProps> = ({ minutesItems }: MinutesIt
return (
<ListItem key={elem.name}>
<div>{elem.name}</div>
{/* {elem.matter_ref && (
{elem.matter_ref && (
<Link to={`/matters/${elem.matter_ref}`}>
{"Go to Full Legislation Details"} <ChevronDownIcon />
{strings.go_to_matter_details} <ChevronDownIcon />
</Link>
)} */}
)}
{elem.description && <div>{elem.description}</div>}
<DocumentsList documents={elem.documents} />
</ListItem>
Expand Down
Expand Up @@ -98,7 +98,7 @@ function VoteCell(isExpanded: boolean, votes: IndividualMeetingVote[], isMobile:

const MeetingVotesTableRow = ({
index,
/* legislationLink, */
legislationLink,
legislationName,
legislationDescription,
councilDecision,
Expand All @@ -120,10 +120,11 @@ const MeetingVotesTableRow = ({
}}
>
<div>
{/* <Link to={legislationLink}>{legislationName}</Link> */}
<p className="mzp-c-card-desc" style={{ fontWeight: 600, marginBottom: 0 }}>
{legislationName}
</p>
<Link to={legislationLink}>
<p className="mzp-c-card-desc" style={{ fontWeight: 600, marginBottom: 0 }}>
{legislationName}
</p>
</Link>
{!isMobile && <p>{legislationDescription}</p>}
</div>
<DecisionResult result={councilDecision} />
Expand Down
11 changes: 6 additions & 5 deletions src/components/Tables/VotingTableRow/VotingTableRow.tsx
Expand Up @@ -35,7 +35,7 @@ export type VotingTableRowProps = {

const VotingTableRow = ({
index,
/* legislationLink, */
legislationLink,
legislationName,
legislationTags,
voteDecision,
Expand Down Expand Up @@ -65,10 +65,11 @@ const VotingTableRow = ({
columnDistribution={columnDistribution}
>
<React.Fragment>
{/* <Link to={legislationLink}>{legislationName}</Link> */}
<p className="mzp-c-card-desc" style={{ fontWeight: 600, marginBottom: 0 }}>
{legislationName}
</p>
<Link to={legislationLink}>
<p className="mzp-c-card-desc" style={{ fontWeight: 600, marginBottom: 0 }}>
{legislationName}
</p>
</Link>
{!isMobile && <p className="mzp-c-card-desc">{legislationTagsString}</p>}
</React.Fragment>
<DecisionResult result={voteDecision} />
Expand Down
45 changes: 45 additions & 0 deletions src/containers/MatterContainer/MatterContainer.tsx
@@ -0,0 +1,45 @@
import React from "react";

import MatterStatus from "../../models/MatterStatus";
import Event from "../../models/Event";
import Person from "../../models/Person";
import Vote from "../../models/Vote";
import IndexedMatterGram from "../../models/IndexedMatterGram";
import EventMinutesItem from "../../models/EventMinutesItem";

import LegislationIntroduction from "../../components/Details/Legislation/LegislationIntroduction";
import LegislationOverview from "../../components/Details/Legislation/LegislationOverview";
import { LegislationLatestVote } from "../../components/Details/Legislation/LegislationLatestVote";
import { LegislationHistory } from "../../components/Details/Legislation/LegislationHistory";

interface MatterContainerProps {
matterStatus: MatterStatus;
indexedMatterGrams: IndexedMatterGram[];
event?: Event;
sponsors: Person[];
votes?: Vote[];
legislationHistory?: EventMinutesItem[];
}

const MatterContainer = ({
matterStatus,
indexedMatterGrams,
event,
sponsors,
votes,
legislationHistory,
}: MatterContainerProps) => {
return (
<div>
<LegislationIntroduction
matterStatus={matterStatus}
indexedMatterGrams={indexedMatterGrams}
/>
<LegislationOverview matterStatus={matterStatus} event={event} sponsors={sponsors} />
{votes && <LegislationLatestVote votes={votes} />}
{legislationHistory && <LegislationHistory eventMinutesItems={legislationHistory} />}
</div>
BrianL3 marked this conversation as resolved.
Show resolved Hide resolved
);
};

export default MatterContainer;
1 change: 1 addition & 0 deletions src/containers/MatterContainer/index.ts
@@ -0,0 +1 @@
export { default as MatterContainer } from "./MatterContainer";
12 changes: 9 additions & 3 deletions src/containers/PersonContainer/MattersSponsored.tsx
@@ -1,5 +1,6 @@
import React, { FC, useMemo, useCallback } from "react";
import { Loader } from "semantic-ui-react";
import { Link } from "react-router-dom";

import { useAppConfigContext } from "../../app";
import useFetchModels, {
Expand Down Expand Up @@ -73,9 +74,14 @@ const MattersSponsored: FC<MattersSponsoredProps> = ({ personId }: MattersSponso
{state.models.map((matterSponsored) => (
<li key={matterSponsored.id}>
<dl>
<dt>
<strong>{matterSponsored.matter?.name}</strong>
</dt>
<Link
key={matterSponsored.matter?.id}
to={`/matters/${matterSponsored.matter?.id}`}
>
<dt>
<strong>{matterSponsored.matter?.name}</strong>
</dt>
</Link>
BrianL3 marked this conversation as resolved.
Show resolved Hide resolved
<dd>{matterSponsored.matter?.title}</dd>
</dl>
</li>
Expand Down
23 changes: 23 additions & 0 deletions src/networking/MatterSponsorService.ts
Expand Up @@ -27,6 +27,29 @@ export default class MatterSponsorService extends ModelService {
super(COLLECTION_NAME.MatterSponsor, firebaseConfig);
}

async getMatterSponsorByMatterId(matterId: string): Promise<MatterSponsor[]> {
const populatePerson = new Populate(
COLLECTION_NAME.MatterSponsor,
REF_PROPERTY_NAME.MatterSponsorPersonRef
);
const networkQueryResponse = this.networkService.getDocuments(
COLLECTION_NAME.MatterSponsor,
[
where(
REF_PROPERTY_NAME.MatterSponsorMatterRef,
WHERE_OPERATOR.eq,
doc(NetworkService.getDb(), COLLECTION_NAME.Matter, matterId)
),
],
new PopulationOptions([populatePerson])
);
return this.createModels(
networkQueryResponse,
MatterSponsor,
`getMatterSponsorByMatterId(${matterId})`
) as Promise<MatterSponsor[]>;
}

/**
*
* @param personId The person's id
Expand Down
48 changes: 48 additions & 0 deletions src/networking/MatterStatusService.ts
@@ -0,0 +1,48 @@
import ModelService from "./ModelService";
import { where, orderBy, doc } from "@firebase/firestore";
import {
COLLECTION_NAME,
Populate,
PopulationOptions,
REF_PROPERTY_NAME,
} from "./PopulationOptions";
import { ORDER_DIRECTION, WHERE_OPERATOR } from "./constants";
import { NetworkService } from "./NetworkService";

import MatterStatus from "../models/MatterStatus";
import { FirebaseConfig } from "../app/AppConfigContext";

export default class MatterStatusService extends ModelService {
constructor(firebaseConfig: FirebaseConfig) {
super(COLLECTION_NAME.MatterStatus, firebaseConfig);
}

async getMatterStatusesByMatterId(matterId: string): Promise<MatterStatus[]> {
const populateMatter = new Populate(
COLLECTION_NAME.MatterStatus,
REF_PROPERTY_NAME.MatterStatusMatterRef
);
BrianL3 marked this conversation as resolved.
Show resolved Hide resolved
const populateEventMinutesItems = new Populate(
COLLECTION_NAME.MatterStatus,
REF_PROPERTY_NAME.MatterStatusEventMinutesItemRef
);

const networkQueryResponse = this.networkService.getDocuments(
COLLECTION_NAME.MatterStatus,
[
where(
REF_PROPERTY_NAME.MatterStatusMatterRef,
WHERE_OPERATOR.eq,
doc(NetworkService.getDb(), COLLECTION_NAME.Matter, matterId)
),
orderBy("update_datetime", ORDER_DIRECTION.desc),
],
new PopulationOptions([populateMatter, populateEventMinutesItems])
);
return this.createModels(
networkQueryResponse,
MatterStatus,
`getMatterStatusByMatterId(${matterId})`
) as Promise<MatterStatus[]>;
}
}