From 33000b49abcaf94ffe1fcbc0e3c92bc9d76a8725 Mon Sep 17 00:00:00 2001 From: Riddhi Agrawal Date: Tue, 23 Jan 2024 11:31:02 +0530 Subject: [PATCH] fix: added feature flag for accept dispute --- config/FeatureFlag.json | 5 +- .../hyperswitch/FeatureFlagUtils.res | 2 + .../HyperSwitch/Disputes/ShowDisputes.res | 206 +++++++++--------- 3 files changed, 109 insertions(+), 104 deletions(-) diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json index 2a0addeb4..0458fcdaa 100644 --- a/config/FeatureFlag.json +++ b/config/FeatureFlag.json @@ -1,7 +1,7 @@ { "test_live_toggle": false, "is_live_mode": false, - "magic_link": false, + "magic_link": true, "production_access": false, "quick_start": true, "switch_merchant": true, @@ -23,5 +23,6 @@ "user_journey_analytics": false, "surcharge": false, "customers_module": false, - "permission_based_module": false + "permission_based_module": false, + "dispute_evidence_upload": false } diff --git a/src/entryPoints/hyperswitch/FeatureFlagUtils.res b/src/entryPoints/hyperswitch/FeatureFlagUtils.res index dda0429d9..b48bba1d4 100644 --- a/src/entryPoints/hyperswitch/FeatureFlagUtils.res +++ b/src/entryPoints/hyperswitch/FeatureFlagUtils.res @@ -25,6 +25,7 @@ type featureFlag = { surcharge: bool, customersModule: bool, permissionBasedModule: bool, + disputeEvidenceUpload: bool, } let featureFlagType = (featureFlags: Js.Json.t) => { @@ -57,6 +58,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => { surcharge: dict->getBool("surcharge", false), customersModule: dict->getBool("customers_module", false), permissionBasedModule: dict->getBool("permission_based_module", false), + disputeEvidenceUpload: dict->getBool("dispute_evidence_upload", false), } typedFeatureFlag } diff --git a/src/screens/HyperSwitch/Disputes/ShowDisputes.res b/src/screens/HyperSwitch/Disputes/ShowDisputes.res index 112a238fd..79a6c1e45 100644 --- a/src/screens/HyperSwitch/Disputes/ShowDisputes.res +++ b/src/screens/HyperSwitch/Disputes/ShowDisputes.res @@ -91,116 +91,118 @@ module DisputesInfoBarComponent = { } } +module Details = { + @react.component + let make = ( + ~data: DisputeTypes.disputes, + ~getHeading, + ~getCell, + ~excludeColKeys=[], + ~detailsFields, + ~justifyClassName="justify-start", + ~widthClass="w-1/4", + ~bgColor="bg-white dark:bg-jp-gray-lightgray_background", + ~children=?, + ~setDisputeData, + ) => { + open APIUtils + let updateDetails = useUpdateMethod() + let (disputeStatus, setDisputeStatus) = React.useState(_ => DisputeTypes.Initiated) + let showPopUp = PopUpState.useShowPopUp() + let {disputeEvidenceUpload} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom -module DisputesInfo = { - module Details = { - @react.component - let make = ( - ~data: DisputeTypes.disputes, - ~getHeading, - ~getCell, - ~excludeColKeys=[], - ~detailsFields, - ~justifyClassName="justify-start", - ~widthClass="w-1/4", - ~bgColor="bg-white dark:bg-jp-gray-lightgray_background", - ~children=?, - ~setDisputeData, - ) => { - open APIUtils - let updateDetails = useUpdateMethod() - let (disputeStatus, setDisputeStatus) = React.useState(_ => DisputeTypes.Initiated) - let showPopUp = PopUpState.useShowPopUp() - - let handleAcceptDispute = async () => { - try { - let url = getURL( - ~entityName=ACCEPT_DISPUTE, - ~methodType=Post, - ~id=Some(data.dispute_id), - (), - ) - let response = await updateDetails(url, Dict.make()->Js.Json.object_, Post) - setDisputeData(_ => response) - setDisputeStatus(_ => Accepted) - } catch { - | _ => () - } + let handleAcceptDispute = async () => { + try { + let url = getURL( + ~entityName=ACCEPT_DISPUTE, + ~methodType=Post, + ~id=Some(data.dispute_id), + (), + ) + let response = await updateDetails(url, Dict.make()->Js.Json.object_, Post) + setDisputeData(_ => response) + setDisputeStatus(_ => Accepted) + } catch { + | _ => () } + } - let handlePopupOpen = () => { - showPopUp({ - popUpType: (Warning, WithIcon), - heading: "Accept this dispute?", - description: "By accepting you will lose this dispute and will have to refund the amount to the user. You won’t be able to submit evidence once you accept"->React.string, - handleConfirm: {text: "Proceed", onClick: _ => handleAcceptDispute()->ignore}, - handleCancel: {text: "Cancel"}, - }) - } + let handlePopupOpen = () => { + showPopUp({ + popUpType: (Warning, WithIcon), + heading: "Accept this dispute?", + description: "By accepting you will lose this dispute and will have to refund the amount to the user. You won’t be able to submit evidence once you accept"->React.string, + handleConfirm: {text: "Proceed", onClick: _ => handleAcceptDispute()->ignore}, + handleCancel: {text: "Cancel"}, + }) + } - -
-
-

- {DisputesEntity.amountValue( - data.amount, - data.currency->String.toUpperCase, - )->React.string} -

- {getStatus(data)} -
- -
-
-
+ +
+
+

+ {DisputesEntity.amountValue( + data.amount, + data.currency->String.toUpperCase, + )->React.string} +

+ {getStatus(data)}
-
- - - - -
- {detailsFields - ->Array.mapWithIndex((colType, i) => { - Array.includes(colType))} key={Belt.Int.toString(i)}> -
- -
-
- }) - ->React.array} + +
+
- - Option.isSome}> - {children->Option.getWithDefault(React.null)} - - } +
+
+ + + + +
+ {detailsFields + ->Array.mapWithIndex((colType, i) => { + Array.includes(colType))} key={Belt.Int.toString(i)}> +
+ +
+
+ }) + ->React.array} +
+
+ Option.isSome}> + {children->Option.getWithDefault(React.null)} + + } +} +module DisputesInfo = { @react.component let make = (~orderDict, ~setDisputeData) => { let disputesData = DisputesEntity.itemToObjMapper(orderDict)