1
1
import { useAuth } from "react-oidc-context" ;
2
- import React , { useContext } from "react" ;
2
+ import { useContext } from "react" ;
3
3
4
4
import { IDPS } from "../../types/idp" ;
5
5
import "./NavIconSideBar.scss" ;
6
6
import OnRouteBCContext from "../../../common/authentication/OnRouteBCContext" ;
7
- import { USER_ROLE } from "../../../common/authentication/types" ;
8
7
import { NavIconHomeButton } from "./NavIconHomeButton" ;
9
8
import { NavIconReportButton } from "./NavIconReportButton" ;
10
9
import { NavIconBFCTButton } from "./NavIconBFCTButton" ;
11
10
import { useFeatureFlagsQuery } from "../../hooks/hooks" ;
11
+ import { usePermissionMatrix } from "../../authentication/PermissionMatrix" ;
12
12
13
13
/**
14
14
* Displays a sidebar with NavIcon buttons as children
@@ -17,22 +17,35 @@ export const NavIconSideBar = () => {
17
17
const { isAuthenticated, user } = useAuth ( ) ;
18
18
const { idirUserDetails } = useContext ( OnRouteBCContext ) ;
19
19
const isIdir = user ?. profile ?. identity_provider === IDPS . IDIR ;
20
- const isEofficer =
21
- idirUserDetails ?. userRole === USER_ROLE . ENFORCEMENT_OFFICER ;
22
20
23
21
const shouldShowSideBar =
24
- isAuthenticated && isIdir && idirUserDetails ?. userName && ! isEofficer ;
22
+ isAuthenticated && isIdir && idirUserDetails ?. userName ;
25
23
26
24
// Determine when to hide the BridgeFormulaCalculationTool button based on its corresponding feature flag
27
25
const { data : featureFlags } = useFeatureFlagsQuery ( ) ;
28
- const enableBFCT =
26
+
27
+ const BFCTFeatureFlagEnabled =
29
28
featureFlags ?. [ "BRIDGE-FORMULA-CALCULATION-TOOL" ] === "ENABLED" ;
30
29
30
+ const shouldShowBFCTButton = usePermissionMatrix ( {
31
+ permissionMatrixKeys : {
32
+ permissionMatrixFeatureKey : "STICKY_SIDE_BAR" ,
33
+ permissionMatrixFunctionKey : "BRIDGE_FORMULA_CALCULATION_TOOL_BUTTON" ,
34
+ } ,
35
+ } ) ;
36
+
37
+ const shouldShowReportsButton = usePermissionMatrix ( {
38
+ permissionMatrixKeys : {
39
+ permissionMatrixFeatureKey : "STICKY_SIDE_BAR" ,
40
+ permissionMatrixFunctionKey : "REPORTS_BUTTON" ,
41
+ } ,
42
+ } ) ;
43
+
31
44
return shouldShowSideBar ? (
32
45
< div className = "nav-icon-side-bar" >
33
46
< NavIconHomeButton />
34
- < NavIconReportButton />
35
- { enableBFCT && < NavIconBFCTButton /> }
47
+ { shouldShowReportsButton && < NavIconReportButton /> }
48
+ { BFCTFeatureFlagEnabled && shouldShowBFCTButton && < NavIconBFCTButton /> }
36
49
</ div >
37
50
) : null ;
38
51
} ;
0 commit comments