From d45da273f3c4c9d5a525904d275cc2f4bb5c9669 Mon Sep 17 00:00:00 2001 From: acouch Date: Mon, 1 Jul 2024 11:56:21 -0400 Subject: [PATCH] Add agency to page and remove unnecessary components --- .../SearchFilterAccordion.tsx | 14 +- .../SearchFilterSection.tsx | 30 +- .../filterJSONLists/agencyFilterList.ts | 508 ------------------ .../[locale]/look/SearchFilterEligibility.tsx | 113 ---- .../look/SearchFilterFundingInstrument.tsx | 47 -- frontend/src/app/[locale]/look/page.tsx | 19 +- 6 files changed, 45 insertions(+), 686 deletions(-) delete mode 100644 frontend/src/app/[locale]/look/SearchFilterAccordion/filterJSONLists/agencyFilterList.ts delete mode 100644 frontend/src/app/[locale]/look/SearchFilterEligibility.tsx delete mode 100644 frontend/src/app/[locale]/look/SearchFilterFundingInstrument.tsx diff --git a/frontend/src/app/[locale]/look/SearchFilterAccordion/SearchFilterAccordion.tsx b/frontend/src/app/[locale]/look/SearchFilterAccordion/SearchFilterAccordion.tsx index 9d100b2751..6ed314babb 100644 --- a/frontend/src/app/[locale]/look/SearchFilterAccordion/SearchFilterAccordion.tsx +++ b/frontend/src/app/[locale]/look/SearchFilterAccordion/SearchFilterAccordion.tsx @@ -27,6 +27,14 @@ export interface FilterOption { children?: FilterOption[]; } +export interface FilterOptionWithChildren { + id: string; + label: string; + value: string; + isChecked?: boolean; + children: FilterOption[]; +} + interface SearchFilterAccordionProps { options: FilterOption[]; title: string; // Title in header of accordion @@ -43,7 +51,9 @@ export function SearchFilterAccordion({ const { queryTerm } = useContext(QueryContext); const { updateQueryParams } = useSearchParamUpdater2(); const totalCheckedCount = query.size + // These are all of the available selectedable options. const allOptionValues = options.map((options) => options.value); + // This is the setting for if all are selected. const allSelected = new Set(allOptionValues); const getAccordionTitle = () => ( @@ -105,11 +115,11 @@ export function SearchFilterAccordion({ ( // SearchFilterSection will map over all children of this option void; toggleSelectAll: (all: boolean, allSelected: Set) => void; - allSelected: Set accordionTitle: string; isSectionAllSelected: (allSelected: Set, query: Set) => boolean; isSectionNoneSelected: (allSelected: Set, query: Set) => boolean; - query: Set + query: Set; + value: string; } const SearchFilterSection: React.FC = ({ @@ -24,13 +24,25 @@ const SearchFilterSection: React.FC = ({ updateCheckedOption, toggleSelectAll, accordionTitle, - allSelected, query, isSectionAllSelected, isSectionNoneSelected, + value }) => { const [childrenVisible, setChildrenVisible] = useState(false); + const sectionQuery = new Set(); + query.forEach((queryValue) => { + console.log('queryValue:', queryValue, "value:", value) + // The value is treated as a child for some agencies if has children in the UI and so + // is added to the count. + if (queryValue.startsWith(`${value}-`) || query.has(value)) { + sectionQuery.add(queryValue); + } + }); + const allSectionOptionValues = option.children.map((options) => options.value); + const sectionAllSelected = new Set(allSectionOptionValues); + const sectionCount = sectionQuery.size; const getHiddenName = (name: string) => @@ -53,10 +65,10 @@ const SearchFilterSection: React.FC = ({ {childrenVisible ? (
toggleSelectAll(true, allSelected)} - onClearAll={() => toggleSelectAll(false, allSelected)} - isAllSelected={isSectionAllSelected(sectionQuery, sectionQuery)} - isNoneSelected={isSectionNoneSelected(sectionQuery, sectionQuery)} + onSelectAll={() => toggleSelectAll(true, sectionAllSelected)} + onClearAll={() => toggleSelectAll(false, sectionAllSelected)} + isAllSelected={isSectionAllSelected(sectionAllSelected, sectionQuery)} + isNoneSelected={isSectionNoneSelected(sectionAllSelected, sectionQuery)} />
    {option.children?.map((child) => ( diff --git a/frontend/src/app/[locale]/look/SearchFilterAccordion/filterJSONLists/agencyFilterList.ts b/frontend/src/app/[locale]/look/SearchFilterAccordion/filterJSONLists/agencyFilterList.ts deleted file mode 100644 index e8b5ab9541..0000000000 --- a/frontend/src/app/[locale]/look/SearchFilterAccordion/filterJSONLists/agencyFilterList.ts +++ /dev/null @@ -1,508 +0,0 @@ -import { FilterOption } from "../SearchFilterAccordion"; - -export const agencyFilterList: FilterOption[] = [ - { - id: "ARPAH", - label: "Advanced Research Projects Agency for Health (ARPAH)", - value: "ARPAH", - }, - { - id: "USAID", - label: "Agency for International Development (USAID)", - value: "USAID", - children: [ - { - id: "USAID-AFG", - label: "Afghanistan USAID-Kabul (USAID-AFG)", - value: "USAID-AFG", - }, - { - id: "USAID", - label: "Agency for International Development (USAID)", - value: "USAID", - }, - { - id: "USAID-ARM", - label: "Armenia USAID-Yerevan (USAID-ARM)", - value: "USAID-ARM", - }, - { - id: "USAID-AZE", - label: "Azerbaijan USAID-Baku (USAID-AZE)", - value: "USAID-AZE", - }, - { - id: "USAID-BAN", - label: "Bangladesh USAID-Dhaka (USAID-BAN)", - value: "USAID-BAN", - }, - { - id: "USAID-BEN", - label: "Benin USAID-Cotonou (USAID-BEN)", - value: "USAID-BEN", - }, - ], - }, - { - id: "AC", - label: "AmeriCorps (AC)", - value: "AC", - }, - { - id: "DC", - label: "Denali Commission (DC)", - value: "DC", - }, - { - id: "USDA", - label: "Department of Agriculture (USDA)", - value: "USDA", - children: [ - { - id: "USDA-AMS", - label: "Agricultural Marketing Service (USDA-AMS)", - value: "USDA-AMS", - }, - { - id: "USDA-FNS1", - label: "Food and Nutrition Service (USDA-FNS1)", - value: "USDA-FNS1", - }, - ], - }, - { - id: "DOC", - label: "Department of Commerce (DOC)", - value: "DOC", - children: [ - { - id: "DOC-DOCNOAAERA", - label: "DOC NOAA - ERA Production (DOC-DOCNOAAERA)", - value: "DOC-DOCNOAAERA", - }, - { - id: "DOC-EDA", - label: "Economic Development Administration (DOC-EDA)", - value: "DOC-EDA", - }, - { - id: "DOC-NIST", - label: "National Institute of Standards and Technology (DOC-NIST)", - value: "DOC-NIST", - }, - ], - }, - { - id: "DOD", - label: "Department of Defense (DOD)", - value: "DOD", - children: [ - { - id: "DOD-AMC-ACCAPGN", - label: "ACC APG - Natick (DOD-AMC-ACCAPGN)", - value: "DOD-AMC-ACCAPGN", - }, - { - id: "DOD-AMC-ACCAPGD", - label: "ACC-APG-Detrick (DOD-AMC-ACCAPGD)", - value: "DOD-AMC-ACCAPGD", - }, - { - id: "DOD-AFRL-AFRLDET8", - label: "AFRL Kirtland AFB (DOD-AFRL-AFRLDET8)", - value: "DOD-AFRL-AFRLDET8", - }, - { - id: "DOD-AFRL", - label: "Air Force -- Research Lab (DOD-AFRL)", - value: "DOD-AFRL", - }, - { - id: "DOD-USAFA", - label: "Air Force Academy (DOD-USAFA)", - value: "DOD-USAFA", - }, - { - id: "DOD-AFOSR", - label: "Air Force Office of Scientific Research (DOD-AFOSR)", - value: "DOD-AFOSR", - }, - { - id: "DOD-DARPA-BTO", - label: "DARPA - Biological Technologies Office (DOD-DARPA-BTO)", - value: "DOD-DARPA-BTO", - }, - ], - }, - { - id: "ED", - label: "Department of Education (ED)", - value: "ED", - }, - { - id: "DOE", - label: "Department of Energy (DOE)", - value: "DOE", - children: [ - { - id: "DOE-ARPAE", - label: "Advanced Research Projects Agency Energy (DOE-ARPAE)", - value: "DOE-ARPAE", - }, - { - id: "DOE-GFO", - label: "Golden Field Office (DOE-GFO)", - value: "DOE-GFO", - }, - { - id: "DOE-01", - label: "Headquarters (DOE-01)", - value: "DOE-01", - }, - ], - }, - { - id: "PAMS", - label: "Department of Energy - Office of Science (PAMS)", - value: "PAMS", - children: [ - { - id: "PAMS-SC", - label: "Office of Science (PAMS-SC)", - value: "PAMS-SC", - }, - ], - }, - { - id: "HHS", - label: "Department of Health and Human Services (HHS)", - value: "HHS", - children: [ - { - id: "HHS-ACF-FYSB", - label: - "Administration for Children & Families - ACYF/FYSB (HHS-ACF-FYSB)", - value: "HHS-ACF-FYSB", - }, - { - id: "HHS-ACF", - label: "Administration for Children and Families (HHS-ACF)", - value: "HHS-ACF", - }, - { - id: "HHS-ACF-CB", - label: - "Administration for Children and Families - ACYF/CB (HHS-ACF-CB)", - value: "HHS-ACF-CB", - }, - ], - }, - { - id: "DHS", - label: "Department of Homeland Security (DHS)", - value: "DHS", - children: [ - { - id: "DHS-DHS", - label: "Department of Homeland Security - FEMA (DHS-DHS)", - value: "DHS-DHS", - }, - { - id: "DHS-OPO", - label: "Office of Procurement Operations - Grants Division (DHS-OPO)", - value: "DHS-OPO", - }, - { - id: "DHS-USCG", - label: "United States Coast Guard (DHS-USCG)", - value: "DHS-USCG", - }, - ], - }, - { - id: "HUD", - label: "Department of Housing and Urban Development (HUD)", - value: "HUD", - }, - { - id: "USDOJ", - label: "Department of Justice (USDOJ)", - value: "USDOJ", - children: [ - { - id: "USDOJ-OJP-BJA", - label: "Bureau of Justice Assistance (USDOJ-OJP-BJA)", - value: "USDOJ-OJP-BJA", - }, - { - id: "USDOJ-OJP-COPS", - label: "Community Oriented Policing Services (USDOJ-OJP-COPS)", - value: "USDOJ-OJP-COPS", - }, - ], - }, - { - id: "DOL", - label: "Department of Labor (DOL)", - value: "DOL", - children: [ - { - id: "DOL-ETA-ILAB", - label: "Bureau of International Labor Affairs (DOL-ETA-ILAB)", - value: "DOL-ETA-ILAB", - }, - { - id: "DOL-ETA-CEO", - label: "Chief Evaluation Office (DOL-ETA-CEO)", - value: "DOL-ETA-CEO", - }, - ], - }, - { - id: "DOS", - label: "Department of State (DOS)", - value: "DOS", - children: [ - { - id: "DOS-NEA-AC", - label: "Assistance Coordination (DOS-NEA-AC)", - value: "DOS-NEA-AC", - }, - { - id: "DOS-DRL", - label: "Bureau of Democracy Human Rights and Labor (DOS-DRL)", - value: "DOS-DRL", - }, - { - id: "DOS-ECA", - label: "Bureau Of Educational and Cultural Affairs (DOS-ECA)", - value: "DOS-ECA", - }, - ], - }, - { - id: "DOI", - label: "Department of the Interior (DOI)", - value: "DOI", - children: [ - { - id: "DOI-BIA", - label: "Bureau of Indian Affairs (DOI-BIA)", - value: "DOI-BIA", - }, - { - id: "DOI-BLM", - label: "Bureau of Land Management (DOI-BLM)", - value: "DOI-BLM", - }, - { - id: "DOI-BOR", - label: "Bureau of Reclamation (DOI-BOR)", - value: "DOI-BOR", - }, - ], - }, - { - id: "USDOT", - label: "Department of the Treasury (USDOT)", - value: "USDOT", - children: [ - { - id: "USDOT-ORP", - label: "Office of Capital Access (USDOT-ORP)", - value: "USDOT-ORP", - }, - { - id: "USDOT-DO-SIPPRA", - label: "SIPPRA (USDOT-DO-SIPPRA)", - value: "USDOT-DO-SIPPRA", - }, - { - id: "USDOT-GCR", - label: "U.S. Dept. of Treasury RESTORE Act Program (USDOT-GCR)", - value: "USDOT-GCR", - }, - ], - }, - { - id: "DOT", - label: "Department of Transportation (DOT)", - value: "DOT", - children: [ - { - id: "DOT-DOT X-50", - label: "69A345 Office of the Under Secretary for Policy (DOT-DOT X-50)", - value: "DOT-DOT X-50", - }, - { - id: "DOT-RITA", - label: "69A355 Research and Technology (DOT-RITA)", - value: "DOT-RITA", - }, - { - id: "DOT-FAA-FAA ARG", - label: "DOT - FAA Aviation Research Grants (DOT-FAA-FAA ARG)", - value: "DOT-FAA-FAA ARG", - }, - { - id: "DOT-FRA", - label: "DOT - Federal Railroad Administration (DOT-FRA)", - value: "DOT-FRA", - }, - { - id: "DOT-FHWA", - label: "DOT Federal Highway Administration (DOT-FHWA)", - value: "DOT-FHWA", - }, - { - id: "DOT-FTA", - label: "DOT/Federal Transit Administration (DOT-FTA)", - value: "DOT-FTA", - }, - { - id: "DOT-FAA-FAA COE-AJFE", - label: "FAA-COE-AJFE (DOT-FAA-FAA COE-AJFE)", - value: "DOT-FAA-FAA COE-AJFE", - }, - { - id: "DOT-FAA-FAA COE-FAA JAMS", - label: "FAA-COE-JAMS (DOT-FAA-FAA COE-FAA JAMS)", - value: "DOT-FAA-FAA COE-FAA JAMS", - }, - { - id: "DOT-FAA-FAA COE-TTHP", - label: "FAA-COE-TTHP (DOT-FAA-FAA COE-TTHP)", - value: "DOT-FAA-FAA COE-TTHP", - }, - { - id: "DOT-MA", - label: "Maritime Administration (DOT-MA)", - value: "DOT-MA", - }, - { - id: "DOT-NHTSA", - label: "National Highway Traffic Safety Administration (DOT-NHTSA)", - value: "DOT-NHTSA", - }, - ], - }, - { - id: "VA", - label: "Department of Veterans Affairs (VA)", - value: "VA", - children: [ - { - id: "VA-CSHF", - label: "Construction of State Home Facilities (VA-CSHF)", - value: "VA-CSHF", - }, - { - id: "VA-HPGPDP", - label: "Homeless Providers Grant and Per Diem Program (VA-HPGPDP)", - value: "VA-HPGPDP", - }, - { - id: "VA-LSV", - label: "Legal Services for Veterans (VA-LSV)", - value: "VA-LSV", - }, - { - id: "VA-NVSP", - label: "National Veterans Sports Programs (VA-NVSP)", - value: "VA-NVSP", - }, - { - id: "VA-NCAC", - label: "NCA Contracting (VA-NCAC)", - value: "VA-NCAC", - }, - { - id: "VA-OMHSP", - label: "Office of Mental Health and Suicide Prevention (VA-OMHSP)", - value: "VA-OMHSP", - }, - { - id: "VA-SSVF", - label: "Supportive Services for Veteran Families (VA-SSVF)", - value: "VA-SSVF", - }, - { - id: "VA-NCA", - label: "VA National Cemetery Administration (VA-NCA)", - value: "VA-NCA", - }, - { - id: "VA-VLGP", - label: "Veterans Legacy Grants Program (VA-VLGP)", - value: "VA-VLGP", - }, - ], - }, - { - id: "EPA", - label: "Environmental Protection Agency (EPA)", - value: "EPA", - }, - { - id: "IMLS", - label: "Institute of Museum and Library Services (IMLS)", - value: "IMLS", - }, - { - id: "MCC", - label: "Millennium Challenge Corporation (MCC)", - value: "MCC", - }, - { - id: "NASA", - label: "National Aeronautics and Space Administration (NASA)", - value: "NASA", - children: [ - { - id: "NASA-HQ", - label: "NASA Headquarters (NASA-HQ)", - value: "NASA-HQ", - }, - { - id: "NASA-JSC", - label: "NASA Johnson Space Center (NASA-JSC)", - value: "NASA-JSC", - }, - { - id: "NASA-SFC", - label: "NASA Marshall Space Flight Center (NASA-SFC)", - value: "NASA-SFC", - }, - { - id: "NASA", - label: "National Aeronautics and Space Administration (NASA)", - value: "NASA", - }, - ], - }, - { - id: "NARA", - label: "National Archives and Records Administration (NARA)", - value: "NARA", - }, - { - id: "NEA", - label: "National Endowment for the Arts (NEA)", - value: "NEA", - }, - { - id: "NEH", - label: "National Endowment for the Humanities (NEH)", - value: "NEH", - }, - { - id: "NSF", - label: "National Science Foundation (NSF)", - value: "NSF", - }, - { - id: "SSA", - label: "Social Security Administration (SSA)", - value: "SSA", - }, -]; diff --git a/frontend/src/app/[locale]/look/SearchFilterEligibility.tsx b/frontend/src/app/[locale]/look/SearchFilterEligibility.tsx deleted file mode 100644 index 258cf29137..0000000000 --- a/frontend/src/app/[locale]/look/SearchFilterEligibility.tsx +++ /dev/null @@ -1,113 +0,0 @@ -"use client"; - -import { - FilterOption, - SearchFilterAccordion, -} from "./SearchFilterAccordion/SearchFilterAccordion"; - -export interface SearchFilterProps { - query: Set; -} - -const initialFilterOptions: FilterOption[] = [ - { - id: "eligibility-state_governments", - label: "State Governments", - value: "state_governments", - }, - { - id: "eligibility-county_governments", - label: "County Governments", - value: "county_governments", - }, - { - id: "eligibility-city_or_township_governments", - label: "City or Township Governments", - value: "city_or_township_governments", - }, - { - id: "eligibility-special_district_governments", - label: "Special District Governments", - value: "special_district_governments", - }, - { - id: "eligibility-independent_school_districts", - label: "Independent School Districts", - value: "independent_school_districts", - }, - { - id: "eligibility-public_and_state_institutions_of_higher_education", - label: "Public and State Institutions of Higher Education", - value: "public_and_state_institutions_of_higher_education", - }, - { - id: "eligibility-private_institutions_of_higher_education", - label: "Private Institutions of Higher Education", - value: "private_institutions_of_higher_education", - }, - { - id: "eligibility-federally_recognized_native_american_tribal_governments", - label: "Federally Recognized Native American Tribal Governments", - value: "federally_recognized_native_american_tribal_governments", - }, - { - id: "eligibility-other_native_american_tribal_organizations", - label: "Other Native American Tribal Organizations", - value: "other_native_american_tribal_organizations", - }, - { - id: "eligibility-public_and_indian_housing_authorities", - label: "Public and Indian Housing Authorities", - value: "public_and_indian_housing_authorities", - }, - { - id: "eligibility-nonprofits_non_higher_education_with_501c3", - label: "Nonprofits Non Higher Education with 501c3", - value: "nonprofits_non_higher_education_with_501c3", - }, - { - id: "eligibility-nonprofits_non_higher_education_without_501c3", - label: - "Nonprofits having a 501(c)(3) status with the IRS, other than institutions of higher education", - value: "nonprofits_non_higher_education_without_501c3", - }, - { - id: "eligibility-individuals", - label: "Individuals", - value: "individuals", - }, - { - id: "eligibility-for_profit_organizations_other_than_small_businesses", - label: "For-Profit Organizations Other Than Small Businesses", - value: "for_profit_organizations_other_than_small_businesses", - }, - { - id: "eligibility-small_businesses", - label: "Small Businesses", - value: "small_businesses", - }, - { - id: "eligibility-other", - label: "Other", - value: "other", - }, - { - id: "eligibility-unrestricted", - label: "Unrestricted", - value: "unrestricted", - }, -]; - -export default function SearchFilterEligibility({ - query, -}: SearchFilterProps) { - - return ( - - ); -} diff --git a/frontend/src/app/[locale]/look/SearchFilterFundingInstrument.tsx b/frontend/src/app/[locale]/look/SearchFilterFundingInstrument.tsx deleted file mode 100644 index eaff657bf9..0000000000 --- a/frontend/src/app/[locale]/look/SearchFilterFundingInstrument.tsx +++ /dev/null @@ -1,47 +0,0 @@ -"use client"; - -import { - FilterOption, - SearchFilterAccordion, -} from "./SearchFilterAccordion/SearchFilterAccordion"; - -export interface SearchFilterProps { - query: Set; -} - -const initialFilterOptions: FilterOption[] = [ - { - id: "funding-instrument-cooperative_agreement", - label: "Cooperative Agreement", - value: "cooperative_agreement", - }, - { - id: "funding-instrument-grant", - label: "Grant", - value: "grant", - }, - { - id: "funding-instrument-procurement_contract", - label: "Procurement Contract ", - value: "procurement_contract", - }, - { - id: "funding-instrument-other", - label: "Other", - value: "other", - }, -]; - -export default function SearchFilterFundingInstrument({ - query, -}: SearchFilterProps) { - - return ( - - ); -} diff --git a/frontend/src/app/[locale]/look/page.tsx b/frontend/src/app/[locale]/look/page.tsx index 2ed3b8cef9..7a8dd8c90c 100644 --- a/frontend/src/app/[locale]/look/page.tsx +++ b/frontend/src/app/[locale]/look/page.tsx @@ -13,8 +13,6 @@ import Loading from "src/app/[locale]/search/loading"; import SearchResultsList from "./SearchResultList"; import QueryProvider from "./QueryProvider"; import SearchOpportunityStatus from "./SearchOpportunityStatus"; -import SearchFilterFundingInstrument from "./SearchFilterFundingInstrument"; -import SearchFilterEligibility from "./SearchFilterEligibility"; import SearchFilterAccordion from "./SearchFilterAccordion/SearchFilterAccordion"; import { convertSearchParamsToProperTypes } from "src/utils/search/convertSearchParamsToProperTypes"; @@ -33,19 +31,20 @@ export default function Look({ searchParams, }: { searchParams: { - query?: string; - status?: string; - fundingInstrument?: string; - eligibility?: string; + agency?: string; category?: string; + eligibility?: string; + fundingInstrument?: string; page?: string; + query?: string; + status?: string; }; }) { unstable_setRequestLocale("en"); const t = useTranslations("Process"); const key = Object.entries(searchParams).join(',') const convertedSearchParams = convertSearchParamsToProperTypes(searchParams); - const { category, eligibility, fundingInstrument, query, status } = convertedSearchParams; + const { agency, category, eligibility, fundingInstrument, query, status } = convertedSearchParams; return ( <> @@ -73,6 +72,12 @@ export default function Look({ queryParamKey="eligibility" query={eligibility} /> +