From 61f296d3484e21b4d2a63cc44ee4f08a589b6f93 Mon Sep 17 00:00:00 2001 From: Sagar Naik Date: Thu, 18 Jan 2024 14:51:16 +0530 Subject: [PATCH] fix: fixed request display bug --- .../HyperSwitch/PaymentLogs/PaymentLogs.res | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res b/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res index 1c978dded..20a5016f9 100644 --- a/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res +++ b/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res @@ -15,6 +15,15 @@ type selectedObj = { optionType: logType, } +let filteredKeys = [ + "value", + "merchant_id", + "created_at_precise", + "component", + "platform", + "version", +] + module PrettyPrintJson = { @react.component let make = ( @@ -58,7 +67,7 @@ module PrettyPrintJson = { let copyParsedJson =
handleOnClickCopy(~parsedValue=parsedJson)} className="cursor-pointer"> - +
@@ -117,10 +126,10 @@ module ApiDetailsComponent = { let headerStyle = "text-fs-13 font-medium text-grey-700 break-all" let logType = if paymentDetailsValue->Dict.get("request_id")->Belt.Option.isSome { Payment - } else if paymentDetailsValue->Dict.get("event_id")->Belt.Option.isSome { - Webhooks - } else { + } else if paymentDetailsValue->Dict.get("component")->Belt.Option.isSome { Sdk + } else { + Webhooks } let apiName = switch logType { | Payment => paymentDetailsValue->getString("api_flow", "default value")->camelCaseToTitle @@ -134,14 +143,6 @@ module ApiDetailsComponent = { | Webhooks => paymentDetailsValue->getString("event_id", "") } - let filteredKeys = [ - "value", - "merchant_id", - "created_at_precise", - "component", - "platform", - "version", - ] let requestObject = switch logType { | Payment => paymentDetailsValue->getString("request", "") | Sdk => @@ -451,29 +452,42 @@ let make = (~paymentId, ~createdAt) => { value: initialData->getString("request_id", ""), optionType: Payment, }) - } else if initialData->Dict.get("event_id")->Belt.Option.isSome { - // webhooks - let request = initialData->getString("outgoing_webhook_event_type", "") - let response = initialData->getString("content", "") + } else if initialData->Dict.get("component")->Belt.Option.isSome { + Js.log2(">>", initialData) + // sdk + let request = + initialData + ->Dict.toArray + ->Array.filter(entry => { + let (key, _) = entry + filteredKeys->Array.includes(key)->not + }) + ->Dict.fromArray + ->Js.Json.object_ + ->Js.Json.stringify + let response = + initialData->getString("log_type", "") === "ERROR" + ? initialData->getString("value", "") + : "" setLogDetails(_ => { response, request, }) setSelectedOption(_ => { value: initialData->getString("event_id", ""), - optionType: Webhooks, + optionType: Sdk, }) } else { - // sdk - let request = initialData->getString("event_name", "") - let response = initialData->getString("response", "") + // webhooks + let request = initialData->getString("outgoing_webhook_event_type", "") + let response = initialData->getString("content", "") setLogDetails(_ => { response, request, }) setSelectedOption(_ => { value: initialData->getString("event_id", ""), - optionType: Sdk, + optionType: Webhooks, }) } }