Skip to content

Commit de21324

Browse files
authored
Merge pull request #1753 from mertbagt/bill-search-filters-reorg
Reordered and Renamed Bill Search filters
2 parents 6f6b7d0 + f672cbd commit de21324

File tree

6 files changed

+41
-8
lines changed

6 files changed

+41
-8
lines changed

components/search/bills/BillSearch.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTranslation } from "next-i18next"
12
import {
23
CurrentRefinements,
34
Hits,
@@ -105,6 +106,8 @@ const Layout: FC<
105106
const hierarchicalMenu = useBillHierarchicalMenu()
106107
const status = useSearchStatus()
107108

109+
const { t } = useTranslation("billSearch")
110+
108111
return (
109112
<SearchContainer>
110113
<Row>
@@ -129,9 +132,9 @@ const Layout: FC<
129132
/>
130133
{status === "empty" ? (
131134
<NoResults>
132-
Your search has yielded zero results!
135+
{t("zero_results")}
133136
<br />
134-
<b>Try another search term</b>
137+
<b>{t("another_term")}</b>
135138
</NoResults>
136139
) : (
137140
<Hits hitComponent={BillHit} />

components/search/bills/useBillRefinements.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ import { RefinementListItem } from "instantsearch.js/es/connectors/refinement-li
33
import { useCallback } from "react"
44
import { useRefinements } from "../useRefinements"
55

6+
// for legacy code purposes, things like:
7+
//
8+
// `legislative session` and `session`
9+
//
10+
// are used by variables that are named things like:
11+
//
12+
// `general court` and `court`
13+
//
14+
// see example below:
15+
//
16+
// attribute: "court",
17+
// searchablePlaceholder: "Legislative Session",
18+
619
export const useBillRefinements = () => {
720
const baseProps = { limit: 500, searchable: true }
821
const propsList = [
@@ -18,7 +31,7 @@ export const useBillRefinements = () => {
1831
[]
1932
),
2033
attribute: "court",
21-
searchablePlaceholder: "General Court",
34+
searchablePlaceholder: "Legislative Session",
2235
...baseProps
2336
},
2437
{

components/search/useHierarchicalMenu.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTranslation } from "next-i18next"
12
import { useInstantSearch } from "react-instantsearch"
23
import { faFilter } from "@fortawesome/free-solid-svg-icons"
34
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
@@ -42,13 +43,15 @@ export const useHierarchicalMenu = ({
4243
)
4344
const hasRefinements = useHasRefinements()
4445

46+
const { t } = useTranslation("billSearch")
47+
4548
return {
4649
options: inline ? (
4750
<div>{hierarchicalMenu}</div>
4851
) : (
4952
<Offcanvas show={show} onHide={handleClose}>
5053
<Offcanvas.Header closeButton>
51-
<Offcanvas.Title>Filter</Offcanvas.Title>
54+
<Offcanvas.Title>{t("topics")}</Offcanvas.Title>
5255
</Offcanvas.Header>
5356
<Offcanvas.Body>
5457
<SearchContainer>{hierarchicalMenu}</SearchContainer>
@@ -62,7 +65,7 @@ export const useHierarchicalMenu = ({
6265
onClick={handleOpen}
6366
className={hasRefinements ? "ais-FilterButton-has-refinements" : ""}
6467
>
65-
<FontAwesomeIcon icon={faFilter} /> Filter
68+
<FontAwesomeIcon icon={faFilter} /> {t("topics")}
6669
</FilterButton>
6770
)
6871
}

components/search/useRefinements.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTranslation } from "next-i18next"
12
import { RefinementList, useInstantSearch } from "react-instantsearch"
23
import { faFilter } from "@fortawesome/free-solid-svg-icons"
34
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
@@ -39,13 +40,15 @@ export const useRefinements = ({
3940
)
4041
const hasRefinements = useHasRefinements()
4142

43+
const { t } = useTranslation("billSearch")
44+
4245
return {
4346
options: inline ? (
4447
<div>{refinements}</div>
4548
) : (
4649
<Offcanvas show={show} onHide={handleClose}>
4750
<Offcanvas.Header closeButton>
48-
<Offcanvas.Title>Filter</Offcanvas.Title>
51+
<Offcanvas.Title>{t("filter")}</Offcanvas.Title>
4952
</Offcanvas.Header>
5053
<Offcanvas.Body>
5154
<SearchContainer>{refinements}</SearchContainer>
@@ -59,7 +62,7 @@ export const useRefinements = ({
5962
onClick={handleOpen}
6063
className={hasRefinements ? "ais-FilterButton-has-refinements" : ""}
6164
>
62-
<FontAwesomeIcon icon={faFilter} /> Filter
65+
<FontAwesomeIcon icon={faFilter} /> {t("filter")}
6366
</FilterButton>
6467
)
6568
}

pages/bills/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTranslation } from "next-i18next"
12
import { Container } from "components/bootstrap"
23
import { createPage } from "components/page"
34
import { BillSearch } from "components/search"
@@ -6,9 +7,11 @@ import { createGetStaticTranslationProps } from "components/translations"
67
export default createPage({
78
title: "Browse Bills",
89
Page: () => {
10+
const { t } = useTranslation("billSearch")
11+
912
return (
1013
<Container fluid="md" className="mt-3">
11-
<h1>Browse Bills</h1>
14+
<h1>{t("browse_bills")}</h1>
1215
<BillSearch />
1316
</Container>
1417
)
@@ -17,6 +20,7 @@ export default createPage({
1720

1821
export const getStaticProps = createGetStaticTranslationProps([
1922
"auth",
23+
"billSearch",
2024
"common",
2125
"footer",
2226
"testimony"

public/locales/en/billSearch.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"another_term" : "Try another search term",
3+
"browse_bills" : "Browse Bills",
4+
"filter" : "Filter",
5+
"topics" : "Topics",
6+
"zero_results" : "Your search has yielded zero results!"
7+
}

0 commit comments

Comments
 (0)