Skip to content

Commit 180b784

Browse files
authored
Merge pull request #1927 from codeforboston/main
Deploy to PROD 8/25/25
2 parents e7cf57f + 34641f9 commit 180b784

23 files changed

Lines changed: 324 additions & 342 deletions

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,15 @@
740740
"contributions": [
741741
"code"
742742
]
743+
},
744+
{
745+
"login": "rockyroed",
746+
"name": "roed",
747+
"avatar_url": "https://avatars.githubusercontent.com/u/108738926?v=4",
748+
"profile": "https://github.com/rockyroed",
749+
"contributions": [
750+
"code"
751+
]
743752
}
744753
],
745754
"commitType": "docs"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,11 @@ Thanks to all our contributors!
236236
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mvictor55"><img src="https://avatars.githubusercontent.com/u/71357256?v=4?s=100" width="100px;" alt="mvictor55"/><br /><sub><b>mvictor55</b></sub></a><br /><a href="#business-mvictor55" title="Business development">💼</a> <a href="#projectManagement-mvictor55" title="Project Management">📆</a> <a href="#fundingFinding-mvictor55" title="Funding Finding">🔍</a> <a href="https://github.com/codeforboston/maple/commits?author=mvictor55" title="Code">💻</a></td>
237237
<td align="center" valign="top" width="14.28%"><a href="https://github.com/pranay8297"><img src="https://avatars.githubusercontent.com/u/47974414?v=4?s=100" width="100px;" alt="pranay"/><br /><sub><b>pranay</b></sub></a><br /><a href="https://github.com/codeforboston/maple/commits?author=pranay8297" title="Code">💻</a></td>
238238
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ren0nie0"><img src="https://avatars.githubusercontent.com/u/32780767?v=4?s=100" width="100px;" alt="ren0nie0"/><br /><sub><b>ren0nie0</b></sub></a><br /><a href="#research-ren0nie0" title="Research">🔬</a></td>
239+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/rockyroed"><img src="https://avatars.githubusercontent.com/u/108738926?v=4?s=100" width="100px;" alt="roed"/><br /><sub><b>roed</b></sub></a><br /><a href="https://github.com/codeforboston/maple/commits?author=rockyroed" title="Code">💻</a></td>
239240
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sammymyi"><img src="https://avatars.githubusercontent.com/u/105759252?v=4?s=100" width="100px;" alt="sammymyi"/><br /><sub><b>sammymyi</b></sub></a><br /><a href="#design-sammymyi" title="Design">🎨</a> <a href="#userTesting-sammymyi" title="User Testing">📓</a></td>
240-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sashamaryl"><img src="https://avatars.githubusercontent.com/u/30247522?v=4?s=100" width="100px;" alt="sashamaryl"/><br /><sub><b>sashamaryl</b></sub></a><br /><a href="https://github.com/codeforboston/maple/commits?author=sashamaryl" title="Code">💻</a> <a href="#mentoring-sashamaryl" title="Mentoring">🧑‍🏫</a> <a href="#research-sashamaryl" title="Research">🔬</a></td>
241241
</tr>
242242
<tr>
243+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sashamaryl"><img src="https://avatars.githubusercontent.com/u/30247522?v=4?s=100" width="100px;" alt="sashamaryl"/><br /><sub><b>sashamaryl</b></sub></a><br /><a href="https://github.com/codeforboston/maple/commits?author=sashamaryl" title="Code">💻</a> <a href="#mentoring-sashamaryl" title="Mentoring">🧑‍🏫</a> <a href="#research-sashamaryl" title="Research">🔬</a></td>
243244
<td align="center" valign="top" width="14.28%"><a href="https://github.com/shannonh800"><img src="https://avatars.githubusercontent.com/u/113308101?v=4?s=100" width="100px;" alt="shannonh800"/><br /><sub><b>shannonh800</b></sub></a><br /><a href="https://github.com/codeforboston/maple/commits?author=shannonh800" title="Code">💻</a></td>
244245
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yasminekarni"><img src="https://avatars.githubusercontent.com/u/47721405?v=4?s=100" width="100px;" alt="yasminekarni"/><br /><sub><b>yasminekarni</b></sub></a><br /><a href="https://github.com/codeforboston/maple/commits?author=yasminekarni" title="Code">💻</a></td>
245246
</tr>

