From 59d0b5387476536ed3a7f6a9f3468a3bd115232f Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Wed, 17 Jan 2024 18:49:23 +0530 Subject: [PATCH] chore: Access Control Module added (#266) --- .../hyperswitch/HyperSwitchApp.res | 54 +++++++------------ src/utils/AccessControl.res | 11 ++++ 2 files changed, 31 insertions(+), 34 deletions(-) create mode 100644 src/utils/AccessControl.res diff --git a/src/entryPoints/hyperswitch/HyperSwitchApp.res b/src/entryPoints/hyperswitch/HyperSwitchApp.res index c692c94d8..210af2a7c 100644 --- a/src/entryPoints/hyperswitch/HyperSwitchApp.res +++ b/src/entryPoints/hyperswitch/HyperSwitchApp.res @@ -4,19 +4,6 @@ open HSLocalStorage open HSwitchGlobalVars open APIUtils -module FeatureFlagEnabledComponent = { - @react.component - let make = (~isEnabled, ~children) => { - let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext) - let updateRoute = () => { - setDashboardPageState(_ => #HOME) - RescriptReactRouter.replace("/home") - React.null - } - <> {isEnabled ? children : updateRoute()} - } -} - @react.component let make = () => { let url = RescriptReactRouter.useUrl() @@ -219,11 +206,11 @@ let make = () => { {switch url.path { | list{"home"} => - + {featureFlagDetails.quickStart ? : } - + | list{"fraud-risk-management", ...remainingPath} => - + { renderNewForm={() => } renderShow={_ => } /> - + | list{"connectors", ...remainingPath} => { renderShow={id => } /> | list{"customers", ...remainingPath} => - + { renderList={() => } renderShow={id => } /> - + | list{"routing", ...remainingPath} => { | list{"analytics-user-journey"} => - + - + | list{"monitoring"} => comingSoonPage | list{"developer-api-keys"} => | list{"developer-system-metrics"} => @@ -336,31 +322,31 @@ let make = () => { } /> | list{"recon"} => - + - + | list{"sdk"} => - + - + | list{"3ds"} => | list{"surcharge"} => - + - + | list{"account-settings"} => - + - + | list{"account-settings", "profile"} => | list{"business-details"} => - + - + | list{"business-profiles"} => - + - + | list{"quick-start"} => determineQuickStartPageState() | list{"woocommerce"} => determineWooCommerce() | list{"stripe-plus-paypal"} => determineStripePlusPayPal() diff --git a/src/utils/AccessControl.res b/src/utils/AccessControl.res new file mode 100644 index 000000000..93d9c0951 --- /dev/null +++ b/src/utils/AccessControl.res @@ -0,0 +1,11 @@ +@react.component +let make = (~isEnabled, ~children) => { + let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext) + + let updateRoute = () => { + setDashboardPageState(_ => #HOME) + RescriptReactRouter.replace("/home") + React.null + } + isEnabled ? children : updateRoute() +}