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: Update Role & Delete user added #403

Merged
merged 24 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
940f69d
feat: Delete user added
Feb 14, 2024
1e681eb
fix: update role added
Feb 15, 2024
0e4b85f
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Feb 15, 2024
498eaa5
fix: return back to Users page
Feb 15, 2024
0a02f13
fix: merchantEmail check added
Feb 15, 2024
2753858
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Feb 17, 2024
dd02343
feat: Update role back functionality
Feb 17, 2024
1214e08
fix: height issue
Feb 19, 2024
7272e9e
fix: style fix
Feb 19, 2024
3516972
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Feb 20, 2024
c8c084a
feat: delete warning modal added
Feb 20, 2024
9808d8b
feat: Back button added
Feb 20, 2024
84ab938
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Feb 20, 2024
0b33e5f
fix: text changes
Feb 20, 2024
bbea84a
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Feb 21, 2024
a5ec305
Merge branch 'main' into update-delete-user
Feb 21, 2024
8f9c98d
Merge branch 'main' into update-delete-user
Feb 22, 2024
096bb60
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Feb 23, 2024
70e3811
fix: comment addressed
Feb 23, 2024
3b4344b
fix: comments addressed
Feb 26, 2024
70867e4
Merge branch 'main' into update-delete-user
Feb 26, 2024
9cc3286
Merge branch 'main' into update-delete-user
Feb 26, 2024
6f53794
Merge branch 'main' into update-delete-user
Riddhiagrawal001 Feb 26, 2024
5acfe8a
Merge branch 'main' into update-delete-user
JeevaRamu0104 Feb 26, 2024
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
3 changes: 1 addition & 2 deletions src/components/DynamicSingleStat.res
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ let make = (
let (key, value) = entries
filterKeys->Array.includes(key) ? Some((key, value)) : None
})
->Dict.fromArray
->JSON.Encode.object
->getJsonFromArrayOfJson
->Some
}, [topFiltersToSearchParam])

Expand Down
3 changes: 1 addition & 2 deletions src/context/SingleStatContext.res
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ let make = (
let (key, value) = entries
filterKeys->Array.includes(key) ? Some((key, value)) : None
})
->Dict.fromArray
->JSON.Encode.object
->getJsonFromArrayOfJson
->Some
}, [topFiltersToSearchParam])

Expand Down
3 changes: 1 addition & 2 deletions src/context/UserPrefContext.res
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ let make = (~children) => {
let (key, value) = item
(key, value->userPrefToJson)
})
->Dict.fromArray
->JSON.Encode.object
->LogicUtils.getJsonFromArrayOfJson
->JSON.stringify

