Skip to content

Commit

Permalink
fix: omp views changes in analytics & ops (#1452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 authored Sep 24, 2024
1 parent 46277b1 commit b089409
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/screens/Analytics/Analytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ open AnalyticsTypes
@react.component
let make = (
~pageTitle="",
~pageSubTitle="",
~startTimeFilterKey: string,
~endTimeFilterKey: string,
~chartEntity: nestedEntityType,
Expand Down Expand Up @@ -679,7 +678,7 @@ let make = (
| Some(chartEntity) =>
<div>
<div className="flex items-center justify-between">
<PageUtils.PageHeading title=pageTitle subTitle=pageSubTitle />
<PageUtils.PageHeading title=pageTitle />
// Refactor required
<RenderIf condition={moduleName == "Refunds" || moduleName == "Disputes"}>
<OMPSwitchHelper.OMPViews
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ let make = () => {
})

let title = "Authentication Analytics"
let subTitle = "Know more about how well your users are able to authenticate payments"

<div>
<PageLoaderWrapper screenState customUI={<NoData title subTitle />}>
<PageLoaderWrapper screenState customUI={<NoData title />}>
<Analytics
pageTitle=title
pageSubTitle=subTitle
filterUri=None
key="AuthenticationAnalytics"
moduleName="Authentication"
Expand Down
5 changes: 2 additions & 3 deletions src/screens/Analytics/DisputeAnalytics/DisputeAnalytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@ let make = () => {
})

let title = "Disputes Analytics"
let subTitle = "Gain Insights, monitor performance and make Informed Decisions with Dispute Analytics."

let analyticsfilterUrl = getURL(~entityName=ANALYTICS_FILTERS, ~methodType=Post, ~id=Some(domain))
let disputeAnalyticsUrl = getURL(
~entityName=ANALYTICS_PAYMENTS,
~methodType=Post,
~id=Some(domain),
)
<PageLoaderWrapper screenState customUI={<NoData title subTitle />}>
<PageLoaderWrapper screenState customUI={<NoData title />}>
<Analytics
pageTitle=title
pageSubTitle=subTitle
filterUri=Some(analyticsfilterUrl)
key="DisputesAnalytics"
moduleName="Disputes"
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Analytics/HSAnalyticsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ let getStringListFromArrayDict = metrics => {

module NoData = {
@react.component
let make = (~title, ~subTitle) => {
let make = (~title) => {
<div className="p-5">
<PageUtils.PageHeading title subTitle />
<PageUtils.PageHeading title />
<NoDataFound message="No Data Available" renderType=Painting>
<Button
text={"Make a Payment"}
Expand Down
5 changes: 2 additions & 3 deletions src/screens/Analytics/PaymentsAnalytics/PaymentAnalytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ let make = () => {
}

let title = "Payments Analytics"
let subTitle = "Gain Insights, monitor performance and make Informed Decisions with Payment Analytics."

let formaPayload = (singleStatBodyEntity: DynamicSingleStat.singleStatBodyEntity) => {
[
Expand Down Expand Up @@ -234,10 +233,10 @@ let make = () => {
}

open AnalyticsNew
<PageLoaderWrapper screenState customUI={<NoData title subTitle />}>
<PageLoaderWrapper screenState customUI={<NoData title />}>
<div className="flex flex-col gap-5">
<div className="flex items-center justify-between ">
<PageUtils.PageHeading title subTitle />
<PageUtils.PageHeading title />
<OMPSwitchHelper.OMPViews
views={OMPSwitchUtils.analyticsViewList(~checkUserEntity)}
selectedEntity={analyticsEntity}
Expand Down
4 changes: 1 addition & 3 deletions src/screens/Analytics/RefundsAnalytics/RefundsAnalytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,16 @@ let make = () => {
})

let title = "Refunds Analytics"
let subTitle = "Uncover patterns and drive business performance through data-driven insights with refund analytics"

let analyticsfilterUrl = getURL(~entityName=ANALYTICS_FILTERS, ~methodType=Post, ~id=Some(domain))
let refundAnalyticsUrl = getURL(
~entityName=ANALYTICS_PAYMENTS,
~methodType=Post,
~id=Some(domain),
)
<PageLoaderWrapper screenState customUI={<NoData title subTitle />}>
<PageLoaderWrapper screenState customUI={<NoData title />}>
<Analytics
pageTitle=title
pageSubTitle=subTitle
filterUri=Some(analyticsfilterUrl)
key="RefundsAnalytics"
moduleName="Refunds"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,16 @@ let make = () => {

let tabKeys = getStringListFromArrayDict(dimensions)
let title = "System Metrics"
let subTitle = "Gain Insights, monitor performance and make Informed Decisions with System Metrics."

let analyticsfilterUrl = getURL(~entityName=ANALYTICS_FILTERS, ~methodType=Post, ~id=Some(domain))
let systemMetricsAnalyticsUrl = getURL(
~entityName=ANALYTICS_PAYMENTS,
~methodType=Post,
~id=Some(domain),
)
<PageLoaderWrapper screenState customUI={<NoData title subTitle />}>
<PageLoaderWrapper screenState customUI={<NoData title />}>
<SystemMetricsAnalytics
pageTitle=title
pageSubTitle=subTitle
filterUri={analyticsfilterUrl}
key="SystemMetrics"
moduleName="SystemMetrics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ let make = () => {
})

let title = "Know your users"
let subTitle = "User Journey analytics is a level deeper into payment analytics and aims at providing you a wholesome understanding of the end users and their usage patterns."

<div>
<PageLoaderWrapper screenState customUI={<NoData title subTitle />}>
<PageLoaderWrapper screenState customUI={<NoData title />}>
<Analytics
pageTitle=title
pageSubTitle=subTitle
filterUri=Some(`${Window.env.apiBaseUrl}/analytics/v1/filters/sdk_events`)
key="UserJourneyAnalytics"
moduleName="UserJourney"
Expand Down
23 changes: 22 additions & 1 deletion src/screens/OMPSwitch/OMPSwitchHelper.res
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ module OMPViews = {
~selectedEntity: UserInfoTypes.entity,
~onChange,
) => {
open OMPSwitchUtils

let {userInfo} = React.useContext(UserInfoProvider.defaultContext)
let merchantList = Recoil.useRecoilValueFromAtom(HyperswitchAtom.merchantListAtom)
let orgList = Recoil.useRecoilValueFromAtom(HyperswitchAtom.orgListAtom)
let profileList = Recoil.useRecoilValueFromAtom(HyperswitchAtom.profileListAtom)

let cssBasedOnIndex = index => {
if index == 0 {
"rounded-l-md"
Expand All @@ -63,14 +70,28 @@ module OMPViews = {
}
}

let getName = entityType => {
let name = switch entityType {
| #Organization => currentOMPName(orgList, userInfo.orgId)
| #Merchant => currentOMPName(merchantList, userInfo.merchantId)
| #Profile => currentOMPName(profileList, userInfo.profileId)
| _ => ""
}
name->String.length > 10
? name
->String.substring(~start=0, ~end=10)
->String.concat("...")
: name
}

<div className="flex h-fit">
{views
->Array.mapWithIndex((value, index) => {
let selectedStyle = selectedEntity == value.entity ? `bg-blue-200` : ""
<div
onClick={_ => onChange(value.entity)->ignore}
className={`text-sm py-2 px-3 ${selectedStyle} border text-blue-500 border-blue-500 ${index->cssBasedOnIndex} cursor-pointer`}>
{value.lable->React.string}
{`${value.lable} (${value.entity->getName})`->React.string}
</div>
})
->React.array}
Expand Down
5 changes: 3 additions & 2 deletions src/screens/OMPSwitch/OMPSwitchUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ let generateDropdownOptions = dropdownList => {
dropdownList->Array.map((item): SelectBox.dropdownOption => {label: item.name, value: item.id})
options
}

let org = {
lable: "All Merchant",
lable: "Organization",
entity: #Organization,
}
let merchant = {
lable: "All Profile",
lable: "Merchant",
entity: #Merchant,
}
let profile = {
Expand Down

0 comments on commit b089409

Please sign in to comment.