Skip to content

Commit

Permalink
feat: Org changes for invite (#1543)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitanjli525 authored Oct 10, 2024
1 parent 4c720da commit c70d32c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/screens/UserManagement/UserRevamp/UserInfo.res
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ module UserAction = {
)

let decideWhatToShow = {
if value.entityType->UserInfoUtils.entityMapper === #Organization {
// User is at org level
NoActionAccess
} else if userEmail === email {
if userEmail === email {
// User cannot update its own role
NoActionAccess
} else if userHasAccess(~groupAccess=UsersManage) === NoAccess {
Expand All @@ -40,6 +37,13 @@ module UserAction = {
value.profile.id->Option.isNone
) {
ManageUser
} else if (
// Org level user
value.org.id->Option.getOr("") === orgId &&
value.merchant.id->Option.isNone &&
value.profile.id->Option.isNone
) {
ManageUser
} else {
SwitchUser
}
Expand Down
24 changes: 23 additions & 1 deletion src/screens/UserManagement/UserRevamp/UserManagementHelper.res
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module MerchantSelection = {
~label="All merchants",
~value="all_merchants",
~dropdownList=merchList,
~showAllSelection=true,
),
~deselectDisable=true,
~buttonText="Select a Merchant",
Expand Down Expand Up @@ -112,10 +113,31 @@ module ProfileSelection = {
let internalSwitch = OMPSwitchHooks.useInternalSwitch()
let profileList = Recoil.useRecoilValueFromAtom(HyperswitchAtom.profileListAtom)
let {userInfo: {userEntity}} = React.useContext(UserInfoProvider.defaultContext)
let form = ReactFinalForm.useForm()
let formState: ReactFinalForm.formState = ReactFinalForm.useFormState(
ReactFinalForm.useFormSubscription(["values"])->Nullable.make,
)

let disableSelect = switch userEntity {
| #Profile => true
| #Organization
| #Organization => {
let selected_merchant =
formState.values
->LogicUtils.getDictFromJsonObject
->LogicUtils.getString("merchant_value", "")
switch selected_merchant->stringToVariantForAllSelection {
| Some(#All_Merchants) => {
form.change(
"profile_value",
(#All_Profiles: UserManagementTypes.allSelectionType :> string)
->String.toLowerCase
->JSON.Encode.string,
)
true
}
| _ => false
}
}
| #Merchant => false
}

Expand Down
2 changes: 1 addition & 1 deletion src/screens/UserManagement/UserRevamp/UserUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ let getEntityType = valueDict => {
let profileValue = valueDict->getOptionString("profile_value")

switch (orgValue, merchantValue, profileValue) {
| (Some(_orgId), Some("all_merchants"), Some("all_profiles")) => "organisation"
| (Some(_orgId), Some("all_merchants"), Some("all_profiles")) => "organization"
| (Some(_orgId), Some(_merchnatId), Some("all_profiles")) => "merchant"
| (Some(_orgId), Some(_merchnatId), Some(_profileId)) => "profile"
| _ => ""
Expand Down

0 comments on commit c70d32c

Please sign in to comment.