Skip to content

Commit

Permalink
added feature flag using useFeatureFlag hook
Browse files Browse the repository at this point in the history
  • Loading branch information
SAUMILDHANKAR committed Sep 27, 2023
1 parent 1f0824d commit f0e8693
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions client/.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_FEATURE_FLAGS=["advancedFilter"]
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
} from "../../../../appReducer";
import "mapbox-gl/dist/mapbox-gl.css";
import { useNavigate, useLocation } from "react-router-dom";
import useFeatureFlag from "hooks/useFeatureFlag";

const ResultsMap = (
{
Expand Down Expand Up @@ -78,6 +79,8 @@ const ResultsMap = (
const regionGeoJSON = neighborhood?.geojson;
const startIconCoordinates = searchCoordinates || userCoordinates;

const hasAdvancedFilterFeatureFlag = useFeatureFlag("advancedFilter");

useEffect(() => {
analytics.postEvent("showMap");
}, []);
Expand Down Expand Up @@ -202,15 +205,18 @@ const ResultsMap = (
<Map.Layer {...regionBorderStyle} />
</Map.Source>
)}
<Button
variant="outlined"
onClick={searchMapArea}
size="small"
className={classes.searchButton}
disabled={loading}
>
Search this area
</Button>

{!hasAdvancedFilterFeatureFlag && (
<Button
variant="outlined"
onClick={searchMapArea}
size="small"
className={classes.searchButton}
disabled={loading}
>
Search this area
</Button>
)}
</ReactMapGL>
);
};
Expand Down
5 changes: 5 additions & 0 deletions client/src/hooks/useFeatureFlag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function useFeatureFlag(flagName) {
const featureFlags = JSON.parse(process.env.REACT_APP_FEATURE_FLAGS || "[]");

return featureFlags.includes(flagName);
}

0 comments on commit f0e8693

Please sign in to comment.