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

chore: User Management File Changes #76

Merged
merged 2 commits into from
Dec 7, 2023
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
6 changes: 3 additions & 3 deletions src/entryPoints/hyperswitch/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,14 @@ let make = () => {
renderList={() => <RoutingStack remainingPath />}
renderShow={routingType => <RoutingConfigure routingType />}
/>
| list{"users", "invite-users"} => <HSwitchInviteUsers />
| list{"users", "invite-users"} => <InviteUsers />
| list{"users", ...remainingPath} =>
<EntityScaffold
entityName="UserManagement"
remainingPath
access=ReadWrite
renderList={() => <HSwitchUserRoleEntry />}
renderShow={id => <HSwitchUserRoleShowData id />}
renderList={() => <UserRoleEntry />}
renderShow={_ => <UserRoleShowData />}
/>
| list{"analytics-payments"} =>
<AnalyticsUrlUpdaterContext key="PaymentsAnalytics">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module InviteEmailForm = {
open HSwitchUserManagementUtils
open UserManagementUtils
@react.component
let make = (~setRoleTypeValue) => {
open LogicUtils
Expand All @@ -24,7 +24,7 @@ module InviteEmailForm = {
(),
)
let response = await fetchDetails(roleListUrl)
let typedResponse: array<HSwitchUserRoleEntity.roleListResponse> =
let typedResponse: array<UserRoleEntity.roleListResponse> =
response->LogicUtils.getArrayDataFromJson(roleListResponseMapper)
setRoleListData(_ => typedResponse)
} catch {
Expand Down Expand Up @@ -68,7 +68,7 @@ module InviteEmailForm = {

@react.component
let make = () => {
open HSwitchUserManagementUtils
open UserManagementUtils
open APIUtils
open LogicUtils
let fetchDetails = useGetMethod()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
open HSwitchUserManagementUtils
open UserManagementUtils

external typeConversion: array<Js.Nullable.t<HSwitchUserRoleEntity.userTableTypes>> => array<
HSwitchUserRoleEntity.userTableTypes,
external typeConversion: array<Js.Nullable.t<UserRoleEntity.userTableTypes>> => array<
UserRoleEntity.userTableTypes,
> = "%identity"

module UserHeading = {
@react.component
let make = (~infoValue: HSwitchUserRoleEntity.userTableTypes, ~userId) => {
let make = (~infoValue: UserRoleEntity.userTableTypes, ~userId) => {
open APIUtils
let showToast = ToastState.useShowToast()
let updateDetails = useUpdateMethod()
let status = infoValue.status->HSwitchUserRoleEntity.statusToVariantMapper
let status = infoValue.status->UserRoleEntity.statusToVariantMapper

let resendInvite = async () => {
try {
Expand Down Expand Up @@ -64,7 +64,7 @@ let make = () => {
let currentSelectedUser = React.useMemo1(() => {
usersList
->typeConversion
->Array.reduce(Js.Dict.empty()->HSwitchUserRoleEntity.itemToObjMapperForUser, (acc, ele) => {
->Array.reduce(Js.Dict.empty()->UserRoleEntity.itemToObjMapperForUser, (acc, ele) => {
url.path->Belt.List.toArray->Js.Array2.joinWith("/")->Js.String2.includes(ele.user_id)
? ele
: acc
Expand Down Expand Up @@ -122,8 +122,7 @@ let make = () => {
(),
)
let res = await fetchDetails(userDataURL)
let userData =
res->LogicUtils.getArrayDataFromJson(HSwitchUserRoleEntity.itemToObjMapperForUser)
let userData = res->LogicUtils.getArrayDataFromJson(UserRoleEntity.itemToObjMapperForUser)
setUsersList(_ => userData->Js.Array2.map(Js.Nullable.return))
} catch {
| _ => ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ let validateForm = (values, ~fieldsToValidate: array<string>) => {
errors->Js.Json.object_
}

let roleListDataMapper: HSwitchUserRoleEntity.roleListResponse => SelectBox.dropdownOption = ele => {
let roleListDataMapper: UserRoleEntity.roleListResponse => SelectBox.dropdownOption = ele => {
{
label: ele.role_name,
value: ele.role_id,
}
}

let roleOptions: array<HSwitchUserRoleEntity.roleListResponse> => array<
let roleOptions: array<UserRoleEntity.roleListResponse> => array<
SelectBox.dropdownOption,
> = roleListData => roleListData->Js.Array2.map(roleListDataMapper)

Expand Down Expand Up @@ -151,9 +151,7 @@ module RolePermissionValueRenderer = {
}
}

let roleListResponseMapper: Js.Dict.t<
Js.Json.t,
> => HSwitchUserRoleEntity.roleListResponse = dict => {
let roleListResponseMapper: Js.Dict.t<Js.Json.t> => UserRoleEntity.roleListResponse = dict => {
open LogicUtils
{
role_id: dict->getString("role_id", ""),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type roles = Users | Roles
open HSwitchUserRoleEntity
open UserRoleEntity

@react.component
let make = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@react.component
let make = (~id as _) => {
let make = () => {
let url = RescriptReactRouter.useUrl()
let stateName = url.search->Js.String2.split("=")->LogicUtils.getValueFromArray(1, "")

<div className="flex flex-col overflow-scroll">
{switch stateName->Js.String2.toLowerCase {
| "user" => <HSwitchShowUserData />
| "user" => <ShowUserData />
| _ => {
RescriptReactRouter.replace("?state=user")
<HSwitchShowUserData />
<ShowUserData />
}
}}
</div>
Expand Down
Loading