From 987399407b8f71a35c4b3cf0bad9b74d4a2f9dd3 Mon Sep 17 00:00:00 2001 From: Neha Date: Tue, 3 Dec 2024 21:41:54 -0800 Subject: [PATCH] [feat] status functionality with bugs --- api/supabase/queries/query.ts | 1 - components/Filter/index.tsx | 2 ++ components/MapViewScreen/index.tsx | 18 ++++++++++++++---- components/ProjectItem/index.tsx | 2 +- components/StatusDropdown/index.tsx | 13 ++++++++++--- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/api/supabase/queries/query.ts b/api/supabase/queries/query.ts index 2a1b243..28ab68b 100644 --- a/api/supabase/queries/query.ts +++ b/api/supabase/queries/query.ts @@ -29,7 +29,6 @@ export async function queryProjectbyId(id: number): Promise { } export async function queryDefaultImages(category: string) { - console.log('Fetching default image for category:', category); const { data: defaultImage, error } = await supabase .from('Renewable Energy Technology') .select('*') diff --git a/components/Filter/index.tsx b/components/Filter/index.tsx index a95f799..a720b0c 100644 --- a/components/Filter/index.tsx +++ b/components/Filter/index.tsx @@ -51,6 +51,8 @@ export default function Filter({ icon={filter.icon} label={filter.label} currFilter={filter} + handleFilterButtonClick={handleFilterButtonClick} + clearFilters={clearFilters} /> ) : // Add other filter dropdown components here null diff --git a/components/MapViewScreen/index.tsx b/components/MapViewScreen/index.tsx index 55794cb..122bbee 100644 --- a/components/MapViewScreen/index.tsx +++ b/components/MapViewScreen/index.tsx @@ -78,11 +78,21 @@ export default function MapViewScreen({ const handleFilterButtonClick = () => { /* eslint-disable @typescript-eslint/no-unused-vars */ const { status, technology, projectSize, location } = selectedFilters; + let filteredProjects = projects; + // add all filtering logic here - const technologyProjects = projects?.filter(project => - technology.includes(project.renewable_energy_technology), - ); - setFilteredProjectsFromDropdowns(technologyProjects); + if (technology.length > 0) { + filteredProjects = filteredProjects.filter(project => + technology.includes(project.renewable_energy_technology), + ); + } + + if (status.length > 0) { + filteredProjects = filteredProjects.filter(project => + status.includes(project.project_status), + ); + } + setFilteredProjectsFromDropdowns(filteredProjects); }; // search within all projects or filtered projects from dropdowns diff --git a/components/ProjectItem/index.tsx b/components/ProjectItem/index.tsx index b79f5b6..381cc37 100644 --- a/components/ProjectItem/index.tsx +++ b/components/ProjectItem/index.tsx @@ -97,7 +97,7 @@ export default function ProjectItem({ // Sets status label to "Operational" or "In Progress" let projectStatus = project_status; if (project_status !== 'Operational') { - projectStatus = 'In Progress'; + projectStatus = 'Proposed'; } // Sets status icon to OperationalIcon or InProgressIcon diff --git a/components/StatusDropdown/index.tsx b/components/StatusDropdown/index.tsx index b97ba8b..0c3d1d4 100644 --- a/components/StatusDropdown/index.tsx +++ b/components/StatusDropdown/index.tsx @@ -27,6 +27,8 @@ interface StatusDropdownProps { icon: React.ReactNode; label: string; currFilter: FilterType; + handleFilterButtonClick: () => void; + clearFilters: () => void; } export default function StatusDropdown({ @@ -36,9 +38,11 @@ export default function StatusDropdown({ icon, label, currFilter, + handleFilterButtonClick, + clearFilters, }: StatusDropdownProps) { const filterOptions = [ - { title: 'In Progress', color: `${COLORS.ashGrey}` }, + { title: 'Proposed', color: `${COLORS.ashGrey}` }, { title: 'Operational', color: `${COLORS.chateauGreen}` }, ]; @@ -58,7 +62,7 @@ export default function StatusDropdown({ {label} - + @@ -79,7 +83,10 @@ export default function StatusDropdown({ ))} - + APPLY