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 1/5] 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?", From 10bc54c0b3309b972c3853427f2edd3e26483bee Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa <136090360+vsrivatsa-juspay@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:36:03 +0530 Subject: [PATCH 2/5] feat: demo fixes customer id and retrieve request by client secret (#29) Co-authored-by: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> --- .../HyperSwitch/SDKPayment/SDKPaymentTypes.res | 1 + .../HyperSwitch/SDKPayment/SDKPaymentUtils.res | 2 ++ .../HyperSwitch/SDKPayment/TestPayment.res | 1 + src/screens/HyperSwitch/SDKPayment/WebSDK.res | 15 +++++---------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res b/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res index 6ab6149af..546b37b09 100644 --- a/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res +++ b/src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res @@ -2,4 +2,5 @@ type paymentType = { amount: int, currency: string, profile_id: string, + customer_id: string, } diff --git a/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res b/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res index ef663a6c5..14184cbdc 100644 --- a/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res +++ b/src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res @@ -2,6 +2,7 @@ let initialValueForForm: string => SDKPaymentTypes.paymentType = profileId => { amount: 100, currency: "United States-USD", profile_id: profileId, + customer_id: "hyperswitch_sdk_demo_id", } let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values => { @@ -11,6 +12,7 @@ let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values = amount: dictOfValues->getInt("amount", 100), currency: dictOfValues->getString("currency", "United States-USD"), profile_id: dictOfValues->getString("profile_id", ""), + customer_id: dictOfValues->getString("customer_id", ""), } } diff --git a/src/screens/HyperSwitch/SDKPayment/TestPayment.res b/src/screens/HyperSwitch/SDKPayment/TestPayment.res index 6426605ed..b10d705ca 100644 --- a/src/screens/HyperSwitch/SDKPayment/TestPayment.res +++ b/src/screens/HyperSwitch/SDKPayment/TestPayment.res @@ -45,6 +45,7 @@ let make = ( ->Js.Json.number, ), ("profile_id", initialValues.profile_id->Js.Json.string), + ("customer_id", "hyperswitch_sdk_demo_id"->Js.Json.string), ])->Js.Json.object_ let response = await updateDetails(url, body, Post) let clientSecret = response->getDictFromJsonObject->getOptionString("client_secret") diff --git a/src/screens/HyperSwitch/SDKPayment/WebSDK.res b/src/screens/HyperSwitch/SDKPayment/WebSDK.res index bb2be9d4f..a9a0785c6 100644 --- a/src/screens/HyperSwitch/SDKPayment/WebSDK.res +++ b/src/screens/HyperSwitch/SDKPayment/WebSDK.res @@ -215,16 +215,11 @@ module CheckoutForm = { ->ignore } React.useEffect1(() => { - let id = Js.String2.split(clientSecret, "_secret_")[0]->Belt.Option.getWithDefault("") - switch Some(id) { - | None | Some("") => () - | Some(id) => - hyper.retrievePaymentIntent(id) - ->then(_ => { - resolve() - }) - ->ignore - } + hyper.retrievePaymentIntent(clientSecret) + ->then(_ => { + resolve() + }) + ->ignore None }, [hyper]) From 3f7d40beac8ad006c1a29e966a5d0c8f1bc5e953 Mon Sep 17 00:00:00 2001 From: Lokesh Jain <56452497+jainlokesh318@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:47:46 +0530 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20donot=20show=20stripe=20paypal=20Tes?= =?UTF-8?q?tCompletion=20on=20just=20connection=20of=20st=E2=80=A6=20(#41)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lokesh Jain Co-authored-by: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> --- config/FeatureFlag.json | 2 +- src/screens/HyperSwitch/HSwitchUtils.res | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json index d08069294..bf3795e0c 100644 --- a/config/FeatureFlag.json +++ b/config/FeatureFlag.json @@ -22,4 +22,4 @@ "mixpanel": false, "business_profile": false, "generate_report": false -} +} \ No newline at end of file diff --git a/src/screens/HyperSwitch/HSwitchUtils.res b/src/screens/HyperSwitch/HSwitchUtils.res index 509b29e30..cdeb685ff 100644 --- a/src/screens/HyperSwitch/HSwitchUtils.res +++ b/src/screens/HyperSwitch/HSwitchUtils.res @@ -480,7 +480,8 @@ module CardLoader = { let checkStripePlusPayPal = (enumDetails: QuickStartTypes.responseType) => { enumDetails.stripeConnected.processorID->Js.String2.length > 0 && - enumDetails.paypalConnected.processorID->Js.String2.length > 0 + enumDetails.paypalConnected.processorID->Js.String2.length > 0 && + enumDetails.sPTestPayment ? true : false } From e8ff5478637979141abda31a8ae6ed2f1db73e05 Mon Sep 17 00:00:00 2001 From: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:37:28 +0530 Subject: [PATCH 4/5] feat: Add forgot password feature flag (#40) --- config/FeatureFlag.json | 4 +- .../hyperswitch/FeatureFlagUtils.res | 8 ++-- .../HyperSwitch/Settings/HSwitchSettings.res | 2 + .../HSwitchLoginFlow/HyperSwitchAuth.res | 40 ++++++++++--------- .../HSwitchLoginFlow/HyperSwitchAuthForm.res | 4 +- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json index bf3795e0c..bbe5ac822 100644 --- a/config/FeatureFlag.json +++ b/config/FeatureFlag.json @@ -7,7 +7,6 @@ "stripe_plus_paypal": false, "woocommerce": false, "open_sdk": false, - "home_page": false, "switch_merchant": false, "audit_trail": false, "system_metrics": false, @@ -21,5 +20,6 @@ "verify_connector": false, "mixpanel": false, "business_profile": false, - "generate_report": false + "generate_report": false, + "forgot_password": false } \ No newline at end of file diff --git a/src/entryPoints/hyperswitch/FeatureFlagUtils.res b/src/entryPoints/hyperswitch/FeatureFlagUtils.res index 1236a653e..150c8cff9 100644 --- a/src/entryPoints/hyperswitch/FeatureFlagUtils.res +++ b/src/entryPoints/hyperswitch/FeatureFlagUtils.res @@ -1,4 +1,5 @@ type featureFlag = { + default: bool, productionAccess: bool, testLiveToggle: bool, magicLink: bool, @@ -6,7 +7,6 @@ type featureFlag = { stripePlusPayPal: bool, wooCommerce: bool, openSDK: bool, - homePage: bool, switchMerchant: bool, testLiveMode: option, auditTrail: bool, @@ -22,13 +22,14 @@ type featureFlag = { businessProfile: bool, mixPanel: bool, verifyConnector: bool, - default: bool, + forgetPassword: bool, } let featureFlagType = (featureFlags: Js.Json.t) => { open LogicUtils let dict = featureFlags->getDictFromJsonObject let typedFeatureFlag: featureFlag = { + default: dict->getBool("default", true), productionAccess: dict->getBool("production_access", false), testLiveToggle: dict->getBool("test_live_toggle", false), magicLink: dict->getBool("magic_link", false), @@ -36,7 +37,6 @@ let featureFlagType = (featureFlags: Js.Json.t) => { stripePlusPayPal: dict->getBool("stripe_plus_paypal", false), wooCommerce: dict->getBool("woocommerce", false), openSDK: dict->getBool("open_sdk", false), - homePage: dict->getBool("home_page", false), switchMerchant: dict->getBool("switch_merchant", false), testLiveMode: dict->getOptionBool("test_live_mode"), auditTrail: dict->getBool("audit_trail", false), @@ -52,7 +52,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => { businessProfile: dict->getBool("business_profile", false), mixPanel: dict->getBool("mixpanel", false), verifyConnector: dict->getBool("verify_connector", false), - default: dict->getBool("default", true), + forgetPassword: dict->getBool("forgot_password", false), } typedFeatureFlag } diff --git a/src/screens/HyperSwitch/Settings/HSwitchSettings.res b/src/screens/HyperSwitch/Settings/HSwitchSettings.res index c670f3a61..8788dd6f8 100644 --- a/src/screens/HyperSwitch/Settings/HSwitchSettings.res +++ b/src/screens/HyperSwitch/Settings/HSwitchSettings.res @@ -160,6 +160,8 @@ module PersonalSettings = { ->FeatureFlagUtils.featureFlagType let personalSettings = if featureFlagDetails.sampleData { [businessSettings, businessUnits, deleteSampleData] + } else if featureFlagDetails.businessProfile { + [businessSettings, businessUnits] } else { [businessSettings] } diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res index 04ecd6c63..b410f0949 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res @@ -15,7 +15,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, let showToast = ToastState.useShowToast() let updateDetails = useUpdateMethod(~showErrorToast=false, ()) let (email, setEmail) = React.useState(_ => "") - let {magicLink: isMagicLinkEnabled} = + let {magicLink: isMagicLinkEnabled, forgetPassword} = HyperswitchAtom.featureFlagAtom ->Recoil.useRecoilValueFromAtom ->LogicUtils.safeParse @@ -139,9 +139,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, } } - let onSubmit = (values, _) => { - open Promise - + let onSubmit = async (values, _) => { let valuesDict = values->getDictFromJsonObject let email = valuesDict->getString("email", "") setEmail(_ => email) @@ -151,39 +149,44 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, | (true, SignUP) | (true, LoginWithEmail) => { let body = getEmailBody(email, ~country, ()) - getUserWithEmail(body) + getUserWithEmail(body)->ignore } - | (true, ForgetPassword) => - let body = email->getEmailBody() - - setForgetPassword(body) | (true, ResendVerifyEmail) => let body = email->getEmailBody() - resendVerifyEmail(body) + resendVerifyEmail(body)->ignore | (false, SignUP) => { let password = getString(valuesDict, "password", "") let body = getEmailPasswordBody(email, password, country) - getUserWithEmailPassword(body, email) + getUserWithEmailPassword(body, email)->ignore } | (_, LoginWithPassword) => { let password = getString(valuesDict, "password", "") let body = getEmailPasswordBody(email, password, country) - getUserWithEmailPassword(body, email) + getUserWithEmailPassword(body, email)->ignore } | (_, ResetPassword) => { let queryDict = url.search->getDictFromUrlSearchParams let password_reset_token = queryDict->Js.Dict.get("token")->Belt.Option.getWithDefault("") let password = getString(valuesDict, "create_password", "") let body = getResetpasswordBodyJson(password, password_reset_token) - setResetPassword(body) + setResetPassword(body)->ignore } - | _ => Js.Nullable.null->resolve + | _ => () + } + + switch (forgetPassword, authType) { + | (true, ForgetPassword) => + let body = email->getEmailBody() + + setForgetPassword(body)->ignore + | _ => () } + Js.Nullable.null } let resendEmail = () => { @@ -234,14 +237,13 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, onSubmit={handleSubmit} className={`flex flex-col justify-evenly gap-5 h-full w-full !overflow-visible text-grey-600`}> {switch authType { - | LoginWithPassword => + | LoginWithPassword => | LoginWithEmail - | ForgetPassword + | ForgetPassword => + forgetPassword ? : React.null | ResendVerifyEmail | SignUP => - isMagicLinkEnabled - ? - : + isMagicLinkEnabled ? : | ResetPassword => | MagicLinkEmailSent | ForgetPasswordEmailSent | ResendVerifyEmailSent => diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res index ee11b82ac..c4e0885ef 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res @@ -3,12 +3,12 @@ let fieldWrapperClass = "w-full flex flex-col" let labelClass = "!text-black !font-medium" module EmailPasswordForm = { @react.component - let make = (~setAuthType, ~isMagicLinkEnabled) => { + let make = (~setAuthType, ~forgetPassword) => {
- +