From 43c2986c3076b2a1f2c3b681da8dfd7afdf73a33 Mon Sep 17 00:00:00 2001 From: Sagar Naik Date: Sat, 9 Nov 2024 11:42:29 +0530 Subject: [PATCH 1/3] fix: currency field key fixes --- .../NewPaymentsOverviewSectionTypes.res | 8 +++--- .../NewPaymentsOverviewSectionUtils.res | 16 +++++------ .../PaymentsProcessedTypes.res | 8 +++--- .../PaymentsProcessedUtils.res | 28 +++++++++---------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionTypes.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionTypes.res index fec32d4fd..afb0f40cc 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionTypes.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionTypes.res @@ -9,13 +9,13 @@ type overviewColumns = | Total_Dispute type dataObj = { - total_smart_retried_amount_usd: float, - total_smart_retried_amount_without_smart_retries_usd: float, + total_smart_retried_amount_in_usd: float, + total_smart_retried_amount_without_smart_retries_in_usd: float, total_success_rate: float, total_success_rate_without_smart_retries: float, - total_payment_processed_amount_usd: float, + total_payment_processed_amount_in_usd: float, total_payment_processed_count: int, - total_payment_processed_amount_without_smart_retries_usd: float, + total_payment_processed_amount_without_smart_retries_in_usd: float, total_payment_processed_count_without_smart_retries: int, refund_processed_amount: float, total_dispute: int, diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionUtils.res index c2d189625..1e2722563 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionUtils.res @@ -2,12 +2,12 @@ open NewPaymentsOverviewSectionTypes let getStringFromVariant = value => { switch value { - | Total_Smart_Retried_Amount => "total_smart_retried_amount_usd" - | Total_Smart_Retried_Amount_Without_Smart_Retries => "total_smart_retried_amount_without_smart_retries_usd" + | Total_Smart_Retried_Amount => "total_smart_retried_amount_in_usd" + | Total_Smart_Retried_Amount_Without_Smart_Retries => "total_smart_retried_amount_without_smart_retries_in_usd" | Total_Success_Rate => "total_success_rate" | Total_Success_Rate_Without_Smart_Retries => "total_success_rate_without_smart_retries" - | Total_Payment_Processed_Amount => "total_payment_processed_amount_usd" - | Total_Payment_Processed_Amount_Without_Smart_Retries => "total_payment_processed_amount_without_smart_retries_usd" + | Total_Payment_Processed_Amount => "total_payment_processed_amount_in_usd" + | Total_Payment_Processed_Amount_Without_Smart_Retries => "total_payment_processed_amount_without_smart_retries_in_usd" | Refund_Processed_Amount => "refund_processed_amount" | Total_Dispute => "total_dispute" } @@ -15,13 +15,13 @@ let getStringFromVariant = value => { let defaultValue = { - total_smart_retried_amount_usd: 0.0, - total_smart_retried_amount_without_smart_retries_usd: 0.0, + total_smart_retried_amount_in_usd: 0.0, + total_smart_retried_amount_without_smart_retries_in_usd: 0.0, total_success_rate: 0.0, total_success_rate_without_smart_retries: 0.0, - total_payment_processed_amount_usd: 0.0, + total_payment_processed_amount_in_usd: 0.0, total_payment_processed_count: 0, - total_payment_processed_amount_without_smart_retries_usd: 0.0, + total_payment_processed_amount_without_smart_retries_in_usd: 0.0, total_payment_processed_count_without_smart_retries: 0, refund_processed_amount: 0.0, total_dispute: 0, diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedTypes.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedTypes.res index 1add17f7c..0029235c6 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedTypes.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedTypes.res @@ -10,13 +10,13 @@ type paymentsProcessedCols = | Time_Bucket type paymentsProcessedObject = { - payment_processed_amount_usd: float, + payment_processed_amount_in_usd: float, payment_processed_count: int, - payment_processed_amount_without_smart_retries_usd: float, + payment_processed_amount_without_smart_retries_in_usd: float, payment_processed_count_without_smart_retries: int, - total_payment_processed_amount_usd: float, + total_payment_processed_amount_in_usd: float, total_payment_processed_count: int, - total_payment_processed_amount_without_smart_retries_usd: float, + total_payment_processed_amount_without_smart_retries_in_usd: float, total_payment_processed_count_without_smart_retries: int, time_bucket: string, } diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res index f908e8b45..88a9277a4 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res @@ -4,13 +4,13 @@ open LogicUtils let getStringFromVariant = value => { switch value { - | Payment_Processed_Amount => "payment_processed_amount_usd" + | Payment_Processed_Amount => "payment_processed_amount_in_usd" | Payment_Processed_Count => "payment_processed_count" - | Payment_Processed_Amount_Without_Smart_Retries => "payment_processed_amount_without_smart_retries_usd" + | Payment_Processed_Amount_Without_Smart_Retries => "payment_processed_amount_without_smart_retries_in_usd" | Payment_Processed_Count_Without_Smart_Retries => "payment_processed_count_without_smart_retries" - | Total_Payment_Processed_Amount => "total_payment_processed_amount_usd" + | Total_Payment_Processed_Amount => "total_payment_processed_amount_in_usd" | Total_Payment_Processed_Count => "total_payment_processed_count" - | Total_Payment_Processed_Amount_Without_Smart_Retries => "total_payment_processed_amount_without_smart_retries_usd" + | Total_Payment_Processed_Amount_Without_Smart_Retries => "total_payment_processed_amount_without_smart_retries_in_usd" | Total_Payment_Processed_Count_Without_Smart_Retriess => "total_payment_processed_count_without_smart_retries" | Time_Bucket => "time_bucket" } @@ -18,14 +18,14 @@ let getStringFromVariant = value => { let getVariantValueFromString = value => { switch value { - | "payment_processed_amount_usd" => Payment_Processed_Amount + | "payment_processed_amount_in_usd" => Payment_Processed_Amount | "payment_processed_count" => Payment_Processed_Count - | "payment_processed_amount_without_smart_retries_usd" => + | "payment_processed_amount_without_smart_retries_in_usd" => Payment_Processed_Amount_Without_Smart_Retries | "payment_processed_count_without_smart_retries" => Payment_Processed_Count_Without_Smart_Retries - | "total_payment_processed_amount_usd" => Total_Payment_Processed_Amount + | "total_payment_processed_amount_in_usd" => Total_Payment_Processed_Amount | "total_payment_processed_count" => Total_Payment_Processed_Count - | "total_payment_processed_amount_without_smart_retries_usd" => + | "total_payment_processed_amount_without_smart_retries_in_usd" => Total_Payment_Processed_Amount_Without_Smart_Retries | "total_payment_processed_count_without_smart_retries" => Total_Payment_Processed_Count_Without_Smart_Retriess @@ -98,25 +98,25 @@ let visibleColumns = [Time_Bucket] let tableItemToObjMapper: Dict.t => paymentsProcessedObject = dict => { { - payment_processed_amount_usd: dict->getAmountValue( + payment_processed_amount_in_usd: dict->getAmountValue( ~id=Payment_Processed_Amount->getStringFromVariant, ), payment_processed_count: dict->getInt(Payment_Processed_Count->getStringFromVariant, 0), - payment_processed_amount_without_smart_retries_usd: dict->getAmountValue( + payment_processed_amount_without_smart_retries_in_usd: dict->getAmountValue( ~id=Payment_Processed_Amount_Without_Smart_Retries->getStringFromVariant, ), payment_processed_count_without_smart_retries: dict->getInt( Payment_Processed_Count_Without_Smart_Retries->getStringFromVariant, 0, ), - total_payment_processed_amount_usd: dict->getAmountValue( + total_payment_processed_amount_in_usd: dict->getAmountValue( ~id=Total_Payment_Processed_Amount->getStringFromVariant, ), total_payment_processed_count: dict->getInt( Total_Payment_Processed_Count->getStringFromVariant, 0, ), - total_payment_processed_amount_without_smart_retries_usd: dict->getAmountValue( + total_payment_processed_amount_without_smart_retries_in_usd: dict->getAmountValue( ~id=Total_Payment_Processed_Amount_Without_Smart_Retries->getStringFromVariant, ), total_payment_processed_count_without_smart_retries: dict->getInt( @@ -175,9 +175,9 @@ let getHeading = colType => { let getCell = (obj, colType): Table.cell => { open NewAnalyticsUtils switch colType { - | Payment_Processed_Amount => Text(obj.payment_processed_amount_usd->valueFormatter(Amount)) + | Payment_Processed_Amount => Text(obj.payment_processed_amount_in_usd->valueFormatter(Amount)) | Payment_Processed_Amount_Without_Smart_Retries => - Text(obj.payment_processed_amount_without_smart_retries_usd->valueFormatter(Amount)) + Text(obj.payment_processed_amount_without_smart_retries_in_usd->valueFormatter(Amount)) | Payment_Processed_Count => Text(obj.payment_processed_count->Int.toString) | Payment_Processed_Count_Without_Smart_Retries => Text(obj.payment_processed_count_without_smart_retries->Int.toString) From 51b1c190c70703eb2bcd5b3e76247d1a05f33d56 Mon Sep 17 00:00:00 2001 From: Sagar Naik Date: Sat, 9 Nov 2024 12:16:25 +0530 Subject: [PATCH 2/3] fix: bar chart empty label fix --- .../NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res index 105d5d824..2d3b98132 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res @@ -6,7 +6,7 @@ let getCategories = (data: JSON.t, index: int, key: string) => { ->getValueFromArray(index, []->JSON.Encode.array) ->getArrayFromJson([]) ->Array.map(item => { - let value = item->getDictFromJsonObject->getString(key, "") + let value = item->getDictFromJsonObject->getString(key, "NA") if value->isNonEmptyString && key == "time_bucket" { let dateObj = value->DayJs.getDayJsForString From abef4220469be4d610f49535d60f47e16fc1f57c Mon Sep 17 00:00:00 2001 From: Sagar Naik Date: Sat, 9 Nov 2024 12:42:21 +0530 Subject: [PATCH 3/3] chore: minor changes --- .../Graphs/LineGraph/LineGraphTypes.res | 2 ++ .../Graphs/LineGraph/LineGraphUtils.res | 22 ++++++++++++++----- .../NewPaymentAnalyticsUtils.res | 5 ++++- .../NewPaymentsOverviewSectionHelper.res | 9 ++++++-- .../PaymentsProcessed/PaymentsProcessed.res | 2 +- .../PaymentsProcessedUtils.res | 1 + .../PaymentsSuccessRateUtils.res | 1 + 7 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/screens/NewAnalytics/Graphs/LineGraph/LineGraphTypes.res b/src/screens/NewAnalytics/Graphs/LineGraph/LineGraphTypes.res index 1a7527d1b..fda5413d2 100644 --- a/src/screens/NewAnalytics/Graphs/LineGraph/LineGraphTypes.res +++ b/src/screens/NewAnalytics/Graphs/LineGraph/LineGraphTypes.res @@ -66,6 +66,7 @@ type yAxis = { gridLineColor: gridLineColor, gridLineDashStyle: gridLineDashStyle, min: min, + max?: option, } type xAxis = { @@ -115,5 +116,6 @@ type lineGraphPayload = { categories: categories, data: data, title: title, + yAxisMaxValue: option, tooltipFormatter: pointFormatter => string, } diff --git a/src/screens/NewAnalytics/Graphs/LineGraph/LineGraphUtils.res b/src/screens/NewAnalytics/Graphs/LineGraph/LineGraphUtils.res index 08103d41f..14a289cdc 100644 --- a/src/screens/NewAnalytics/Graphs/LineGraph/LineGraphUtils.res +++ b/src/screens/NewAnalytics/Graphs/LineGraph/LineGraphUtils.res @@ -1,13 +1,21 @@ open LineGraphTypes let getLineGraphOptions = (lineGraphOptions: lineGraphPayload) => { - let {categories, data, title, tooltipFormatter} = lineGraphOptions + let {categories, data, title, tooltipFormatter, yAxisMaxValue} = lineGraphOptions let stepInterval = Js.Math.max_int( Js.Math.ceil_int(categories->Array.length->Int.toFloat /. 20.0), 1, ) + let yAxis: LineGraphTypes.yAxis = { + title, + gridLineWidth: 1, + gridLineColor: "#e6e6e6", + gridLineDashStyle: "Dash", + min: 0, + } + { chart: { \"type": "line", @@ -52,11 +60,13 @@ let getLineGraphOptions = (lineGraphOptions: lineGraphPayload) => { shared: true, // Allows multiple series' data to be shown in a single tooltip }, yAxis: { - title, - gridLineWidth: 1, - gridLineColor: "#e6e6e6", - gridLineDashStyle: "Dash", - min: 0, + switch yAxisMaxValue { + | Some(val) => { + ...yAxis, + max: val->Some, + } + | _ => yAxis + } }, plotOptions: { line: { diff --git a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res index 2d3b98132..7cc2eb4f2 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalyticsUtils.res @@ -142,12 +142,15 @@ let tooltipFormatter = ( let primartPoint = this.points->getValueFromArray(0, defaultValue) let secondaryPoint = this.points->getValueFromArray(1, defaultValue) + // TODO:Currency need to be picked from filter + let suffix = metricType == NewAnalyticsTypes.Amount ? "USD" : "" + let getRowsHtml = (~iconColor, ~date, ~value, ~comparisionComponent="") => { let valueString = valueFormatter(value, metricType) `
${date}${comparisionComponent}
-
${valueString}
+
${valueString} ${suffix}
` } diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionHelper.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionHelper.res index 1771749de..92b380ef6 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionHelper.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionHelper.res @@ -20,7 +20,7 @@ module SmartRetryCard = { connector-list
- {`Saved ${valueFormatter(primaryValue, config.valueType)}`->React.string} + {`Saved ${valueFormatter(primaryValue, config.valueType)} USD`->React.string} // TODO:Currency need to be picked from filter
@@ -57,7 +57,12 @@ module OverViewStat = {
- {valueFormatter(primaryValue, config.valueType)->React.string} + { + let value = valueFormatter(primaryValue, config.valueType) + let suffix = config.valueType == Amount ? "USD" : "" + + `${value} ${suffix}`->React.string + }
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res index 97fd72968..22e3c4393 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res @@ -112,7 +112,7 @@ module PaymentsProcessedHeader = {
- {primaryValue->valueFormatter(Amount)->React.string} + {`${primaryValue->valueFormatter(Amount)} USD`->React.string} // TODO:Currency need to be picked from filter
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res index 88a9277a4..9e3af23ef 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res @@ -76,6 +76,7 @@ let paymentsProcessedMapper = ( categories: primaryCategories, data: lineGraphData, title, + yAxisMaxValue: None, tooltipFormatter: tooltipFormatter( ~secondaryCategories, ~title="Payments Processed", diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res index 856b1a74b..1abb0c3ec 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res @@ -55,6 +55,7 @@ let paymentsSuccessRateMapper = ( categories: primaryCategories, data: lineGraphData, title, + yAxisMaxValue: 100->Some, tooltipFormatter: tooltipFormatter( ~secondaryCategories, ~title="Payments Success Rate",