Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Add search filters without separate component
Browse files Browse the repository at this point in the history
  • Loading branch information
acouch committed Jul 1, 2024
1 parent c64f6ff commit cd81d84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,15 @@ export function SearchFilterAccordion({
updateQueryParams(updated, key, queryTerm);
}

const isAllSelected = false;
const isNoneSelected = true;
const isExpanded = query.size ? true: false;

const getAccordionContent = () => (
<>
<SearchFilterToggleAll
onSelectAll={() => toggleSelectAll(true, allSelected)}
onClearAll={() => toggleSelectAll(false, allSelected)}
isAllSelected={isAllSelected}
isNoneSelected={isNoneSelected}
isAllSelected={isSectionAllSelected(allSelected, query)}
isNoneSelected={isSectionNoneSelected(query)}
/>

<ul className="usa-list usa-list--unstyled">
Expand Down Expand Up @@ -133,7 +132,7 @@ export function SearchFilterAccordion({
{
title: getAccordionTitle(),
content: getAccordionContent(),
expanded: false,
expanded: isExpanded,
id: `funding-instrument-filter-${queryParamKey}`,
headingLevel: "h2",
},
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/app/[locale]/look/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ export default function Look({
status?: string;
fundingInstrument?: string;
eligibility?: string;
category?: string;
page?: string;
};
}) {
unstable_setRequestLocale("en");
const t = useTranslations("Process");
const key = Object.entries(searchParams).join(',')
const convertedSearchParams = convertSearchParamsToProperTypes(searchParams);
const { query, status, eligibility, fundingInstrument } = convertedSearchParams;
const { category, eligibility, fundingInstrument, query, status } = convertedSearchParams;

return (
<>
Expand All @@ -60,13 +61,24 @@ export default function Look({
<div className="grid-row grid-gap">
<div className="tablet:grid-col-4">
<SearchOpportunityStatus query={status} />
// TODO: These could be a single component.
<SearchFilterAccordion
options={fundingOptions}
title="Funding instrument"
queryParamKey="fundingInstrument"
query={fundingInstrument}
/>
<SearchFilterAccordion
options={eligibilityOptions}
title="Eligibility"
queryParamKey="eligibility"
query={eligibility}
/>
<SearchFilterAccordion
options={categoryOptions}
title="Category"
queryParamKey="category"
query={category}
/>
</div>
<div className="tablet:grid-col-8">
<Suspense key={key} fallback={<Loading />}>
Expand Down

0 comments on commit cd81d84

Please sign in to comment.