Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Org changes for invite #1543

Merged
merged 7 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "")
JeevaRamu0104 marked this conversation as resolved.
Show resolved Hide resolved
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"
JeevaRamu0104 marked this conversation as resolved.
Show resolved Hide resolved
| (Some(_orgId), Some(_merchnatId), Some("all_profiles")) => "merchant"
| (Some(_orgId), Some(_merchnatId), Some(_profileId)) => "profile"
| _ => ""
Expand Down
Loading