Skip to content

Commit

Permalink
Merge pull request #1827 from hackforla/saumildhankar-1824-implementi…
Browse files Browse the repository at this point in the history
…ng-feature-flags

added feature flag using useFeatureFlag hook
  • Loading branch information
SAUMILDHANKAR authored Sep 29, 2023
2 parents 76ca6ab + 2208f56 commit 59203ab
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 59203ab

Please sign in to comment.