From 9b1b6b43bc143d4d27f481eec4ad0ac3e0665d39 Mon Sep 17 00:00:00 2001 From: VenkateshDevarakonda0706 Date: Tue, 12 May 2026 11:28:21 +0530 Subject: [PATCH 1/5] feat: add legislator testimony tab --- components/legislator/LegislatorPage.tsx | 2 +- .../TabComponents/LegislatorTabs.tsx | 6 +- .../legislator/TabComponents/Testimony.tsx | 67 ++++++++++++++++++- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/components/legislator/LegislatorPage.tsx b/components/legislator/LegislatorPage.tsx index 35f2b5251..34db79358 100644 --- a/components/legislator/LegislatorPage.tsx +++ b/components/legislator/LegislatorPage.tsx @@ -117,7 +117,7 @@ export function LegislatorPage(props: { id: string }) { - + diff --git a/components/legislator/TabComponents/LegislatorTabs.tsx b/components/legislator/TabComponents/LegislatorTabs.tsx index 34cc14260..9b1caf794 100644 --- a/components/legislator/TabComponents/LegislatorTabs.tsx +++ b/components/legislator/TabComponents/LegislatorTabs.tsx @@ -63,9 +63,11 @@ const TabNavItem = ({ } export function LegislatorTabs({ - tabCategory + tabCategory, + legislatorId }: { tabCategory?: TabCategories + legislatorId?: string }) { const { t } = useTranslation("legislators") @@ -98,7 +100,7 @@ export function LegislatorTabs({ { title: t("tabs.testimony"), eventKey: "testimony", - content: + content: }, { title: t("tabs.votes"), diff --git a/components/legislator/TabComponents/Testimony.tsx b/components/legislator/TabComponents/Testimony.tsx index d69dde353..a44092d20 100644 --- a/components/legislator/TabComponents/Testimony.tsx +++ b/components/legislator/TabComponents/Testimony.tsx @@ -1,3 +1,66 @@ -export function Testimony() { - return
- Testimony
+import { useEffect, useMemo } from "react" +import { useTranslation } from "next-i18next" +import { SmartDisclaimer } from "components/bill/SmartDisclaimer" +import { TestimonyItem } from "components/TestimonyCard/TestimonyItem" +import { usePublishedTestimonyListing } from "components/db/testimony/usePublishedTestimonyListing" +import { CURRENT_COURT_NUMBER } from "components/search/courtSessions" +import { NoResults } from "components/search/NoResults" +import { useAuth } from "components/auth" + +export function Testimony({ legislatorId }: { legislatorId?: string }) { + const { t } = useTranslation("testimony") + const { user } = useAuth() + + // Query testimonies where legislator is a representative + const representativeTestimony = usePublishedTestimonyListing({ + court: CURRENT_COURT_NUMBER + }) + + // Query testimonies where legislator is a senator + const senatorTestimony = usePublishedTestimonyListing({ + court: CURRENT_COURT_NUMBER + }) + + // Apply legislator filters + useEffect(() => { + if (legislatorId) { + representativeTestimony.setFilter({ representativeId: legislatorId }) + } + }, [legislatorId, representativeTestimony]) + + useEffect(() => { + if (legislatorId) { + senatorTestimony.setFilter({ senatorId: legislatorId }) + } + }, [legislatorId, senatorTestimony]) + + const allTestimonies = useMemo(() => { + const repTestimonies = representativeTestimony.items.result ?? [] + const senTestimonies = senatorTestimony.items.result ?? [] + + // Combine and sort by publishedAt (newest first), then take 4 most recent + return [...repTestimonies, ...senTestimonies] + .sort((a, b) => b.publishedAt - a.publishedAt) + .slice(0, 4) + }, [representativeTestimony.items.result, senatorTestimony.items.result]) + + return ( + <> + + {allTestimonies.length > 0 ? ( +
+ {allTestimonies.map(testimony => ( + + ))} +
+ ) : ( + {t("viewTestimony.noTestimonies")} + )} + + ) } From 88b216c1723f0026e77c713dfc38f45ae2dd10a3 Mon Sep 17 00:00:00 2001 From: VenkateshDevarakonda0706 Date: Tue, 12 May 2026 12:00:31 +0530 Subject: [PATCH 2/5] fix: use firestore timestamp sorting --- components/legislator/TabComponents/Testimony.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/legislator/TabComponents/Testimony.tsx b/components/legislator/TabComponents/Testimony.tsx index a44092d20..490b48871 100644 --- a/components/legislator/TabComponents/Testimony.tsx +++ b/components/legislator/TabComponents/Testimony.tsx @@ -40,7 +40,10 @@ export function Testimony({ legislatorId }: { legislatorId?: string }) { // Combine and sort by publishedAt (newest first), then take 4 most recent return [...repTestimonies, ...senTestimonies] - .sort((a, b) => b.publishedAt - a.publishedAt) + .sort( + (a, b) => + b.publishedAt.toMillis() - a.publishedAt.toMillis() + ) .slice(0, 4) }, [representativeTestimony.items.result, senatorTestimony.items.result]) From dbb13fed2726bbf2809bdd61098543631cf6cc4d Mon Sep 17 00:00:00 2001 From: VenkateshDevarakonda0706 Date: Wed, 13 May 2026 08:53:03 +0530 Subject: [PATCH 3/5] style: format testimony component --- components/legislator/TabComponents/Testimony.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/legislator/TabComponents/Testimony.tsx b/components/legislator/TabComponents/Testimony.tsx index 490b48871..7e953363c 100644 --- a/components/legislator/TabComponents/Testimony.tsx +++ b/components/legislator/TabComponents/Testimony.tsx @@ -40,10 +40,7 @@ export function Testimony({ legislatorId }: { legislatorId?: string }) { // Combine and sort by publishedAt (newest first), then take 4 most recent return [...repTestimonies, ...senTestimonies] - .sort( - (a, b) => - b.publishedAt.toMillis() - a.publishedAt.toMillis() - ) + .sort((a, b) => b.publishedAt.toMillis() - a.publishedAt.toMillis()) .slice(0, 4) }, [representativeTestimony.items.result, senatorTestimony.items.result]) From c0466061ac3559f29be91900747d2e7ed3990a36 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Wed, 10 Jun 2026 00:23:54 -0400 Subject: [PATCH 4/5] tweaks --- components/legislator/LegislatorPage.tsx | 2 +- .../TabComponents/LegislatorTabs.tsx | 10 +- .../legislator/TabComponents/Testimony.tsx | 112 ++++++++++++------ public/locales/en/legislators.json | 1 + 4 files changed, 83 insertions(+), 42 deletions(-) diff --git a/components/legislator/LegislatorPage.tsx b/components/legislator/LegislatorPage.tsx index 4b79c1268..fbf6b9113 100644 --- a/components/legislator/LegislatorPage.tsx +++ b/components/legislator/LegislatorPage.tsx @@ -345,7 +345,7 @@ export function LegislatorPage(props: { id: string }) { - + diff --git a/components/legislator/TabComponents/LegislatorTabs.tsx b/components/legislator/TabComponents/LegislatorTabs.tsx index 9b1caf794..332f41747 100644 --- a/components/legislator/TabComponents/LegislatorTabs.tsx +++ b/components/legislator/TabComponents/LegislatorTabs.tsx @@ -63,11 +63,13 @@ const TabNavItem = ({ } export function LegislatorTabs({ - tabCategory, - legislatorId + fullname, + pageId, + tabCategory }: { + fullname?: string + pageId?: string tabCategory?: TabCategories - legislatorId?: string }) { const { t } = useTranslation("legislators") @@ -100,7 +102,7 @@ export function LegislatorTabs({ { title: t("tabs.testimony"), eventKey: "testimony", - content: + content: }, { title: t("tabs.votes"), diff --git a/components/legislator/TabComponents/Testimony.tsx b/components/legislator/TabComponents/Testimony.tsx index 7e953363c..c31474e75 100644 --- a/components/legislator/TabComponents/Testimony.tsx +++ b/components/legislator/TabComponents/Testimony.tsx @@ -1,61 +1,99 @@ -import { useEffect, useMemo } from "react" +import { useMemo } from "react" import { useTranslation } from "next-i18next" +import styled from "styled-components" + +import { useAuth } from "components/auth" import { SmartDisclaimer } from "components/bill/SmartDisclaimer" -import { TestimonyItem } from "components/TestimonyCard/TestimonyItem" import { usePublishedTestimonyListing } from "components/db/testimony/usePublishedTestimonyListing" -import { CURRENT_COURT_NUMBER } from "components/search/courtSessions" import { NoResults } from "components/search/NoResults" -import { useAuth } from "components/auth" +import { TestimonyItem } from "components/TestimonyCard/TestimonyItem" -export function Testimony({ legislatorId }: { legislatorId?: string }) { - const { t } = useTranslation("testimony") - const { user } = useAuth() +const DisclaimerBlock = styled.div` + align-items: flex-start; + background-color: #f0f4ff; + border: "1px #d1d6e7 solid"; + border-radius: 5px; + color: #1a3185; + display: flex; + font-size: 13px; + gap: 10px; + line-height: 1.6; + margin-top: 14px; + margin-bottom: 14px; + padding: 12px 16px; +` - // Query testimonies where legislator is a representative - const representativeTestimony = usePublishedTestimonyListing({ - court: CURRENT_COURT_NUMBER - }) +const TestimonyBlock = styled.div` + background-color: white; + border: "1px #ced4da solid"; + border-radius: 5px; + font-size: 11px; + margin-bottom: 14px; + padding: 0px 16px; +` - // Query testimonies where legislator is a senator - const senatorTestimony = usePublishedTestimonyListing({ - court: CURRENT_COURT_NUMBER - }) +function Disclaimer({ fullname }: { fullname?: string }) { + const { t } = useTranslation("legislators") + + return ( + + + + + + +
+ {fullname} {t("canSubmit")} +
+
+ ) +} - // Apply legislator filters - useEffect(() => { - if (legislatorId) { - representativeTestimony.setFilter({ representativeId: legislatorId }) - } - }, [legislatorId, representativeTestimony]) +export function Testimony({ + fullname, + pageId +}: { + fullname?: string + pageId?: string +}) { + const { t } = useTranslation("testimony") + const { user } = useAuth() - useEffect(() => { - if (legislatorId) { - senatorTestimony.setFilter({ senatorId: legislatorId }) - } - }, [legislatorId, senatorTestimony]) + const testimony = usePublishedTestimonyListing({ + uid: pageId + }) const allTestimonies = useMemo(() => { - const repTestimonies = representativeTestimony.items.result ?? [] - const senTestimonies = senatorTestimony.items.result ?? [] + const legislatorTestimonies = testimony.items.result ?? [] // Combine and sort by publishedAt (newest first), then take 4 most recent - return [...repTestimonies, ...senTestimonies] + return [...legislatorTestimonies] .sort((a, b) => b.publishedAt.toMillis() - a.publishedAt.toMillis()) .slice(0, 4) - }, [representativeTestimony.items.result, senatorTestimony.items.result]) + }, [testimony.items.result]) return ( <> - + {allTestimonies.length > 0 ? (
{allTestimonies.map(testimony => ( - + + + ))}
) : ( diff --git a/public/locales/en/legislators.json b/public/locales/en/legislators.json index 8b5c685d1..fecb79040 100644 --- a/public/locales/en/legislators.json +++ b/public/locales/en/legislators.json @@ -1,5 +1,6 @@ { "billsSponsored": "Bills Sponsored", + "canSubmit": "can submit testimony on any bill or ballot question, just like any constituent. Her stance and reasoning are shown exactly as submitted — MAPLE does not edit or editorialize.", "contact": "Contact", "cosponsored": "Cosponsored", "fundsRaised": "Funds Raised", From 2f07630a79b0bfc97a83b2508f4149e1c051d2e8 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Wed, 10 Jun 2026 00:40:25 -0400 Subject: [PATCH 5/5] moved up key property --- components/legislator/TabComponents/Testimony.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/legislator/TabComponents/Testimony.tsx b/components/legislator/TabComponents/Testimony.tsx index c31474e75..6f5c0e40b 100644 --- a/components/legislator/TabComponents/Testimony.tsx +++ b/components/legislator/TabComponents/Testimony.tsx @@ -86,9 +86,8 @@ export function Testimony({ {allTestimonies.length > 0 ? (
{allTestimonies.map(testimony => ( - +