Skip to content

Commit

Permalink
chore: disable customers for profile level users (#1304)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 authored Sep 5, 2024
1 parent a1553e8 commit d5c72ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
8 changes: 6 additions & 2 deletions src/entryPoints/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -213,7 +215,9 @@ let make = () => {
| list{"payouts", ..._} =>
<TransactionContainer />
| list{"customers", ...remainingPath} =>
<AccessControl permission=userPermissionJson.operationsView>
<AccessControl
permission={userPermissionJson.operationsView}
isEnabled={userEntity !== #Profile}>
<EntityScaffold
entityName="Customers"
remainingPath
Expand Down
12 changes: 8 additions & 4 deletions src/entryPoints/SidebarValues.res
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,22 @@ let payouts = permissionJson => {
})
}

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({
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
20 changes: 13 additions & 7 deletions src/screens/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ 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 {
| Some(_con) => `account/connectors/verify`
| None =>
switch id {
| Some(connectorID) => `${connectorBaseURL}/${connectorID}`
| None =>
switch (userEntity, userManagementRevamp) {
| (#Merchant, true) | (#Profile, true) => `account/${merchantId}/profile/connectors`
| _ => connectorBaseURL
}
| None => connectorBaseURL
}
}
| _ => ""
Expand Down Expand Up @@ -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}`
| _ =>
Expand All @@ -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`
Expand Down

0 comments on commit d5c72ef

Please sign in to comment.