From d5c72ef3ab0fcc9c933dbc940e911cd2a0cbbfa3 Mon Sep 17 00:00:00 2001
From: Riddhiagrawal001 <50551695+Riddhiagrawal001@users.noreply.github.com>
Date: Thu, 5 Sep 2024 11:58:59 +0530
Subject: [PATCH] chore: disable customers for profile level users (#1304)
---
src/entryPoints/HyperSwitchApp.res | 8 ++++++--
src/entryPoints/SidebarValues.res | 12 ++++++++----
src/screens/APIUtils/APIUtils.res | 20 +++++++++++++-------
3 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/src/entryPoints/HyperSwitchApp.res b/src/entryPoints/HyperSwitchApp.res
index 2607c04cc..9fe08100e 100644
--- a/src/entryPoints/HyperSwitchApp.res
+++ b/src/entryPoints/HyperSwitchApp.res
@@ -26,7 +26,9 @@ let make = () => {
let featureFlagDetails = featureFlagAtom->Recoil.useRecoilValueFromAtom
let (userPermissionJson, setuserPermissionJson) = Recoil.useRecoilState(userPermissionAtom)
let getEnumDetails = EnumVariantHook.useFetchEnumDetails()
- let {userInfo: {orgId, merchantId, profileId}} = React.useContext(UserInfoProvider.defaultContext)
+ let {userInfo: {orgId, merchantId, profileId, userEntity}} = React.useContext(
+ UserInfoProvider.defaultContext,
+ )
let {userRole} = useCommonAuthInfo()->Option.getOr(defaultAuthInfo)
let modeText = featureFlagDetails.isLiveMode ? "Live Mode" : "Test Mode"
let modeStyles = featureFlagDetails.isLiveMode
@@ -213,7 +215,9 @@ let make = () => {
| list{"payouts", ..._} =>
| list{"customers", ...remainingPath} =>
-
+
{
})
}
-let operations = (isOperationsEnabled, ~permissionJson, ~isPayoutsEnabled) => {
+let operations = (isOperationsEnabled, ~permissionJson, ~isPayoutsEnabled, ~userEntity) => {
let payments = payments(permissionJson)
let refunds = refunds(permissionJson)
let disputes = disputes(permissionJson)
let customers = customers(permissionJson)
let payouts = payouts(permissionJson)
- let links = [payments, refunds, disputes, customers]
+ let links = [payments, refunds, disputes]
+ let isCustomersEnabled = userEntity !== #Profile
if isPayoutsEnabled {
links->Array.push(payouts)->ignore
}
+ if isCustomersEnabled {
+ links->Array.push(customers)->ignore
+ }
isOperationsEnabled
? Section({
@@ -594,7 +598,7 @@ let useGetSidebarValues = (~isReconEnabled: bool) => {
CommonAuthHooks.useCommonAuthInfo()->Option.getOr(CommonAuthHooks.defaultAuthInfo)
let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let permissionJson = Recoil.useRecoilValueFromAtom(HyperswitchAtom.userPermissionAtom)
-
+ let {userInfo: {userEntity}} = React.useContext(UserInfoProvider.defaultContext)
let {
frm,
payOut,
@@ -618,7 +622,7 @@ let useGetSidebarValues = (~isReconEnabled: bool) => {
let sidebar = [
productionAccessComponent(quickStart),
default->home,
- default->operations(~permissionJson, ~isPayoutsEnabled=payOut),
+ default->operations(~permissionJson, ~isPayoutsEnabled=payOut, ~userEntity),
default->connectors(
~isLiveMode,
~isFrmEnabled=frm,
diff --git a/src/screens/APIUtils/APIUtils.res b/src/screens/APIUtils/APIUtils.res
index 5873ce0d2..05373e7ca 100644
--- a/src/screens/APIUtils/APIUtils.res
+++ b/src/screens/APIUtils/APIUtils.res
@@ -52,7 +52,11 @@ let useGetURL = () => {
| Get =>
switch id {
| Some(connectorID) => `${connectorBaseURL}/${connectorID}`
- | None => connectorBaseURL
+ | None =>
+ switch (userEntity, userManagementRevamp) {
+ | (#Merchant, true) | (#Profile, true) => `account/${merchantId}/profile/connectors`
+ | _ => connectorBaseURL
+ }
}
| Post | Delete =>
switch connector {
@@ -60,11 +64,7 @@ let useGetURL = () => {
| None =>
switch id {
| Some(connectorID) => `${connectorBaseURL}/${connectorID}`
- | None =>
- switch (userEntity, userManagementRevamp) {
- | (#Merchant, true) | (#Profile, true) => `account/${merchantId}/profile/connectors`
- | _ => connectorBaseURL
- }
+ | None => connectorBaseURL
}
}
| _ => ""
@@ -280,7 +280,7 @@ let useGetURL = () => {
| PAYOUT_DEFAULT_FALLBACK => `routing/payouts/default`
| PAYOUT_ROUTING =>
switch methodType {
- | Get | Put =>
+ | Get =>
switch id {
| Some(routingId) => `routing/${routingId}`
| _ =>
@@ -289,6 +289,12 @@ let useGetURL = () => {
| _ => `routing/payouts`
}
}
+
+ | Put =>
+ switch id {
+ | Some(routingId) => `routing/${routingId}`
+ | _ => `routing/payouts`
+ }
| Post =>
switch id {
| Some(routing_id) => `routing/payouts/${routing_id}/activate`