diff --git a/components/HearingsScheduled/HearingsScheduled.tsx b/components/HearingsScheduled/HearingsScheduled.tsx index bb51b18d6..88508ee81 100644 --- a/components/HearingsScheduled/HearingsScheduled.tsx +++ b/components/HearingsScheduled/HearingsScheduled.tsx @@ -9,6 +9,7 @@ export type EventData = { index: number type: "hearing" | "session" name: string + code?: string | null id: number location?: string fullDate: Date // TODO: Could be a timestamp diff --git a/components/LegislatorProfile/LegislatorProfilePage.tsx b/components/LegislatorProfile/LegislatorProfilePage.tsx index 24ea34433..e65576a90 100644 --- a/components/LegislatorProfile/LegislatorProfilePage.tsx +++ b/components/LegislatorProfile/LegislatorProfilePage.tsx @@ -376,6 +376,7 @@ export function LegislatorProfilePage({ - + ) } + +export const SidebarBlock = styled.div` + background-color: white; + border-color: #b8c0c9; + border-radius: 5px; + border-style: solid; + border-width: 1px; + font-size: 11px; + padding: 16px; +` + +export const SidebarTitle = styled.div` + font-weight: 700; + color: #0b0a3e; + text-transform: uppercase; + letter-spacing: 0.05em; + margin-bottom: 10px; +` diff --git a/components/LegislatorProfile/SidebarComponents/Biography.tsx b/components/LegislatorProfile/SidebarComponents/Biography.tsx index cdbed8755..28f5428af 100644 --- a/components/LegislatorProfile/SidebarComponents/Biography.tsx +++ b/components/LegislatorProfile/SidebarComponents/Biography.tsx @@ -6,6 +6,7 @@ import styled from "styled-components" import { Form } from "../../bootstrap" import { Profile, ProfileHook, useProfile } from "../../db" import Input from "../../forms/Input" +import { SidebarBlock, SidebarTitle } from "../LegislatorSidebar" import { useAuth } from "components/auth" import { @@ -13,29 +14,11 @@ import { UpdateProfileData } from "components/EditProfilePage/PersonalInfoTab" -const BioBlock = styled.div` - background-color: white; - border-color: #b8c0c9; - border-radius: 5px; - border-style: solid; - border-width: 1px; - font-size: 11px; - padding: 16px; -` - const BioButton = styled.button` font-size: 9px; padding: 2px; ` -const BioTitle = styled.div` - font-weight: 700; - color: #0b0a3e; - text-transform: uppercase; - letter-spacing: 0.05em; - margin-bottom: 10px; -` - export function Biography({ court, legislatorData, @@ -108,12 +91,12 @@ function EditableBiography({ }, [isDirty, setFormUpdated]) return ( - +
- + {t("biography")} - + - + ) } @@ -139,11 +122,11 @@ function ReadonlyBiography({ legislatorData }: { legislatorData: any[] }) { const { t } = useTranslation("legislators") return ( - - {t("biography")} + + {t("biography")}
{legislatorData[0]?.about ? legislatorData[0].about : t("notClaimed")}
-
+ ) } diff --git a/components/LegislatorProfile/SidebarComponents/OtherTestimony.tsx b/components/LegislatorProfile/SidebarComponents/OtherTestimony.tsx index 4cf43f2b2..222e204d3 100644 --- a/components/LegislatorProfile/SidebarComponents/OtherTestimony.tsx +++ b/components/LegislatorProfile/SidebarComponents/OtherTestimony.tsx @@ -1,5 +1,14 @@ -import { TabBlock } from "../LegislatorComponents" +import { useTranslation } from "next-i18next" + +import { SidebarBlock, SidebarTitle } from "../LegislatorSidebar" export function OtherTestimony() { - return - Other Testimony + const { t } = useTranslation("legislators") + + return ( + + {t("otherTestimony")} +
Content To Be Added
+
+ ) } diff --git a/components/LegislatorProfile/SidebarComponents/UpcomingHearings.tsx b/components/LegislatorProfile/SidebarComponents/UpcomingHearings.tsx index c3da92690..4bbb86c2e 100644 --- a/components/LegislatorProfile/SidebarComponents/UpcomingHearings.tsx +++ b/components/LegislatorProfile/SidebarComponents/UpcomingHearings.tsx @@ -1,5 +1,121 @@ -import { TabBlock } from "../LegislatorComponents" +import { DateTime } from "luxon" +import { useTranslation } from "next-i18next" +import styled from "styled-components" -export function UpcomingHearings() { - return - Upcoming Hearings +import * as links from "../../links" +import { Col } from "../../bootstrap" +import { SidebarBlock, SidebarTitle } from "../LegislatorSidebar" + +import { useUpcomingEvents } from "components/db/events" +import { EventData } from "components/HearingsScheduled" +import { formatDate } from "components/HearingsScheduled/dateUtils" + +const EventBlock = styled.div` + border-bottom: 1px solid #b8c0c9; + font-size: 12px; + font-weight: 700; + margin: 0 2px; + padding: 8px 0; +` + +const EventDate = styled.div` + color: #1a3185; +` + +const EventTitle = styled.div` + color: #212529; + font-weight: 600; + text-decoration: none; +` + +const EventLocation = styled.div` + color: #6c757d; + margin-top: 1px; +` + +export const HearingsLink = styled(links.Internal)` + font-size: 12px; + font-weight: 700; + color: #1a3185; + padding: 10px; + display: block; + text-align: center; + text-decoration: none; +` + +export function UpcomingHearings({ committeeList }: { committeeList: any[] }) { + const { t } = useTranslation("legislators") + + const events = useUpcomingEvents() + const thisMonth = DateTime.now().startOf("month") + const eventList: EventData[] = [] + let latestDate = DateTime.now() + + if (events) { + for (let e of events) { + const eventDate = DateTime.fromISO(e.content.EventDate) + + if (eventDate > latestDate) latestDate = eventDate + + const index = Math.floor(eventDate.diff(thisMonth, "months").months) + const date = formatDate(e.content.EventDate) + if (e.type === "hearing") { + eventList.push({ + index, + type: e.type, + name: e.content.Name ?? "Hearing", + code: e.content.HearingHost.CommitteeCode, + id: e.content.EventId, + location: e.content.Location?.LocationName ?? undefined, + fullDate: eventDate.toJSDate(), + year: date.year, + month: date.month, + date: date.date, + day: date.day, + time: date.time + }) + } + } + } + + const LegislatorCommitteCodes = committeeList.map(code => code.CommitteeCode) + + let legislatorEvents: any[] = [] + + if (events) { + eventList.forEach(event => { + if (LegislatorCommitteCodes.includes(event.code)) { + legislatorEvents.push(event) + } + }) + } + + console.log("legislatorEvents", legislatorEvents) + + return ( + + {t("upcomingHearings")} + {legislatorEvents ? ( + <> + {legislatorEvents.slice(0, 3).map(e => ( + + + {e.month} {e.date} {" · "} {e.time} + + {e.name} + {e.location} + + ))} + + ) : ( +
{t("noEvents")}
+ )} + + + {t("viewAllHearings")} + {" ↗"} + + +
+ ) } diff --git a/public/locales/en/legislators.json b/public/locales/en/legislators.json index c422d3e01..79d2da6fc 100644 --- a/public/locales/en/legislators.json +++ b/public/locales/en/legislators.json @@ -44,7 +44,9 @@ "home": "Home", "legislators": "Legislators", "loading": "Loading district...", + "noEvents": "This legislator does not have hearings in the near term future", "notClaimed": "This legislator has not claimed their MAPLE account", + "otherTestimony": "Others' testimony on their bills", "party": { "democratic": "Democratic Party", "party": "Party", @@ -62,5 +64,7 @@ "testimony": "Testimony", "votes": "Votes" }, - "termsServed": "Terms Served" + "termsServed": "Terms Served", + "upcomingHearings": "Upcoming Hearings", + "viewAllHearings": "View all hearings" } \ No newline at end of file