From d80301370500a0dd3cb3830ae54e54c0abb189da Mon Sep 17 00:00:00 2001 From: Nicole Date: Tue, 14 Jan 2025 19:41:56 -0800 Subject: [PATCH] Revert "frontend - add clear filter button #5275 (#5413)" This reverts commit a670d24e8702ab6d294b5e528aaa9cb0d57ab893. --- .../useNotificationSettings.test.ts | 2 +- app/web/features/search/FilterDialog.tsx | 2 +- app/web/features/search/MapWrapper.tsx | 58 +++----------- app/web/features/search/SearchPage.test.tsx | 7 -- app/web/features/search/SearchPage.tsx | 58 ++++---------- app/web/features/search/locales/en.json | 80 +++++++++---------- 6 files changed, 68 insertions(+), 139 deletions(-) diff --git a/app/web/features/auth/notifications/useNotificationSettings.test.ts b/app/web/features/auth/notifications/useNotificationSettings.test.ts index 2552ed9042..50855f1346 100644 --- a/app/web/features/auth/notifications/useNotificationSettings.test.ts +++ b/app/web/features/auth/notifications/useNotificationSettings.test.ts @@ -56,7 +56,7 @@ describe("useNotificationSettings", () => { service.notifications.getNotificationSettings ).toHaveBeenCalledTimes(1) ); - await waitFor(() => expect(result.current.data).toEqual(mockData)); + expect(result.current.data).toEqual(mockData); }); it("should return an error when the request fails", async () => { diff --git a/app/web/features/search/FilterDialog.tsx b/app/web/features/search/FilterDialog.tsx index 09057667d9..7b864ae72e 100644 --- a/app/web/features/search/FilterDialog.tsx +++ b/app/web/features/search/FilterDialog.tsx @@ -347,7 +347,7 @@ export default function FilterDialog({ className={classes.noMargin} type="number" variant="standard" - value={numberOfGuestFilter || ""} + value={numberOfGuestFilter} inputProps={{ min: 0 }} onChange={handleNumGuestsChange} fullWidth diff --git a/app/web/features/search/MapWrapper.tsx b/app/web/features/search/MapWrapper.tsx index dd96580f97..4883181aa4 100644 --- a/app/web/features/search/MapWrapper.tsx +++ b/app/web/features/search/MapWrapper.tsx @@ -1,6 +1,5 @@ import ReplayIcon from "@mui/icons-material/Replay"; import TuneIcon from "@mui/icons-material/Tune"; -import { useMediaQuery } from "@mui/material"; import Button from "components/Button"; import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner"; import Map from "components/Map"; @@ -30,7 +29,6 @@ import { useState, } from "react"; import { InfiniteData } from "react-query"; -import { theme } from "theme"; import { GeocodeResult, usePrevious } from "utils/hooks"; import makeStyles from "utils/makeStyles"; @@ -56,7 +54,7 @@ const useStyles = makeStyles((theme) => ({ width: "100%", }, testChildFromGoogle: { - width: "365px", + width: "300px", top: "30px", display: "flex", position: "relative", @@ -64,23 +62,19 @@ const useStyles = makeStyles((theme) => ({ fontSize: " 14px", margin: "8px auto 0", alignItems: "center", + height: "25px", - zIndex: 1, - }, - searchHereButton: { - borderRadius: "4px", - marginRight: theme.spacing(1), - }, - clearFiltersButton: { - borderRadius: "4px", - marginRight: theme.spacing(1), + zIndex: 10, }, buttonSearchSettings: { - borderRadius: "4px", + borderRadius: "0 4px 4px 0", "& span": { margin: 0, }, }, + searchHereButton: { + borderRadius: "4px 0 0 4px", + }, })); interface mapWrapperProps { @@ -96,8 +90,6 @@ interface mapWrapperProps { map: MutableRefObject; setWasSearchPerformed: Dispatch>; wasSearchPerformed: boolean; - areFiltersCleared: boolean; - onClearFiltersClick: () => void; } export default function MapWrapper({ @@ -111,8 +103,6 @@ export default function MapWrapper({ setIsFiltersOpen, wasSearchPerformed, setWasSearchPerformed, - areFiltersCleared, - onClearFiltersClick, }: mapWrapperProps) { const { t } = useTranslation([SEARCH]); const [areClustersLoaded, setAreClustersLoaded] = useState(false); @@ -120,7 +110,6 @@ export default function MapWrapper({ const [isMapSourceLoaded, setIsMapSourceLoaded] = useState(false); const previousResult = usePrevious(selectedResult); const classes = useStyles(); - const isMobile = useMediaQuery(theme.breakpoints.down("md")); /** * User clicks on a user on map @@ -240,11 +229,7 @@ export default function MapWrapper({ * Re-renders users list on map (when results array changed) */ useEffect(() => { - if ( - isMapStyleLoaded && - isMapSourceLoaded && - (wasSearchPerformed || areFiltersCleared) - ) { + if (isMapStyleLoaded && isMapSourceLoaded && wasSearchPerformed) { if (results) { const usersToRender = filterData(results); reRenderUsersOnMap(map.current!, usersToRender, handleMapUserClick); @@ -257,19 +242,17 @@ export default function MapWrapper({ isMapStyleLoaded, isMapSourceLoaded, wasSearchPerformed, - areFiltersCleared, ]); /** * Clicks on 'search here' button */ - const handleSearchOnClick = () => { + const handleOnClick = () => { const currentBbox = map.current?.getBounds().toArray(); if (currentBbox) { if (map.current?.getBounds && locationResult) { - // Reset location but persist map position setLocationResult({ - location: new LngLat(0, 0), + ...locationResult, name: "", simplifiedName: "", bbox: [ @@ -284,13 +267,6 @@ export default function MapWrapper({ } }; - /** - * Clicks on 'clear filters' button - */ - const handleClearFiltersClick = () => { - onClearFiltersClick(); - }; - const initializeMap = (newMap: MaplibreMap) => { map.current = newMap; newMap.on("load", () => { @@ -315,21 +291,11 @@ export default function MapWrapper({ -