Skip to content

Commit

Permalink
List/Map button is dynamic and Fixed Bug in same file (#2146)
Browse files Browse the repository at this point in the history
* list/map button is dynamic

* fixed bug map/list button taking you back to search
  • Loading branch information
93Belen committed Jun 2, 2024
1 parent 3ddb11b commit 6a3477f
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions client/src/components/FoodSeeker/SearchResults/SearchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
useAppDispatch,
useSearchCoordinates,
useStakeholders,
useIsListPanelVisible
useIsListPanelVisible,
usePosition
} from "../../../appReducer";
import Filters from "./ResultsFilters/ResultsFilters";
import List from "./ResultsList/ResultsList";
Expand All @@ -32,6 +33,42 @@ const SearchResults = () => {
);
const stakeholders = useStakeholders();
const organizationId = new URLSearchParams(location.search).get("id");
const positionDraggable = usePosition();

useEffect(() => {
const windowHeightPercentage = window.innerHeight / 100;
const triggerHeightTop = 54 * windowHeightPercentage;

if (positionDraggable.y === 0) {
setShowList(true);
} else if (positionDraggable.y === triggerHeightTop) {
setShowList(false);
}
else {
return
}
console.log(positionDraggable)
}, [positionDraggable]);


// USE EFFECT BASED ON THIS FUNCTION IN Mobile.js
// const handleStop = (e, ui) => {
// const windowHeight = window.innerHeight / 100;
// let newY;
// if (ui.y < 20 * windowHeight) {
// newY = hasAdvancedFilterFeatureFlag ? (100 / window.innerHeight) * 60 : 0;
// } else if (ui.y > 20 * windowHeight && ui.y < 40 * windowHeight) {
// newY = 17;
// } else if (ui.y > 40 * windowHeight) {
// newY = 54;
// }
// setPosition({ x: 0, y: newY * windowHeight });
// };






// If path starts with "widget", then set the state variable isWidget to true,
// so we stay in widget mode (w/o normal App Header and Footer)
Expand Down Expand Up @@ -109,7 +146,6 @@ const SearchResults = () => {
}, [dispatch]);

const toggleShowList = useCallback(() => {
dispatch({ type: "RESET_SELECTED_ORGANIZATION" });
setShowList((showList) => !showList);
}, [dispatch]);

Expand Down

0 comments on commit 6a3477f

Please sign in to comment.