From d5c65c711ae753b827b5a729ee08fc8b526553e8 Mon Sep 17 00:00:00 2001 From: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:55:52 +0530 Subject: [PATCH] fix: Prod deployment changes (#36) --- .../hyperswitch/FeatureFlagUtils.res | 4 +-- .../hyperswitch/HyperSwitchApp.res | 32 ++++++++++++------- .../hyperswitch/HyperSwitchEntry.res | 7 ++-- .../Connectors/ConnectorAccountDetails.res | 4 +-- .../ConnectorAccountDetailsHelper.res | 2 +- .../HyperSwitch/Connectors/ConnectorList.res | 11 ++++--- .../HyperSwitch/FraudAndRisk/FRMConfigure.res | 2 +- .../FraudAndRisk/FRMIntegrationFields.res | 6 +++- .../CommonConnectorFlow/SetupConnector.res | 2 +- src/screens/HyperSwitch/Home/HomeUtils.res | 17 ++++++---- .../HyperSwitch/Order/OrderUIUtils.res | 4 +-- .../SetupConnectorCredentials.res | 4 +-- .../HyperSwitchAuthScreen.res | 2 +- .../HSwitchLoginFlow/HyperSwitchAuthUtils.res | 17 ++++++---- 14 files changed, 68 insertions(+), 46 deletions(-) diff --git a/src/entryPoints/hyperswitch/FeatureFlagUtils.res b/src/entryPoints/hyperswitch/FeatureFlagUtils.res index 7393d0165..1236a653e 100644 --- a/src/entryPoints/hyperswitch/FeatureFlagUtils.res +++ b/src/entryPoints/hyperswitch/FeatureFlagUtils.res @@ -8,7 +8,7 @@ type featureFlag = { openSDK: bool, homePage: bool, switchMerchant: bool, - testLiveMode: bool, + testLiveMode: option, auditTrail: bool, systemMetrics: bool, sampleData: bool, @@ -38,7 +38,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => { openSDK: dict->getBool("open_sdk", false), homePage: dict->getBool("home_page", false), switchMerchant: dict->getBool("switch_merchant", false), - testLiveMode: dict->getBool("test_live_mode", false), + testLiveMode: dict->getOptionBool("test_live_mode"), auditTrail: dict->getBool("audit_trail", false), systemMetrics: dict->getBool("system_metrics", false), sampleData: dict->getBool("sample_data", false), diff --git a/src/entryPoints/hyperswitch/HyperSwitchApp.res b/src/entryPoints/hyperswitch/HyperSwitchApp.res index 65c6e216f..e6a3c48a5 100644 --- a/src/entryPoints/hyperswitch/HyperSwitchApp.res +++ b/src/entryPoints/hyperswitch/HyperSwitchApp.res @@ -50,12 +50,14 @@ let make = () => { let getEnumDetails = EnumVariantHook.useFetchEnumDetails() let verificationDays = getFromMerchantDetails("verification")->LogicUtils.getIntFromString(-1) let userRole = getFromUserDetails("user_role") - let modeText = featureFlagDetails.testLiveMode ? "Live Mode" : "Test Mode" + let modeText = + featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false) ? "Live Mode" : "Test Mode" let titleComingSoonMessage = "Coming Soon!" let subtitleComingSoonMessage = "We are currently working on this page." - let modeStyles = featureFlagDetails.testLiveMode - ? "bg-hyperswitch_green_trans border-hyperswitch_green_trans text-hyperswitch_green" - : "bg-orange-600/80 border-orange-500 text-grey-700" + let modeStyles = + featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false) + ? "bg-hyperswitch_green_trans border-hyperswitch_green_trans text-hyperswitch_green" + : "bg-orange-600/80 border-orange-500 text-grey-700" let merchantDetailsValue = HSwitchUtils.useMerchantDetailsValue() let isReconEnabled = @@ -121,17 +123,9 @@ let make = () => { let _profileDetails = await fetchBusinessProfiles() let _connectorList = await fetchConnectorListResponse() let _merchantDetails = await fetchMerchantAccountDetails() - - if featureFlagDetails.testLiveMode { - getAgreementEnum()->ignore - } else { - setDashboardPageState(_ => #HOME) - setScreenState(_ => PageLoaderWrapper.Success) - } } catch { | _ => setDashboardPageState(_ => #HOME) - setScreenState(_ => PageLoaderWrapper.Error("")) } } @@ -141,6 +135,20 @@ let make = () => { None }) + React.useEffect1(() => { + switch featureFlagDetails.testLiveMode { + | Some(val) => + if val { + getAgreementEnum()->ignore + } else { + setDashboardPageState(_ => #HOME) + setScreenState(_ => PageLoaderWrapper.Success) + } + | None => () + } + None + }, [featureFlagDetails.testLiveMode]) + React.useEffect1(() => { if featureFlagDetails.quickStart { fetchInitialEnums()->ignore diff --git a/src/entryPoints/hyperswitch/HyperSwitchEntry.res b/src/entryPoints/hyperswitch/HyperSwitchEntry.res index 1eec333bd..29c8550bd 100644 --- a/src/entryPoints/hyperswitch/HyperSwitchEntry.res +++ b/src/entryPoints/hyperswitch/HyperSwitchEntry.res @@ -42,9 +42,10 @@ module HyperSwitchEntryComponent = { let setPageName = pageTitle => { let page = pageTitle->LogicUtils.snakeToTitle - let title = featureFlagDetails.testLiveMode - ? `${page} - Dashboard` - : `${page} - Dashboard [Test]` + let title = + featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false) + ? `${page} - Dashboard` + : `${page} - Dashboard [Test]` DOMUtils.document.title = title GoogleAnalytics.send({hitType: "pageview", page}) hyperswitchMixPanel( diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res index 271cb45c5..b70337231 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res @@ -339,7 +339,7 @@ let make = ( ~connector, ~bodyType, ~isPayoutFlow, - ~isLiveMode={featureFlagDetails.testLiveMode}, + ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, (), ) setScreenState(_ => Loading) @@ -392,7 +392,7 @@ let make = ( ~connector, ~bodyType, ~isPayoutFlow, - ~isLiveMode={featureFlagDetails.testLiveMode}, + ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, (), )->ignoreFields(connectorID, verifyConnectorIgnoreField) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetailsHelper.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetailsHelper.res index 050a1f127..366abf74f 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetailsHelper.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetailsHelper.res @@ -132,7 +132,7 @@ module RenderConnectorInputFields = { ~selectedConnector, ~dict=details, ~fieldName=formName, - ~isLiveMode={featureFlagDetails.testLiveMode}, + ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, )} /> diff --git a/src/screens/HyperSwitch/Connectors/ConnectorList.res b/src/screens/HyperSwitch/Connectors/ConnectorList.res index 150f1bd7c..8cca1013e 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorList.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorList.res @@ -11,11 +11,12 @@ module NewProcessorCards = { ->LogicUtils.safeParse ->FeatureFlagUtils.featureFlagType - let connectorsAvailableForIntegration = featureFlagDetails.testLiveMode - ? ConnectorUtils.connectorListForLive - : isPayoutFlow - ? ConnectorUtils.payoutConnectorList - : ConnectorUtils.connectorList + let connectorsAvailableForIntegration = + featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false) + ? ConnectorUtils.connectorListForLive + : isPayoutFlow + ? ConnectorUtils.payoutConnectorList + : ConnectorUtils.connectorList let unConfiguredConnectors = connectorsAvailableForIntegration->Js.Array2.filter(total => diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res b/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res index 3b8b05328..39467a555 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res @@ -32,7 +32,7 @@ let make = () => { setInitialValues(_ => { generateInitialValuesDict( ~selectedFRMInfo=frmInfo, - ~isLiveMode=featureFlagDetails.testLiveMode, + ~isLiveMode=featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false), (), ) }) diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res index ca20884e5..b38dbca63 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res @@ -228,7 +228,11 @@ let make = ( } | None => - generateInitialValuesDict(~selectedFRMInfo, ~isLiveMode={featureFlagDetails.testLiveMode}, ()) + generateInitialValuesDict( + ~selectedFRMInfo, + ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, + (), + ) } }, [retrivedValues]) diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res index 621364994..898e63aef 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res @@ -91,7 +91,7 @@ module ConfigureProcessor = { ~connector=connectorName, ~bodyType, ~isPayoutFlow=false, - ~isLiveMode={featureFlagDetails.testLiveMode}, + ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, (), ) setInitialValues(_ => body) diff --git a/src/screens/HyperSwitch/Home/HomeUtils.res b/src/screens/HyperSwitch/Home/HomeUtils.res index e87ce358c..663ae1785 100644 --- a/src/screens/HyperSwitch/Home/HomeUtils.res +++ b/src/screens/HyperSwitch/Home/HomeUtils.res @@ -277,13 +277,16 @@ module ControlCenter = { let pageName = url.path->getPageNameFromUrl - let isLiveModeEnabledStyles = testLiveMode - ? "flex flex-col md:flex-row gap-5 w-full" - : "flex flex-col gap-5 md:w-1/2 w-full" + let isLiveModeEnabledStyles = + testLiveMode->Belt.Option.getWithDefault(false) + ? "flex flex-col md:flex-row gap-5 w-full" + : "flex flex-col gap-5 md:w-1/2 w-full"
- + Belt.Option.getWithDefault(false) ? "" : "h-3/6"}> - + Belt.Option.getWithDefault(false) ? "" : "h-4/6"}>
- + Belt.Option.getWithDefault(false))}>
diff --git a/src/screens/HyperSwitch/Order/OrderUIUtils.res b/src/screens/HyperSwitch/Order/OrderUIUtils.res index c84381ed3..5cca74b2f 100644 --- a/src/screens/HyperSwitch/Order/OrderUIUtils.res +++ b/src/screens/HyperSwitch/Order/OrderUIUtils.res @@ -88,7 +88,7 @@ module NoData = { ->FeatureFlagUtils.featureFlagType Belt.Option.getWithDefault(false) ? "There are no payments as of now." : "There are no payments as of now. Try making a test payment and visualise the checkout experience." : "Connect to a connector like Stripe, Adyen or Hyperswitch provided test connector to make your first payment."} @@ -96,7 +96,7 @@ module NoData = { moduleName="" paymentModal setPaymentModal - showRedirectCTA={!testLiveMode} + showRedirectCTA={!(testLiveMode->Belt.Option.getWithDefault(false))} mixPanelEventName={isConfigureConnector ? "paymentops_makeapayment" : "payemntops_connectaconnector"} diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res index be46a9701..e6f70932c 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res @@ -173,7 +173,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { ~values, ~connector=connectorName, ~bodyType, - ~isLiveMode={featureFlagDetails.testLiveMode}, + ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, (), ) @@ -238,7 +238,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { ~connector={connectorName}, ~bodyType, ~isPayoutFlow=false, - ~isLiveMode={featureFlagDetails.testLiveMode}, + ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, (), )->ignoreFields(connectorID, verifyConnectorIgnoreField) diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res index ade1b4c48..ed749027e 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res @@ -74,7 +74,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit) => { }, [isMagicLinkEnabled]) React.useEffect1(() => { - if testLiveMode { + if testLiveMode->Belt.Option.getWithDefault(false) { setMode(_ => LiveButtonMode) } else { setMode(_ => TestButtonMode) diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res index d5b98a866..eb2f576ac 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res @@ -356,7 +356,7 @@ module Header = { @react.component let make = (~authType, ~setAuthType, ~email) => { let form = ReactFinalForm.useForm() - let {magicLink: isMagicLinkEnabled} = + let {magicLink: isMagicLinkEnabled, testLiveMode} = HyperswitchAtom.featureFlagAtom ->Recoil.useRecoilValueFromAtom ->LogicUtils.safeParse @@ -429,12 +429,15 @@ module Header = {

{cardHeaderText->React.string}

{switch authType { | LoginWithPassword | LoginWithEmail => - getHeaderLink( - ~prefix="New to Hyperswitch?", - ~authType=SignUP, - ~path="/register", - ~sufix="Sign up", - ) + !(testLiveMode->Belt.Option.getWithDefault(false)) + ? getHeaderLink( + ~prefix="New to Hyperswitch?", + ~authType=SignUP, + ~path="/register", + ~sufix="Sign up", + ) + : React.null + | SignUP => getHeaderLink( ~prefix="Already using Hyperswitch?",