Skip to content

Commit

Permalink
added feature flag using useFeatureFlag hook
Browse files Browse the repository at this point in the history
added env local to git ignore

updated address of .env.local file in gitignore
  • Loading branch information
SAUMILDHANKAR committed Sep 28, 2023
1 parent 76ca6ab commit 3258ee2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ dotenv
# React .env SHOULD be in repo - it has no secrets, and is
# required for GitHub action to build react app.
!/client/.env
/client/.env.local

.eslintcache

Expand Down
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 3258ee2

Please sign in to comment.