From 9b1b6b43bc143d4d27f481eec4ad0ac3e0665d39 Mon Sep 17 00:00:00 2001 From: VenkateshDevarakonda0706 Date: Tue, 12 May 2026 11:28:21 +0530 Subject: [PATCH 1/3] 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/3] 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/3] 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])