Skip to content

Commit 4f65905

Browse files
authored
Merge pull request #1777 from Mephistic/smart-tag-links
Add hyperlinks to SmartTags on Bill Details page
2 parents 902afde + 809af19 commit 4f65905

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

components/bill/Summary.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { SmartDisclaimer } from "./SmartDisclaimer"
88
import { SmartIcon } from "./SmartIcon"
99
import { TestimonyCounts } from "./TestimonyCounts"
1010
import { BillProps } from "./types"
11+
import { currentGeneralCourt } from "functions/src/shared"
12+
import { BillTopic } from "functions/src/bills/types"
1113

1214
const SummaryContainer = styled(Container)`
1315
background-color: white;
@@ -49,17 +51,21 @@ const SmartTagButton = styled.button`
4951
font-size: 12px;
5052
`
5153

52-
const SmartTag = ({ icon, tagName }: { icon: String; tagName: String }) => {
54+
const SmartTag = ({ topic }: { topic: BillTopic }) => {
5355
return (
54-
<SmartTagButton
55-
className={`btn btn-secondary d-flex text-nowrap mt-1 mx-1 p-1`}
56+
<links.Internal
57+
href={links.billSearchByTopicLink(currentGeneralCourt, topic)}
5658
>
57-
&nbsp;
58-
<SmartIcon icon={icon} />
59-
&nbsp;
60-
{tagName}
61-
&nbsp;
62-
</SmartTagButton>
59+
<SmartTagButton
60+
className={`btn btn-secondary d-flex text-nowrap mt-1 mx-1 p-1`}
61+
>
62+
&nbsp;
63+
<SmartIcon icon={topic.category} />
64+
&nbsp;
65+
{topic.topic}
66+
&nbsp;
67+
</SmartTagButton>
68+
</links.Internal>
6369
)
6470
}
6571

@@ -134,7 +140,7 @@ export const Summary = ({
134140
<Row className="mx-1 mb-3">{bill.summary}</Row>
135141
<Row className={`d-flex mx-0 my-1`} xs="auto">
136142
{bill.topics?.map(t => (
137-
<SmartTag key={t.topic} icon={t.category} tagName={t.topic} />
143+
<SmartTag key={t.topic} topic={t} />
138144
))}
139145
</Row>
140146
</>

components/links.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Link from "next/link"
22
import { forwardRef, PropsWithChildren } from "react"
3-
import { CurrentCommittee } from "../functions/src/bills/types"
3+
import { BillTopic, CurrentCommittee } from "../functions/src/bills/types"
44
import { Testimony } from "components/db/testimony"
55
import { Bill, MemberContent } from "./db"
66
import { formatBillId } from "./formatting"
@@ -130,3 +130,11 @@ export const twitterShareLink = (publication: Testimony, t: TFunction) => {
130130

131131
return tweetUrl
132132
}
133+
134+
export const billSearchByTopicLink = (court: number, topic: BillTopic) => {
135+
const params = {
136+
"bills/sort/latestTestimonyAt:desc[multiselectHierarchicalMenu][topics.lvl1][0]": `${topic.category} > ${topic.topic}`,
137+
"bills/sort/latestTestimonyAt:desc[refinementList][court][0]": `${court}`
138+
}
139+
return `/bills?${new URLSearchParams(params).toString()}`
140+
}

0 commit comments

Comments
 (0)