Skip to content

Commit

Permalink
chore: remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
hueyy committed Jan 17, 2023
1 parent 7d9f563 commit 2e392bb
Showing 1 changed file with 16 additions and 40 deletions.
56 changes: 16 additions & 40 deletions src/Popup/components/QueryResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,22 @@ const QueryResult: FunctionComponent<Props> = ({ searchResult, downloadPDF, isSe

const showMore = morePressed || searchResult.length <= maxResults

const resultType: Law.Type = searchResult[0]?.type
if(resultType === `case-citation` || resultType === `case-name`){
return (
<div className="flex flex-col mt-2 items-start content-start gap-4">
{
(searchResult as Law.Case[])
.slice(0, showMore ? undefined : maxResults)
.map((result) => (
<CaseResult
case={result}
downloadPDF={downloadPDF}
key={`${result.name}-${result.citation}`}
/>
))
}
{ showMore ? null : <ShowMore onClick={onShowMore} /> }
</div>
)
} else if (resultType === `legislation`){
return (
<div className="flex flex-col mt-2 items-start content-start gap-4">
{
(searchResult as Law.Legislation[])
.slice(0, showMore ? undefined: maxResults)
.map((legislation) => {
const { provisionType, provisionNumber, statute } = legislation
return (
<LegislationResult
legislation={legislation}
downloadPDF={downloadPDF}
key={`${provisionType}-${provisionNumber}-${statute}`}
/>
)
})
}
{ showMore ? null : <ShowMore onClick={onShowMore} /> }
</div>
)
}
return null
return (
<div className="flex flex-col mt-2 items-start content-start gap-4">
{
(searchResult as Law.Case[])
.slice(0, showMore ? undefined : maxResults)
.map((result) => (
<CaseResult
case={result}
downloadPDF={downloadPDF}
key={`${result.name}-${result.citation}`}
/>
))
}
{ showMore ? null : <ShowMore onClick={onShowMore} /> }
</div>
)
}

export default QueryResult

0 comments on commit 2e392bb

Please sign in to comment.