Skip to content

Commit

Permalink
fix: update list on accept invite (#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevaRamu0104 authored Dec 6, 2024
1 parent 58e3731 commit 945ce14
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/container/MerchantAccountContainer.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Modules that depend on Merchant data are located within this container.
*/
@react.component
let make = () => {
let make = (~setAppScreenState) => {
open HSwitchUtils
open HyperswitchAtom
let url = RescriptReactRouter.useUrl()
Expand Down Expand Up @@ -45,7 +45,7 @@ let make = () => {
<div>
<PageLoaderWrapper screenState={screenState} sectionHeight="!h-screen" showLogoutButton=true>
{switch url.path->urlPath {
| list{"home"} => <Home />
| list{"home"} => <Home setAppScreenState />

| list{"recon"} =>
<AccessControl
Expand Down
5 changes: 2 additions & 3 deletions src/entryPoints/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ let make = () => {
</RenderIf>
<ProfileSwitch />
</div>

<>
<div>
{switch dashboardPageState {
Expand Down Expand Up @@ -158,7 +157,7 @@ let make = () => {
| list{"config-settings"}
| list{"file-processor"}
| list{"sdk"} =>
<MerchantAccountContainer />
<MerchantAccountContainer setAppScreenState=setScreenState />
| list{"connectors", ..._}
| list{"payoutconnectors", ..._}
| list{"3ds-authenticators", ..._}
Expand Down Expand Up @@ -303,7 +302,7 @@ let make = () => {
| list{"unauthorized"} => <UnauthorizedPage />
| _ =>
RescriptReactRouter.replace(appendDashboardPath(~url="/home"))
<MerchantAccountContainer />
<MerchantAccountContainer setAppScreenState=setScreenState />
}}
</ErrorBoundary>
</div>
Expand Down
26 changes: 20 additions & 6 deletions src/entryPoints/PendingInvitationsHome.res
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ module InviteForMultipleInvitation = {
<div className="flex items-center gap-3">
<Icon size=40 name="group-users-without-circle" />
<div>
{`You've been invited to the Hyperswitch dashboard by `->React.string}
<span className="font-bold"> {ele.entityId->React.string} </span>
{`You've been invited to `->React.string}
<span className="font-bold">
{(
ele.entityName->isNonEmptyString ? ele.entityName : ele.entityId
)->React.string}
</span>
{` as `->React.string}
<span className="font-bold"> {ele.roleId->snakeToTitle->React.string} </span>
</div>
</div>
{switch checkIfInvitationAccepted(ele.entityId, ele.entityType) {
Expand Down Expand Up @@ -107,10 +113,16 @@ module InviteForSingleInvitation = {
<div className="flex items-center gap-3">
<Icon size=40 name="group-users-without-circle" />
<div>
{`You've been invited to the Hyperswitch dashboard by `->React.string}
<span className="font-bold"> {inviteValue.entityId->React.string} </span>
{`You've been invited to `->React.string}
<span className="font-bold">
{(
inviteValue.entityName->isNonEmptyString
? inviteValue.entityName
: inviteValue.entityId
)->React.string}
</span>
{` as `->React.string}
<span className="font-bold"> {inviteValue.roleId->React.string} </span>
<span className="font-bold"> {inviteValue.roleId->snakeToTitle->React.string} </span>
</div>
</div>
<Button
Expand All @@ -123,7 +135,7 @@ module InviteForSingleInvitation = {
}
}
@react.component
let make = () => {
let make = (~setAppScreenState) => {
open APIUtils
open LogicUtils
let getURL = useGetURL()
Expand All @@ -147,6 +159,7 @@ let make = () => {

let acceptInvite = async acceptedInvitesArray => {
try {
setAppScreenState(_ => PageLoaderWrapper.Loading)
let url = getURL(~entityName=USERS, ~userType=#ACCEPT_INVITATION_HOME, ~methodType=Post)

let body =
Expand All @@ -164,6 +177,7 @@ let make = () => {
let _ = await updateDetails(url, body, Post)
setShowModal(_ => false)
getListOfMerchantIds()->ignore
setAppScreenState(_ => Success)
} catch {
| _ => showToast(~message="Failed to accept invitations!", ~toastType=ToastError)
}
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Home/Home.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@react.component
let make = () => {
let make = (~setAppScreenState) => {
open HomeUtils
open PageUtils
let greeting = getGreeting()
Expand All @@ -11,7 +11,7 @@ let make = () => {
<RenderIf condition={recoveryCodesLeft->Option.isSome && recoveryCode < 3}>
<HomeUtils.LowRecoveryCodeBanner recoveryCode />
</RenderIf>
<PendingInvitationsHome />
<PendingInvitationsHome setAppScreenState />
</div>
<PageHeading
title={`${greeting}, it's great to see you!`}
Expand Down

0 comments on commit 945ce14

Please sign in to comment.