Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/HearingsScheduled/HearingsScheduled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions components/LegislatorProfile/LegislatorProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export function LegislatorProfilePage({
</Col>
<Col md="3">
<LegislatorSidebar
committeeList={member.Committees}
court={court}
legislatorData={legislatorData}
legislatorId={legislatorId}
Expand Down
4 changes: 3 additions & 1 deletion components/LegislatorProfile/LegislatorSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { OtherTestimony } from "./SidebarComponents/OtherTestimony"
import { UpcomingHearings } from "./SidebarComponents/UpcomingHearings"

export function LegislatorSidebar({
committeeList,
court,
legislatorData,
legislatorId,
memberCode
}: {
committeeList: any[]
court: number
legislatorData: any[]
legislatorId: string
Expand All @@ -16,7 +18,7 @@ export function LegislatorSidebar({
return (
<>
<OtherTestimony />
<UpcomingHearings />
<UpcomingHearings committeeList={committeeList} />
<Biography
court={court}
legislatorData={legislatorData}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,57 @@
import { DateTime } from "luxon"

import { TabBlock } from "../LegislatorComponents"

export function UpcomingHearings() {
import { useUpcomingEvents } from "components/db/events"
import { EventData } from "components/HearingsScheduled"
import { formatDate } from "components/HearingsScheduled/dateUtils"

export function UpcomingHearings({ committeeList }: { committeeList: any[] }) {
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 <TabBlock>- Upcoming Hearings</TabBlock>
}
Loading