diff --git a/api/maps/AddMarkers.tsx b/api/maps/AddMarkers.tsx index 3573d1f..a493026 100644 --- a/api/maps/AddMarkers.tsx +++ b/api/maps/AddMarkers.tsx @@ -90,7 +90,6 @@ export default function AddMarker({ return mapZoom; }; */ - const clusterer = useMemo(() => { if (!map) return null; @@ -129,6 +128,18 @@ export default function AddMarker({ onClusterClick: clusterHandler, }); + /*setClusterer.addListener('click', function (cluster: Cluster) { + const mapZoom = map.getZoom() ?? 0; + const minZoom = getMinZoom(cluster, mapZoom); + + if (mapZoom && mapZoom < minZoom) { + const idleListener = map.addListener('idle', function () { + map.setZoom(minZoom); + idleListener.remove(); + }); + } + });*/ + return setClusterer; }, [map]); diff --git a/components/Filter/index.tsx b/components/Filter/index.tsx index a95f799..f94a02d 100644 --- a/components/Filter/index.tsx +++ b/components/Filter/index.tsx @@ -16,8 +16,6 @@ interface FilterProps { selectedFilters: Filters; filterChangeHandlers: FilterChangeHandlers; handleButtonClick: (filter: FilterType) => void; - handleFilterButtonClick: () => void; - clearFilters: () => void; } export default function Filter({ @@ -26,8 +24,6 @@ export default function Filter({ selectedFilters, filterChangeHandlers, handleButtonClick, - handleFilterButtonClick, - clearFilters, }: FilterProps) { return ( @@ -40,8 +36,6 @@ export default function Filter({ icon={filter.icon} label={filter.label} currFilter={filter} - handleFilterButtonClick={handleFilterButtonClick} - clearFilters={clearFilters} /> ) : filter.id === 'status' ? ( void; selectedFilters: Filters; setSelectedFilters: React.Dispatch>; - handleFilterButtonClick: () => void; - clearFilters: () => void; }) => { const [activeFilter, setActiveFilter] = useState(null); const handleButtonClick = (filter: FilterType) => { setActiveFilter(activeFilter?.id === filter.id ? null : filter); + onFilterChange(filter); }; const handleTechnologyChange = (options: string[]) => { @@ -53,8 +52,6 @@ export const FilterBar = ({ selectedFilters={selectedFilters} filterChangeHandlers={filterChangeHandlers} handleButtonClick={handleButtonClick} - handleFilterButtonClick={handleFilterButtonClick} - clearFilters={clearFilters} /> ))} diff --git a/components/MapViewScreen/index.tsx b/components/MapViewScreen/index.tsx index 833a133..a9e2ccf 100644 --- a/components/MapViewScreen/index.tsx +++ b/components/MapViewScreen/index.tsx @@ -56,70 +56,29 @@ export default function MapViewScreen({ projectSize: { min: 0, max: 0 }, location: [], }); - const [filteredProjectsFromDropdowns, setFilteredProjectsFromDropdowns] = - useState(projects); - const [filteredProjectsFromSearch, setFilteredProjectsFromSearch] = - useState(projects); - - // clear filters - const clearFilters = () => { - setSelectedFilters({ - status: [], - technology: [], - projectSize: { min: 0, max: 0 }, - location: [], - }); - setFilteredProjects(projects); - setFilteredProjectsFromDropdowns(projects); - }; - - // show projects based on selected filters - const handleFilterButtonClick = () => { - /* eslint-disable @typescript-eslint/no-unused-vars */ - const { status, technology, projectSize, location } = selectedFilters; - // add all filtering logic here - const technologyProjects = projects?.filter(project => - technology.includes(project.renewable_energy_technology), - ); - setFilteredProjectsFromDropdowns(technologyProjects); + const handleFilterChange = (filter: FilterType) => { + console.log(filter); }; - // search within all projects or filtered projects from dropdowns useEffect(() => { - let projectsToSearch: Project[] = []; - - if (filteredProjectsFromDropdowns.length > 0) { - projectsToSearch = filteredProjectsFromDropdowns; - } else { - projectsToSearch = projects; - } - - const searchedProjects: Project[] = - projectsToSearch?.filter(project => + let filtered: Project[] = []; + filtered = + projects?.filter(project => project.project_name.toLowerCase().includes(searchTerm.toLowerCase()), - ) ?? []; + ) ?? null; - setFilteredProjectsFromSearch(searchedProjects); - }, [projects, searchTerm, filteredProjectsFromDropdowns]); - - useEffect(() => { - setFilteredProjects(filteredProjectsFromDropdowns); - }, [filteredProjectsFromDropdowns, setFilteredProjects]); - - useEffect(() => { - setFilteredProjects(filteredProjectsFromSearch); - }, [filteredProjectsFromSearch, setFilteredProjects]); + setFilteredProjects(filtered); + }, [projects, searchTerm, setFilteredProjects]); return ( <> void; - clearFilters: () => void; } export default function TechnologyDropdown({ @@ -47,8 +44,6 @@ export default function TechnologyDropdown({ icon, label, currFilter, - handleFilterButtonClick, - clearFilters, }: TechnologyDropdownProps) { const filter = { categories: [ @@ -143,14 +138,12 @@ export default function TechnologyDropdown({ return ( - - handleButtonClick(currFilter)}> - {icon} - - handleButtonClick(currFilter)}> + handleButtonClick(currFilter)}> + {icon} + {label} - + @@ -176,10 +169,7 @@ export default function TechnologyDropdown({ ))} ))} - + APPLY diff --git a/components/TechnologyDropdown/styles.ts b/components/TechnologyDropdown/styles.ts index 97e2c61..89a5a57 100644 --- a/components/TechnologyDropdown/styles.ts +++ b/components/TechnologyDropdown/styles.ts @@ -72,12 +72,6 @@ export const ButtonWithIconStyles = styled.div` cursor: pointer; `; -export const FilterIconStyles = styled.div` - display: flex; - align-items: center; - flex-direction: row; -`; - export const IconStyles = styled.div` width: '3rem', height: '3rem',