Skip to content

Commit 946d254

Browse files
authored
Merge pull request #2134 from VenkateshDevarakonda0706/feat/legislator-testimony-tab
feat: add "Their Testimony" tab to legislator profile
2 parents ec59dbb + 2f07630 commit 946d254

4 files changed

Lines changed: 109 additions & 4 deletions

File tree

components/legislator/LegislatorPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export function LegislatorPage(props: { id: string }) {
345345

346346
<Row>
347347
<Col className={`mt-4`} md="9">
348-
<LegislatorTabs />
348+
<LegislatorTabs fullname={profile.fullName} pageId={props.id} />
349349
</Col>
350350
<Col className={`mt-4`} md="3">
351351
<LegislatorSidebar />

components/legislator/TabComponents/LegislatorTabs.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ const TabNavItem = ({
6363
}
6464

6565
export function LegislatorTabs({
66+
fullname,
67+
pageId,
6668
tabCategory
6769
}: {
70+
fullname?: string
71+
pageId?: string
6872
tabCategory?: TabCategories
6973
}) {
7074
const { t } = useTranslation("legislators")
@@ -98,7 +102,7 @@ export function LegislatorTabs({
98102
{
99103
title: t("tabs.testimony"),
100104
eventKey: "testimony",
101-
content: <Testimony />
105+
content: <Testimony fullname={fullname} pageId={pageId} />
102106
},
103107
{
104108
title: t("tabs.votes"),
Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,103 @@
1-
export function Testimony() {
2-
return <div>- Testimony</div>
1+
import { useMemo } from "react"
2+
import { useTranslation } from "next-i18next"
3+
import styled from "styled-components"
4+
5+
import { useAuth } from "components/auth"
6+
import { SmartDisclaimer } from "components/bill/SmartDisclaimer"
7+
import { usePublishedTestimonyListing } from "components/db/testimony/usePublishedTestimonyListing"
8+
import { NoResults } from "components/search/NoResults"
9+
import { TestimonyItem } from "components/TestimonyCard/TestimonyItem"
10+
11+
const DisclaimerBlock = styled.div`
12+
align-items: flex-start;
13+
background-color: #f0f4ff;
14+
border: "1px #d1d6e7 solid";
15+
border-radius: 5px;
16+
color: #1a3185;
17+
display: flex;
18+
font-size: 13px;
19+
gap: 10px;
20+
line-height: 1.6;
21+
margin-top: 14px;
22+
margin-bottom: 14px;
23+
padding: 12px 16px;
24+
`
25+
26+
const TestimonyBlock = styled.div`
27+
background-color: white;
28+
border: "1px #ced4da solid";
29+
border-radius: 5px;
30+
font-size: 11px;
31+
margin-bottom: 14px;
32+
padding: 0px 16px;
33+
`
34+
35+
function Disclaimer({ fullname }: { fullname?: string }) {
36+
const { t } = useTranslation("legislators")
37+
38+
return (
39+
<DisclaimerBlock>
40+
<svg
41+
width="16"
42+
height="16"
43+
viewBox="0 0 24 24"
44+
fill="none"
45+
stroke="#1a3185"
46+
stroke-width="2"
47+
// style="flex-shrink:0;margin-top:1px"
48+
>
49+
<circle cx="12" cy="12" r="10"></circle>
50+
<line x1="12" y1="8" x2="12" y2="12"></line>
51+
<line x1="12" y1="16" x2="12.01" y2="16"></line>
52+
</svg>
53+
<div>
54+
{fullname} {t("canSubmit")}
55+
</div>
56+
</DisclaimerBlock>
57+
)
58+
}
59+
60+
export function Testimony({
61+
fullname,
62+
pageId
63+
}: {
64+
fullname?: string
65+
pageId?: string
66+
}) {
67+
const { t } = useTranslation("testimony")
68+
const { user } = useAuth()
69+
70+
const testimony = usePublishedTestimonyListing({
71+
uid: pageId
72+
})
73+
74+
const allTestimonies = useMemo(() => {
75+
const legislatorTestimonies = testimony.items.result ?? []
76+
77+
// Combine and sort by publishedAt (newest first), then take 4 most recent
78+
return [...legislatorTestimonies]
79+
.sort((a, b) => b.publishedAt.toMillis() - a.publishedAt.toMillis())
80+
.slice(0, 4)
81+
}, [testimony.items.result])
82+
83+
return (
84+
<>
85+
<Disclaimer fullname={fullname} />
86+
{allTestimonies.length > 0 ? (
87+
<div>
88+
{allTestimonies.map(testimony => (
89+
<TestimonyBlock key={testimony.id}>
90+
<TestimonyItem
91+
testimony={testimony}
92+
isUser={testimony.authorUid === user?.uid}
93+
onProfilePage={true}
94+
/>
95+
</TestimonyBlock>
96+
))}
97+
</div>
98+
) : (
99+
<NoResults>{t("viewTestimony.noTestimonies")}</NoResults>
100+
)}
101+
</>
102+
)
3103
}

public/locales/en/legislators.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"billsSponsored": "Bills Sponsored",
3+
"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.",
34
"contact": "Contact",
45
"cosponsored": "Cosponsored",
56
"fundsRaised": "Funds Raised",

0 commit comments

Comments
 (0)