let value = React.useMemo4(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/screens/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ let getURL = (
| #SIGNINV2 => `${userUrl}/v2/signin`
| #VERIFY_EMAILV2 => `${userUrl}/v2/verify_email`
| #ACCEPT_INVITE => `${userUrl}/user/invite/accept`
| #USER_DELETE => `${userUrl}/user/delete`
| #UPDATE_ROLE => `${userUrl}/user/${(userType :> string)->String.toLowerCase}`
| #SIGNIN
| #SIGNUP
| #VERIFY_EMAIL
Expand Down
2 changes: 2 additions & 0 deletions src/screens/APIUtils/APIUtilsTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type userType = [
| #MERCHANT_DATA
| #USER_DATA
| #INVITE
| #USER_DELETE
| #UPDATE_ROLE
| #INVITE_MULTIPLE
| #RESEND_INVITE
| #CREATE_MERCHANT
Expand Down
4 changes: 1 addition & 3 deletions src/screens/Analytics/Logs/PaymentLogs/PaymentLogs.res
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ let make = (~paymentId, ~createdAt) => {
->Dict.fromArray
->JSON.Encode.object,
),
]
->Dict.fromArray
->JSON.Encode.object
]->getJsonFromArrayOfJson
let webhookLogsUrl = getURL(
~entityName=WEBHOOKS_EVENT_LOGS,
~methodType=Get,
Expand Down
3 changes: 1 addition & 2 deletions src/screens/Connectors/ConnectorUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,7 @@ let ignoreFields = (json, id, fields) => {
let (key, _val) = entry
!(fields->Array.includes(key))
})
->Dict.fromArray
->JSON.Encode.object
->LogicUtils.getJsonFromArrayOfJson
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/screens/FraudAndRisk/FRMUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ let size = "w-14 h-14 rounded-full"

let generateInitialValuesDict = (~selectedFRMInfo, ~isLiveMode, ()) => {
let frmAccountDetailsDict =
[("auth_type", selectedFRMInfo.name->getFRMAuthType->JSON.Encode.string)]
->Dict.fromArray
->JSON.Encode.object
[
("auth_type", selectedFRMInfo.name->getFRMAuthType->JSON.Encode.string),
]->LogicUtils.getJsonFromArrayOfJson

[
("connector_name", selectedFRMInfo.name->getFRMNameString->JSON.Encode.string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ let getProdApiBody = (
(parentVariant :> string),
[("connector_id", connectorId->JSON.Encode.string)]->Dict.fromArray->JSON.Encode.object,
),
]
->Dict.fromArray
->JSON.Encode.object
]->LogicUtils.getJsonFromArrayOfJson

| #ProductionAgreement =>
[
Expand All @@ -160,9 +158,7 @@ let getProdApiBody = (
("version", HSwitchGlobalVars.agreementVersion->JSON.Encode.string),
]->LogicUtils.getJsonFromArrayOfJson,
),
]
->Dict.fromArray
->JSON.Encode.object
]->LogicUtils.getJsonFromArrayOfJson
| _ => (parentVariant :> string)->JSON.Encode.string
}
}
Expand Down
15 changes: 6 additions & 9 deletions src/screens/SetupAccount/HSwitchSetupAccountUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ let constructBody = (~connectorName, ~json, ~profileId) => {
let bodyType = connectorAccountDict->Dict.keysToArray->Array.get(0)->Option.getOr("")

let connectorAccountDetails =
[("auth_type", bodyType->JSON.Encode.string), ("api_key", "test"->JSON.Encode.string)]
->Dict.fromArray
->JSON.Encode.object
[
("auth_type", bodyType->JSON.Encode.string),
("api_key", "test"->JSON.Encode.string),
]->getJsonFromArrayOfJson

let initialValueForPayload = generateInitialValuesDict(
~values=[
("profile_id", profileId->JSON.Encode.string),
("connector_account_details", connectorAccountDetails),
("connector_label", `${connectorName}_default`->JSON.Encode.string),
]
->Dict.fromArray
->JSON.Encode.object,
]->getJsonFromArrayOfJson,
~connector=connectorName,
~bodyType,
(),
Expand Down Expand Up @@ -113,9 +112,7 @@ let constructRoutingPayload = (routingData: routingData) => {
[
("connector", routingData.connector_name->JSON.Encode.string),
("merchant_connector_id", routingData.merchant_connector_id->JSON.Encode.string),
]
->Dict.fromArray
->JSON.Encode.object
]->LogicUtils.getJsonFromArrayOfJson
[("split", 50.0->JSON.Encode.float), ("connector", innerRoutingDict)]
->Dict.fromArray
->JSON.Encode.object
Expand Down
82 changes: 51 additions & 31 deletions src/screens/UserManagement/InviteUsers.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module InviteEmailForm = {
open UserManagementUtils
@react.component
let make = (~setRoleTypeValue) => {
let make = (~setRoleTypeValue, ~isEmailTextInputVisible, ~setNewRoleSelected) => {
open LogicUtils
open APIUtils
open UIUtils
let fetchDetails = useGetMethod()
let {magicLink} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let (roleListData, setRoleListData) = React.useState(_ => [])
Expand All @@ -14,6 +15,11 @@ module InviteEmailForm = {
->getValueFromArray(0, ""->JSON.Encode.string)
->getStringFromJson("")

React.useEffect1(() => {
setNewRoleSelected(_ => role)
None
}, [role])

let getRolesList = async () => {
try {
let roleListUrl = getURL(
Expand Down Expand Up @@ -42,22 +48,24 @@ module InviteEmailForm = {
}, [role])

<>
<div className="flex justify-between">
<div className="flex flex-col w-full">
<FormRenderer.FieldRenderer
field=inviteEmail
fieldWrapperClass="w-4/5"
labelClass="!text-black !text-base !-ml-[0.5px]"
/>
</div>
<div className="absolute top-10 right-5">
<FormRenderer.SubmitButton
text={magicLink ? "Send Invite" : "Add User"} loadingText="Loading..."
/>
<RenderIf condition={isEmailTextInputVisible}>
<div className="flex justify-between">
<div className="flex flex-col w-full">
<FormRenderer.FieldRenderer
field=inviteEmail
fieldWrapperClass="w-4/5"
labelClass="!text-black !text-base !-ml-[0.5px]"
/>
</div>
<div className="absolute top-10 right-5">
<FormRenderer.SubmitButton
text={magicLink ? "Send Invite" : "Add User"} loadingText="Loading..."
/>
</div>
</div>
</div>
</RenderIf>
<FormRenderer.FieldRenderer
fieldWrapperClass="w-full mt-5"
fieldWrapperClass={`w-full ${isEmailTextInputVisible ? "mt-5" : ""}`}
field={roleType(roleListData)}
errorClass
labelClass="!text-black !font-semibold"
Expand All @@ -67,24 +75,31 @@ module InviteEmailForm = {
}

@react.component
let make = () => {
let make = (~isInviteUserFlow=true, ~setNewRoleSelected=_ => (), ~currentRole=?) => {
open UserManagementUtils
open APIUtils
open LogicUtils
open UIUtils
let fetchDetails = useGetMethod()
let updateDetails = useUpdateMethod()
let showToast = ToastState.useShowToast()

let defaultRole = switch currentRole {
| Some(val) => val
| None => "merchant_view_only"
}

let {magicLink, inviteMultiple} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let {permissionInfo, setPermissionInfo} = React.useContext(GlobalProvider.defaultContext)
let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading)
let (roleTypeValue, setRoleTypeValue) = React.useState(_ => "merchant_view_only")
let (roleTypeValue, setRoleTypeValue) = React.useState(_ => defaultRole)
let (roleDict, setRoleDict) = React.useState(_ => Dict.make())
let (loaderForInviteUsers, setLoaderForInviteUsers) = React.useState(_ => false)
let paddingClass = isInviteUserFlow ? "p-10" : ""
let marginClass = isInviteUserFlow ? "mt-5" : ""

let initialValues = React.useMemo0(() => {
[("roleType", ["merchant_view_only"->JSON.Encode.string]->JSON.Encode.array)]
->Dict.fromArray
->JSON.Encode.object
[("roleType", [defaultRole->JSON.Encode.string]->JSON.Encode.array)]->getJsonFromArrayOfJson
})

let inviteListOfUsersWithInviteMultiple = async values => {
Expand Down Expand Up @@ -312,20 +327,25 @@ let make = () => {
}, [roleTypeValue])

<div className="flex flex-col overflow-y-scroll h-full">
<BreadCrumbNavigation
path=[{title: "Users", link: "/users"}] currentPageTitle="Invite new users"
/>
<PageUtils.PageHeading
title="Invite New Users"
subTitle="An invite will be sent to the email addresses to set up a new account"
/>
<div className="h-4/5 bg-white mt-5 p-10 relative overflow-y-scroll flex flex-col gap-10">
<RenderIf condition={isInviteUserFlow}>
<BreadCrumbNavigation
path=[{title: "Users", link: "/users"}] currentPageTitle="Invite new users"
/>
<PageUtils.PageHeading
title="Invite New Users"
subTitle="An invite will be sent to the email addresses to set up a new account"
/>
</RenderIf>
<div
className={`h-4/5 bg-white relative overflow-y-scroll flex flex-col gap-10 ${paddingClass} ${marginClass}`}>
<Form
key="invite-user-management"
initialValues={initialValues}
validate={values => values->validateForm(~fieldsToValidate=["emailList"])}
onSubmit>
<InviteEmailForm setRoleTypeValue />
<InviteEmailForm
setRoleTypeValue isEmailTextInputVisible=isInviteUserFlow setNewRoleSelected
/>
</Form>
<PageLoaderWrapper screenState={screenState}>
<div className="flex flex-col justify-between gap-12 show-scrollbar overflow-scroll">
Expand All @@ -342,12 +362,12 @@ let make = () => {
</div>
</PageLoaderWrapper>
</div>
<UIUtils.RenderIf condition={!magicLink}>
<RenderIf condition={!magicLink}>
<LoaderModal
showModal={loaderForInviteUsers}
setShowModal={setLoaderForInviteUsers}
text="Inviting Users"
/>
</UIUtils.RenderIf>
</RenderIf>
</div>
}
Loading
Loading