diff --git a/src/screens/NewAnalytics/NewRefundsAnalytics/NewRefundsAnalytics.res b/src/screens/NewAnalytics/NewRefundsAnalytics/NewRefundsAnalytics.res
index 666b74b70..95ed9c3e7 100644
--- a/src/screens/NewAnalytics/NewRefundsAnalytics/NewRefundsAnalytics.res
+++ b/src/screens/NewAnalytics/NewRefundsAnalytics/NewRefundsAnalytics.res
@@ -8,6 +8,10 @@ let make = () => {
+
}
diff --git a/src/screens/NewAnalytics/NewRefundsAnalytics/NewRefundsAnalyticsEntity.res b/src/screens/NewAnalytics/NewRefundsAnalytics/NewRefundsAnalyticsEntity.res
index 8132926a9..3ab177db1 100644
--- a/src/screens/NewAnalytics/NewRefundsAnalytics/NewRefundsAnalyticsEntity.res
+++ b/src/screens/NewAnalytics/NewRefundsAnalytics/NewRefundsAnalyticsEntity.res
@@ -59,6 +59,39 @@ let refundsSuccessRateChartEntity: chartEntity<
getObjects: RefundsSuccessRateUtils.refundsSuccessRateMapper,
getChatOptions: LineGraphUtils.getLineGraphOptions,
}
+// Successful Refunds Distribution
+let successfulRefundsDistributionEntity: moduleEntity = {
+ requestBodyConfig: {
+ delta: false,
+ groupBy: [#connector],
+ metrics: [#sessionized_refund_count, #sessionized_refund_success_count],
+ },
+ title: "Successful Refunds Distribution By Connector",
+ domain: #refunds,
+}
+
+let successfulRefundsDistributionChartEntity: chartEntity<
+ BarGraphTypes.barGraphPayload,
+ BarGraphTypes.barGraphOptions,
+ JSON.t,
+> = {
+ getObjects: SuccessfulRefundsDistributionUtils.successfulRefundsDistributionMapper,
+ getChatOptions: BarGraphUtils.getBarGraphOptions,
+}
+
+let successfulRefundsDistributionTableEntity = {
+ open SuccessfulRefundsDistributionUtils
+ EntityType.makeEntity(
+ ~uri=``,
+ ~getObjects,
+ ~dataKey="queryData",
+ ~defaultColumns=[],
+ ~requiredSearchFieldsList=[],
+ ~allColumns=[],
+ ~getCell,
+ ~getHeading,
+ )
+}
// Refunds Reasons
let refundsReasonsEntity: moduleEntity = {
diff --git a/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistribution.res b/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistribution.res
new file mode 100644
index 000000000..89c28a06c
--- /dev/null
+++ b/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistribution.res
@@ -0,0 +1,139 @@
+open NewAnalyticsTypes
+open NewAnalyticsHelper
+open NewRefundsAnalyticsEntity
+open BarGraphTypes
+open SuccessfulRefundsDistributionUtils
+open SuccessfulRefundsDistributionTypes
+
+module TableModule = {
+ @react.component
+ let make = (~data, ~className="") => {
+ let (offset, setOffset) = React.useState(_ => 0)
+ let defaultSort: Table.sortedObject = {
+ key: "",
+ order: Table.INC,
+ }
+
+ let visibleColumns = [Connector, Refunds_Success_Rate]
+ let tableData = getTableData(data)
+
+
+ Array.length}
+ offset
+ setOffset
+ defaultSort
+ currrentFetchCount={tableData->Array.length}
+ tableLocalFilter=false
+ tableheadingClass=tableBorderClass
+ tableBorderClass
+ ignoreHeaderBg=true
+ tableDataBorderClass=tableBorderClass
+ isAnalyticsModule=true
+ />
+
+ }
+}
+
+module SuccessfulRefundsDistributionHeader = {
+ @react.component
+ let make = (~viewType, ~setViewType) => {
+ let setViewType = value => {
+ setViewType(_ => value)
+ }
+
+
+ }
+}
+
+@react.component
+let make = (
+ ~entity: moduleEntity,
+ ~chartEntity: chartEntity,
+) => {
+ open LogicUtils
+ open APIUtils
+ let getURL = useGetURL()
+ let updateDetails = useUpdateMethod()
+ let {filterValueJson} = React.useContext(FilterContext.filterContext)
+ let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading)
+ let (refundsDistribution, setrefundsDistribution) = React.useState(_ => JSON.Encode.array([]))
+ let (viewType, setViewType) = React.useState(_ => Graph)
+ let startTimeVal = filterValueJson->getString("startTime", "")
+ let endTimeVal = filterValueJson->getString("endTime", "")
+
+ let getRefundsDistribution = async () => {
+ setScreenState(_ => PageLoaderWrapper.Loading)
+ try {
+ let url = getURL(
+ ~entityName=ANALYTICS_REFUNDS,
+ ~methodType=Post,
+ ~id=Some((entity.domain: domain :> string)),
+ )
+
+ let body = NewAnalyticsUtils.requestBody(
+ ~startTime=startTimeVal,
+ ~endTime=endTimeVal,
+ ~delta=entity.requestBodyConfig.delta,
+ ~metrics=entity.requestBodyConfig.metrics,
+ ~groupByNames=[Connector->getStringFromVariant]->Some,
+ )
+
+ let response = await updateDetails(url, body, Post)
+
+ let responseData =
+ response->getDictFromJsonObject->getArrayFromDict("queryData", [])->modifyQuery
+
+ if responseData->Array.length > 0 {
+ setrefundsDistribution(_ => responseData->JSON.Encode.array)
+ setScreenState(_ => PageLoaderWrapper.Success)
+ } else {
+ setScreenState(_ => PageLoaderWrapper.Custom)
+ }
+ } catch {
+ | _ => setScreenState(_ => PageLoaderWrapper.Custom)
+ }
+ }
+
+ React.useEffect(() => {
+ if startTimeVal->isNonEmptyString && endTimeVal->isNonEmptyString {
+ getRefundsDistribution()->ignore
+ }
+ None
+ }, [startTimeVal, endTimeVal])
+
+ let params = {
+ data: refundsDistribution,
+ xKey: Refunds_Success_Rate->getStringFromVariant,
+ yKey: Connector->getStringFromVariant,
+ }
+
+
+
+
+ } customUI={}>
+
+
+ {switch viewType {
+ | Graph =>
+
+ | Table =>
+ }}
+
+
+
+
+}
diff --git a/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistributionTypes.res b/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistributionTypes.res
new file mode 100644
index 000000000..7f9c61e72
--- /dev/null
+++ b/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistributionTypes.res
@@ -0,0 +1,12 @@
+type successfulRefundsDistributionTypes =
+ | Refunds_Success_Rate
+ | Refund_Count
+ | Refund_Success_Count
+ | Connector
+
+type successfulRefundsDistributionObject = {
+ refund_count: int,
+ refund_success_count: int,
+ refunds_success_rate: float,
+ connector: string,
+}
diff --git a/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistributionUtils.res b/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistributionUtils.res
new file mode 100644
index 000000000..8f58b8b0e
--- /dev/null
+++ b/src/screens/NewAnalytics/NewRefundsAnalytics/SuccessfulRefundsDistribution/SuccessfulRefundsDistributionUtils.res
@@ -0,0 +1,108 @@
+open NewAnalyticsUtils
+open LogicUtils
+open SuccessfulRefundsDistributionTypes
+
+let getStringFromVariant = value => {
+ switch value {
+ | Refunds_Success_Rate => "refunds_success_rate"
+ | Refund_Count => "refund_count"
+ | Refund_Success_Count => "refund_success_count"
+ | Connector => "connector"
+ }
+}
+
+let successfulRefundsDistributionMapper = (
+ ~params: NewAnalyticsTypes.getObjects,
+): BarGraphTypes.barGraphPayload => {
+ open BarGraphTypes
+ let {data, xKey, yKey} = params
+ let categories = [data]->JSON.Encode.array->getCategories(0, yKey)
+
+ let barGraphData = getBarGraphObj(
+ ~array=data->getArrayFromJson([]),
+ ~key=xKey,
+ ~name=xKey->snakeToTitle,
+ ~color=barGreenColor,
+ )
+
+ let title = {
+ text: "",
+ }
+
+ let tooltipFormatter = bargraphTooltipFormatter(
+ ~title="Successful Refunds Distribution",
+ ~metricType=Rate,
+ )
+
+ {
+ categories,
+ data: [barGraphData],
+ title,
+ tooltipFormatter,
+ }
+}
+
+let tableItemToObjMapper: Dict.t => successfulRefundsDistributionObject = dict => {
+ {
+ refund_count: dict->getInt(Refund_Count->getStringFromVariant, 0),
+ refund_success_count: dict->getInt(Refund_Success_Count->getStringFromVariant, 0),
+ refunds_success_rate: dict->getFloat(Refunds_Success_Rate->getStringFromVariant, 0.0),
+ connector: dict->getString(Connector->getStringFromVariant, ""),
+ }
+}
+
+let getObjects: JSON.t => array = json => {
+ json
+ ->LogicUtils.getArrayFromJson([])
+ ->Array.map(item => {
+ tableItemToObjMapper(item->getDictFromJsonObject)
+ })
+}
+
+let getHeading = colType => {
+ switch colType {
+ | Refunds_Success_Rate =>
+ Table.makeHeaderInfo(
+ ~key=Refunds_Success_Rate->getStringFromVariant,
+ ~title="Refunds Success Rate",
+ ~dataType=TextType,
+ )
+ | Connector =>
+ Table.makeHeaderInfo(
+ ~key=Connector->getStringFromVariant,
+ ~title="Connector",
+ ~dataType=TextType,
+ )
+ | _ => Table.makeHeaderInfo(~key="", ~title="", ~dataType=TextType)
+ }
+}
+
+let getCell = (obj, colType): Table.cell => {
+ switch colType {
+ | Refunds_Success_Rate => Text(obj.refunds_success_rate->valueFormatter(Rate))
+ | Connector => Text(obj.connector)
+ | _ => Text("")
+ }
+}
+
+let getTableData = json => {
+ json->getArrayDataFromJson(tableItemToObjMapper)->Array.map(Nullable.make)
+}
+
+let modifyQuery = query => {
+ query->Array.map(value => {
+ let valueDict = value->getDictFromJsonObject
+ let refund_count = valueDict->getInt(Refund_Count->getStringFromVariant, 0)->Int.toFloat
+ let refund_success_count =
+ valueDict->getInt(Refund_Success_Count->getStringFromVariant, 0)->Int.toFloat
+
+ let refunds_success_rate = refund_success_count /. refund_count *. 100.0
+
+ valueDict->Dict.set(
+ Refunds_Success_Rate->getStringFromVariant,
+ refunds_success_rate->JSON.Encode.float,
+ )
+
+ valueDict->JSON.Encode.object
+ })
+}