diff --git a/src/container/MerchantAccountContainer.res b/src/container/MerchantAccountContainer.res index 32e28090d..aae27b26f 100644 --- a/src/container/MerchantAccountContainer.res +++ b/src/container/MerchantAccountContainer.res @@ -83,12 +83,14 @@ let make = (~setAppScreenState) => { authorization={userHasResourceAccess(~resourceAccess=ReconConfig)}> urlPath} /> - | list{"file-processor"} => - - urlPath} /> - + + // Commented as not needed now + // | list{"file-processor"} => + // + // urlPath} /> + // | list{"sdk"} => { | list{"recon-analytics"} | list{"reports"} | list{"config-settings"} - | list{"file-processor"} | list{"sdk"} => + // Commented as not needed now + // list{"file-processor"} + | list{"connectors", ..._} | list{"payoutconnectors", ..._} | list{"3ds-authenticators", ..._} diff --git a/src/entryPoints/SidebarValues.res b/src/entryPoints/SidebarValues.res index 714b7557b..4db4ed63d 100644 --- a/src/entryPoints/SidebarValues.res +++ b/src/entryPoints/SidebarValues.res @@ -600,14 +600,15 @@ let reconConfigurator = { searchOptions: [("Recon configurator", "")], }) } -let reconFileProcessor = { - SubLevelLink({ - name: "File Processor", - link: `/file-processor`, - access: Access, - searchOptions: [("Recon file processor", "")], - }) -} +// Commented as not needed now +// let reconFileProcessor = { +// SubLevelLink({ +// name: "File Processor", +// link: `/file-processor`, +// access: Access, +// searchOptions: [("Recon file processor", "")], +// }) +// } let reconAndSettlement = (recon, isReconEnabled, checkUserEntity, userHasResourceAccess) => { switch (recon, isReconEnabled, checkUserEntity([#Merchant, #Organization])) { @@ -630,9 +631,10 @@ let reconAndSettlement = (recon, isReconEnabled, checkUserEntity, userHasResourc if userHasResourceAccess(~resourceAccess=ReconConfig) == CommonAuthTypes.Access { links->Array.push(reconConfigurator) } - if userHasResourceAccess(~resourceAccess=ReconFiles) == CommonAuthTypes.Access { - links->Array.push(reconFileProcessor) - } + // Commented as not needed now + // if userHasResourceAccess(~resourceAccess=ReconFiles) == CommonAuthTypes.Access { + // links->Array.push(reconFileProcessor) + // } Section({ name: "Recon And Settlement", icon: "recon", diff --git a/src/screens/Recon/ReconModule.res b/src/screens/Recon/ReconModule.res index 6c963e345..af283a00b 100644 --- a/src/screens/Recon/ReconModule.res +++ b/src/screens/Recon/ReconModule.res @@ -4,6 +4,7 @@ let make = (~urlList) => { open LogicUtils let getURL = useGetURL() + let handleLogout = useHandleLogout() let fetchDetails = useGetMethod() let (redirectToken, setRedirectToken) = React.useState(_ => "") let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) @@ -23,14 +24,15 @@ let make = (~urlList) => { } let redirectUrl = switch urlList { - | list{"upload-files"} - | list{"run-recon"} - | list{"reports"} - | list{"config-settings"} - | list{"file-processor"} => - urlList->List.toArray->Array.joinWith("/") - | list{"recon-analytics"} => "analytics" + | list{"upload-files"} => "upload-recon-files" + | list{"run-recon"} => "run-recon/home" + | list{"reports"} => "report/reconciliation" + | list{"config-settings"} => "reconcilation-config" + + | list{"recon-analytics"} => "analytics-recon-and-settlement" | _ => "" + // commented as not needed as of now + // | list{"file-processor"} => "file-processor" } React.useEffect(() => { @@ -38,6 +40,37 @@ let make = (~urlList) => { None }, (iframeLoaded, redirectUrl)) + React.useEffect(() => { + // Event listner to check if the session is expired in iframe + let handleIframeMessage = event => { + let dictFromEvent = event->Identity.genericTypeToJson->getDictFromJsonObject + + let eventType = + dictFromEvent + ->getString("data", "") + ->safeParse + ->getDictFromJsonObject + ->getString("event", "") + ->ReconUtils.getEventTypeFromString + + let status = + dictFromEvent + ->getString("data", "") + ->safeParse + ->getDictFromJsonObject + ->getString("AuthenticationStatus", "") + ->ReconUtils.getAuthStatusFromMessage + + if eventType == AuthenticationStatus && status == IframeLoggedOut { + handleLogout()->ignore + } + } + + Window.addEventListener("message", handleIframeMessage) + + Some(() => Window.removeEventListener("message", handleIframeMessage)) + }, []) + <> { switch iframeRef.current->Js.Nullable.toOption { diff --git a/src/screens/Recon/ReconTypes.res b/src/screens/Recon/ReconTypes.res new file mode 100644 index 000000000..d02929fdd --- /dev/null +++ b/src/screens/Recon/ReconTypes.res @@ -0,0 +1,3 @@ +type authStatus = IframeLoggedIn | IframeLoggedOut + +type eventType = AuthenticationStatus diff --git a/src/screens/Recon/ReconUtils.res b/src/screens/Recon/ReconUtils.res new file mode 100644 index 000000000..d7180b2ca --- /dev/null +++ b/src/screens/Recon/ReconUtils.res @@ -0,0 +1,13 @@ +open ReconTypes +let getAuthStatusFromMessage = authStatus => + switch authStatus { + | "LoggedOut" => IframeLoggedOut + | _ => IframeLoggedIn + } + +let getEventTypeFromString = eventTypeString => + switch eventTypeString { + | "AuthenticationStatus" + | _ => + AuthenticationStatus + }