components/HearingsScheduled/HearingsScheduled.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ export const HearingsScheduled = () => {
219219
wrap={false}
220220
activeIndex={monthIndex}
221221
onSelect={handleSelect}
222-
prevIcon={<CarouselControlNextIcon aria-hidden="true" />}
223-
nextIcon={<CarouselControlPrevIcon aria-hidden="true" />}
222+
prevIcon={<CarouselControlPrevIcon aria-hidden="true" />}
223+
nextIcon={<CarouselControlNextIcon aria-hidden="true" />}
224224
>
225225
{monthsList?.map(month => {
226226
return (

components/search/NoResults.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ const Container = styled.div`
1919
export const NoResults: React.FC<React.PropsWithChildren<unknown>> = ({
2020
children
2121
}) => {
22-
const { t } = useTranslation("common")
22+
const { t } = useTranslation("search")
2323
return (
2424
<Container>
25-
<Image src="/no-results.svg" alt={t("noResults")} />
26-
<div className="fs-3">Looks Pretty Empty Here</div>
25+
<Image src="/no-results.svg" alt={t("no_results")} />
26+
<div className="fs-3">{t("looks_pretty_empty_here")}</div>
2727
<div className="text-center">{children}</div>
2828
</Container>
2929
)

components/search/ResultCount.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTranslation } from "next-i18next"
12
import { useStats } from "react-instantsearch"
23
import styled from "styled-components"
34

@@ -13,7 +14,11 @@ export function ResultCount(props: any) {
1314

1415
return (
1516
<ResultContainer {...props}>
16-
Showing {pageStart}-{pageEnd} of {nbHits} Results
17+
{useTranslation("search").t("result_count", {
18+
pageStart,
19+
pageEnd,
20+
nbHits
21+
})}
1722
</ResultContainer>
1823
)
1924
}

components/search/SearchErrorBoundary.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { ReactNode } from "react"
22
import { Alert } from "react-bootstrap"
3+
import { withTranslation, WithTranslation } from "next-i18next"
34

4-
export class SearchErrorBoundary extends React.Component<{
5-
children?: ReactNode
6-
}> {
5+
class SearchErrorBoundaryBase extends React.Component<
6+
{ children?: ReactNode } & WithTranslation
7+
> {
78
state: { error: string | null } = { error: null }
89

910
promiseRejectionHandler = (event: PromiseRejectionEvent) => {
@@ -16,8 +17,7 @@ export class SearchErrorBoundary extends React.Component<{
1617
if (this.state.error) {
1718
return (
1819
<Alert variant="danger">
19-
Something went wrong. Please try again. Original message:{" "}
20-
{this.state.error}
20+
{this.props.t("search_error", { error: this.state.error })}
2121
</Alert>
2222
)
2323
}
@@ -44,3 +44,7 @@ export class SearchErrorBoundary extends React.Component<{
4444
)
4545
}
4646
}
47+
48+
export const SearchErrorBoundary = withTranslation("search")(
49+
SearchErrorBoundaryBase
50+
)

components/search/bills/BillSearch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const Layout: FC<
147147
const refinements = useBillRefinements()
148148
const status = useSearchStatus()
149149

150-
const { t } = useTranslation("billSearch")
150+
const { t } = useTranslation("search")
151151

152152
return (
153153
<SearchContainer>

components/search/bills/useBillHierarchicalMenu.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { generalCourts } from "functions/src/shared"
22
import { RefinementListItem } from "instantsearch.js/es/connectors/refinement-list/connectRefinementList"
3-
import { useCallback } from "react"
3+
import { useMemo } from "react"
44
import { useRefinements } from "../useRefinements"
5+
import { useTranslation } from "next-i18next"
56

67
// for legacy code purposes, things like:
78
//
@@ -17,58 +18,35 @@ import { useRefinements } from "../useRefinements"
1718
// searchablePlaceholder: "Legislative Session",
1819

1920
export const useBillRefinements = () => {
20-
const baseProps = { limit: 500, searchable: true }
21-
const propsList = [
22-
{
23-
transformItems: useCallback(
24-
(i: RefinementListItem[]) =>
25-
i
26-
.map(i => ({
27-
...i,
28-
label: generalCourts[i.value as any]?.Name ?? i.label
29-
}))
30-
.sort((a, b) => Number(b.value) - Number(a.value)),
31-
[]
32-
),
33-
attribute: "court",
34-
searchablePlaceholder: "Legislative Session",
35-
...baseProps
36-
},
37-
{
38-
attribute: "currentCommittee",
39-
...baseProps,
40-
searchablePlaceholder: "Current Committee"
41-
},
42-
{
43-
attribute: "city",
44-
searchablePlaceholder: "City",
45-
...baseProps
46-
},
47-
{
48-
attribute: "primarySponsor",
49-
...baseProps,
50-
searchablePlaceholder: "Primary Sponsor"
51-
},
52-
{
53-
attribute: "cosponsors",
54-
...baseProps,
55-
searchablePlaceholder: "Cosponsor"
56-
}
57-
]
58-
59-
const hierarchicalPropsList = [
60-
{
61-
attribute: "topics.lvl0",
62-
...baseProps
63-
},
64-
{
65-
attribute: "topics.lvl1",
66-
...baseProps
67-
}
68-
]
21+
const { t } = useTranslation("search")
6922

7023
return useRefinements({
71-
hierarchicalMenuProps: hierarchicalPropsList,
72-
refinementProps: propsList
24+
hierarchicalMenuProps: { attributes: ["topics.lvl0", "topics.lvl1"] },
25+
refinementProps: useMemo(
26+
() =>
27+
[
28+
{
29+
transformItems: (items: RefinementListItem[]) =>
30+
items
31+
.map(i => ({
32+
...i,
33+
label: generalCourts[parseInt(i.value, 10)]?.Name ?? i.label
34+
}))
35+
.sort((a, b) => Number(b.value) - Number(a.value)),
36+
37+
attribute: "court"
38+
},
39+
{ attribute: "currentCommittee" },
40+
{ attribute: "city" },
41+
{ attribute: "primarySponsor" },
42+
{ attribute: "cosponsors" }
43+
].map(props => ({
44+
limit: 500,
45+
searchable: true,
46+
searchablePlaceholder: t(`refinements.bill.${props.attribute}`),
47+
...props
48+
})),
49+
[t]
50+
)
7351
})
7452
}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
import { useMemo, useRef } from "react"
22
import { SortByWithConfigurationItem } from "../SortBy"
3+
import { useTranslation } from "next-i18next"
34

45
export const useBillSort = () => {
56
const now = useRef(new Date().getTime())
7+
const { t } = useTranslation("search")
68

79
// refer to
810
// https://github.com/typesense/typesense-instantsearch-adapter#with-react-instantsearch
911
const items: SortByWithConfigurationItem[] = useMemo(
1012
() => [
1113
{
12-
label: "Sort by Most Recent Testimony",
14+
label: t("sort_by.most_recent_testimony"),
1315
value: "bills/sort/latestTestimonyAt:desc"
1416
},
1517
{
16-
label: "Sort by Relevance",
18+
label: t("sort_by.relevance"),
1719
value: "bills/sort/_text_match:desc,testimonyCount:desc"
1820
},
1921
{
20-
label: "Sort by Testimony Count",
22+
label: t("sort_by.testimony_count"),
2123
value: "bills/sort/testimonyCount:desc"
2224
},
2325
{
24-
label: "Sort by Cosponsor Count",
26+
label: t("sort_by.cosponsor_count"),
2527
value: "bills/sort/cosponsorCount:desc"
2628
},
2729
{
28-
label: "Sort by Next Hearing Date",
30+
label: t("sort_by.next_hearing_date"),
2931
value: "bills/sort/nextHearingAt:asc",
3032
configure: {
3133
numericRefinements: {
@@ -36,7 +38,7 @@ export const useBillSort = () => {
3638
}
3739
}
3840
],
39-
[]
41+
[t]
4042
)
4143
return items
4244
}

0 commit comments

Comments
 (0)