From 7819d1007bab8449121af5c6c7737a6c08829079 Mon Sep 17 00:00:00 2001 From: Jeeva Ramachandran Date: Thu, 30 Nov 2023 16:58:10 +0530 Subject: [PATCH] fix: add forgot password feature flag --- config/FeatureFlag.json | 6 +-- .../hyperswitch/FeatureFlagUtils.res | 8 ++-- .../HyperSwitch/Settings/HSwitchSettings.res | 2 + .../HSwitchLoginFlow/HyperSwitchAuth.res | 40 ++++++++++--------- .../HSwitchLoginFlow/HyperSwitchAuthForm.res | 4 +- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json index d08069294..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) => {
- +