From 255241cf5a53d76beff78f20126aaa1c1466c4c8 Mon Sep 17 00:00:00 2001 From: Sagar naik Date: Wed, 24 Jan 2024 17:30:50 +0530 Subject: [PATCH] feat: added webhooks events (#272) Co-authored-by: Pritish Budhiraja <1805317@kiit.ac.in> --- public/hyperswitch/icons/solid.svg | 15 + src/screens/HyperSwitch/APIUtils/APIUtils.res | 10 + .../HyperSwitch/APIUtils/APIUtilsTypes.res | 2 + .../HyperSwitch/PaymentLogs/PaymentLogs.res | 575 +++++++++++------- .../PaymentLogs/PaymentLogsTypes.res | 11 + ...{PaymentUtils.res => PaymentLogsUtils.res} | 17 + src/utils/LogicUtils.res | 6 +- tailwindHyperSwitch.config.js | 1 + 8 files changed, 412 insertions(+), 225 deletions(-) create mode 100644 src/screens/HyperSwitch/PaymentLogs/PaymentLogsTypes.res rename src/screens/HyperSwitch/PaymentLogs/{PaymentUtils.res => PaymentLogsUtils.res} (57%) diff --git a/public/hyperswitch/icons/solid.svg b/public/hyperswitch/icons/solid.svg index b2467c422..640d696dc 100644 --- a/public/hyperswitch/icons/solid.svg +++ b/public/hyperswitch/icons/solid.svg @@ -1402,6 +1402,21 @@ License) d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z" > + + + + + + + + + + + + + + + "" } + | WEBHOOKS_EVENT_LOGS => + switch id { + | Some(payment_id) => `analytics/v1/outgoing_webhook_event_logs?payment_id=${payment_id}` + | None => "" + } + | CONNECTOR_EVENT_LOGS => + switch id { + | Some(payment_id) => `analytics/v1/connector_event_logs?type=Payment&payment_id=${payment_id}` + | None => "" + } | USERS => let userUrl = `user` switch userType { diff --git a/src/screens/HyperSwitch/APIUtils/APIUtilsTypes.res b/src/screens/HyperSwitch/APIUtils/APIUtilsTypes.res index d0b8eddef..46056dfbf 100644 --- a/src/screens/HyperSwitch/APIUtils/APIUtilsTypes.res +++ b/src/screens/HyperSwitch/APIUtils/APIUtilsTypes.res @@ -17,6 +17,8 @@ type entityName = | ANALYTICS_SYSTEM_METRICS | PAYMENT_LOGS | SDK_EVENT_LOGS + | WEBHOOKS_EVENT_LOGS + | CONNECTOR_EVENT_LOGS | GENERATE_SAMPLE_DATA | USERS | RECON diff --git a/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res b/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res index f7644cf63..55a3d89e7 100644 --- a/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res +++ b/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res @@ -1,8 +1,20 @@ -open OrderUtils -open APIUtils -open LogicUtils @module("js-sha256") external sha256: string => string = "sha256" + +open PaymentLogsTypes +let getLogType = dict => { + if dict->Dict.get("connector_name")->Option.isSome { + CONNECTOR + } else if dict->Dict.get("request_id")->Option.isSome { + PAYMENTS + } else if dict->Dict.get("component")->Option.isSome { + SDK + } else { + WEBHOOKS + } +} + module PrettyPrintJson = { + open LogicUtils @react.component let make = ( ~jsonToDisplay, @@ -13,7 +25,6 @@ module PrettyPrintJson = { let showToast = ToastState.useShowToast() let (isTextVisible, setIsTextVisible) = React.useState(_ => false) let (parsedJson, setParsedJson) = React.useState(_ => "") - let parseJsonValue = () => { try { let parsedValue = jsonToDisplay->Js.Json.parseExn->Js.Json.stringifyWithSpace(3) @@ -34,11 +45,11 @@ module PrettyPrintJson = { let copyParsedJson =
handleOnClickCopy(~parsedValue=parsedJson)} className="cursor-pointer"> - +
-
- String.length > 0}> +
+ isNonEmptyString}> {<> Option.isSome}>
@@ -50,12 +61,9 @@ module PrettyPrintJson = {
+              className={`${overrideBackgroundColor} p-3 text-jp-gray-900 dark:bg-jp-gray-950 dark:bg-opacity-100 text-fs-13 text font-medium`}>
               {parsedJson->React.string}
             
- {copyParsedJson}