Skip to content

Commit daeebe5

Browse files
committed
Merge branch 'main' of https://github.com/kiminkim724/maple into fix-mobile-filters
2 parents 906d05f + 42252d0 commit daeebe5

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

components/bill/BillDetails.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,11 @@ import { useTranslation } from "next-i18next"
1717
import { isCurrentCourt } from "functions/src/shared"
1818
import { FollowBillButton } from "components/shared/FollowButton"
1919
import { PendingUpgradeBanner } from "components/PendingUpgradeBanner"
20-
import { FollowContext, OrgFollowStatus } from "components/shared/FollowContext"
21-
import { useState } from "react"
2220

2321
const StyledContainer = styled(Container)`
2422
font-family: "Nunito";
2523
`
2624

27-
const StyledImage = styled(Image)`
28-
width: 14.77px;
29-
height: 12.66px;
30-
31-
margin-left: 8px;
32-
`
33-
3425
export const BillDetails = ({ bill }: BillProps) => {
3526
const { t } = useTranslation("common")
3627

components/search/bills/BillHit.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import styled from "styled-components"
1313
import { Card, Col } from "../../bootstrap"
1414
import { formatBillId } from "../../formatting"
1515
import { Timestamp } from "firebase/firestore"
16-
import { DateTime } from "luxon"
1716
import { dateInFuture } from "components/db/events"
1817

1918
type BillRecord = {
@@ -132,11 +131,7 @@ export const DisplayUpcomingHearing = ({
132131

133132
export const BillHit = ({ hit }: { hit: Hit<BillRecord> }) => {
134133
const url = maple.bill({ id: hit.number, court: hit.court })
135-
const today = new Date()
136134
const hearingDate = hit.nextHearingAt && hit.nextHearingAt / 1000 // convert to seconds
137-
const isUpcomingHearing = hearingDate
138-
? today < fromUnixTime(hearingDate)
139-
: false
140135

141136
return (
142137
<Link href={url} legacyBehavior>

components/search/bills/BillSearch.tsx

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useTranslation } from "next-i18next"
1+
import { TFunction, useTranslation } from "next-i18next"
22
import {
33
CurrentRefinements,
44
Hits,
@@ -10,7 +10,7 @@ import {
1010
import { currentGeneralCourt } from "functions/src/shared"
1111
import styled from "styled-components"
1212
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter"
13-
import { Col, Row } from "../../bootstrap"
13+
import { Col, Container, Row, Spinner } from "../../bootstrap"
1414
import { NoResults } from "../NoResults"
1515
import { ResultCount } from "../ResultCount"
1616
import { SearchContainer } from "../SearchContainer"
@@ -21,7 +21,7 @@ import { useBillRefinements } from "./useBillRefinements"
2121
import { SortBy, SortByWithConfigurationItem } from "../SortBy"
2222
import { getServerConfig, VirtualFilters } from "../common"
2323
import { useBillSort } from "./useBillSort"
24-
import { FC } from "react"
24+
import { FC, useState } from "react"
2525

2626
const searchClient = new TypesenseInstantSearchAdapter({
2727
server: getServerConfig(),
@@ -100,6 +100,47 @@ const useSearchStatus = () => {
100100
}
101101
}
102102

103+
const StyledLoadingContainer = styled(Container)`
104+
background-color: white;
105+
display: flex;
106+
height: 300px;
107+
justify-content: center;
108+
align-items: center;
109+
`
110+
111+
const Results = ({
112+
status,
113+
t
114+
}: {
115+
status: ReturnType<typeof useSearchStatus>
116+
t: TFunction
117+
}) => {
118+
const [isLoadingBillDetails, setIsLoadingBillDetails] = useState(false)
119+
120+
if (isLoadingBillDetails) {
121+
return (
122+
<StyledLoadingContainer>
123+
<Spinner animation="border" className="mx-auto" />
124+
</StyledLoadingContainer>
125+
)
126+
} else if (status === "empty") {
127+
return (
128+
<NoResults>
129+
{t("zero_results")}
130+
<br />
131+
<b>{t("another_term")}</b>
132+
</NoResults>
133+
)
134+
} else {
135+
return (
136+
<Hits
137+
hitComponent={BillHit}
138+
onClick={() => setIsLoadingBillDetails(true)}
139+
/>
140+
)
141+
}
142+
}
143+
103144
const Layout: FC<
104145
React.PropsWithChildren<{ items: SortByWithConfigurationItem[] }>
105146
> = ({ items }) => {
@@ -128,15 +169,7 @@ const Layout: FC<
128169
excludedAttributes={["nextHearingAt"]}
129170
transformItems={extractLastSegmentOfRefinements}
130171
/>
131-
{status === "empty" ? (
132-
<NoResults>
133-
{t("zero_results")}
134-
<br />
135-
<b>{t("another_term")}</b>
136-
</NoResults>
137-
) : (
138-
<Hits hitComponent={BillHit} />
139-
)}
172+
<Results status={status} t={t} />
140173
<Pagination className="mx-auto mt-2 mb-3" />
141174
</Col>
142175
</Row>

0 commit comments

Comments
 (0)