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

ignored .env.local file

added .env.local again
  • Loading branch information
SAUMILDHANKAR committed Sep 28, 2023
1 parent 76ca6ab commit 2208f56
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ dotenv
# required for GitHub action to build react app.
!/client/.env

/client/.env.local

.eslintcache

# End of project-specific exclusions
Expand Down
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 2208f56

Please sign in to comment.