Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bugfix/sdk-refresh-issue-fix
Browse files Browse the repository at this point in the history
JeevaRamu0104 authored Dec 1, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents ad07351 + 74e6908 commit e3608c3
Showing 6 changed files with 43 additions and 35 deletions.
4 changes: 2 additions & 2 deletions config/FeatureFlag.json
Original file line number Diff line number Diff line change
@@ -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
}
8 changes: 4 additions & 4 deletions src/entryPoints/hyperswitch/FeatureFlagUtils.res
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
type featureFlag = {
default: bool,
productionAccess: bool,
testLiveToggle: bool,
magicLink: bool,
quickStart: bool,
stripePlusPayPal: bool,
wooCommerce: bool,
openSDK: bool,
homePage: bool,
switchMerchant: bool,
testLiveMode: option<bool>,
auditTrail: bool,
@@ -22,21 +22,21 @@ 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),
quickStart: dict->getBool("quick_start", false),
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
}
2 changes: 2 additions & 0 deletions src/screens/HyperSwitch/Settings/HSwitchSettings.res
Original file line number Diff line number Diff line change
@@ -160,6 +160,8 @@ module PersonalSettings = {
->FeatureFlagUtils.featureFlagType
let personalSettings = if featureFlagDetails.sampleData {
[businessSettings, businessUnits, deleteSampleData]
} else if featureFlagDetails.businessProfile {
[businessSettings, businessUnits]
} else {
[businessSettings]
}
40 changes: 21 additions & 19 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res
Original file line number Diff line number Diff line change
@@ -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 => <EmailPasswordForm setAuthType isMagicLinkEnabled />
| LoginWithPassword => <EmailPasswordForm setAuthType forgetPassword />
| LoginWithEmail
| ForgetPassword
| ForgetPassword =>
forgetPassword ? <EmailForm /> : React.null
| ResendVerifyEmail
| SignUP =>
isMagicLinkEnabled
? <EmailForm />
: <EmailPasswordForm setAuthType isMagicLinkEnabled />
isMagicLinkEnabled ? <EmailForm /> : <EmailPasswordForm setAuthType forgetPassword />
| ResetPassword => <ResetPasswordForm />
| MagicLinkEmailSent | ForgetPasswordEmailSent | ResendVerifyEmailSent =>
<ResendBtn callBackFun={resendEmail} />
4 changes: 2 additions & 2 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res
Original file line number Diff line number Diff line change
@@ -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) => {
<div className="flex flex-col gap-3">
<FormRenderer.FieldRenderer field=emailField labelClass fieldWrapperClass />
<div className="flex flex-col gap-3">
<FormRenderer.FieldRenderer field=passwordField labelClass fieldWrapperClass />
<UIUtils.RenderIf condition={isMagicLinkEnabled}>
<UIUtils.RenderIf condition={forgetPassword}>
<label
className={`not-italic text-[12px] font-semibold font-ibm-plex text-blue-800 cursor-pointer cursor-pointer`}
onClick={_ => setAuthType(_ => HyperSwitchAuthTypes.ForgetPassword)}>
20 changes: 12 additions & 8 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res
Original file line number Diff line number Diff line change
@@ -429,14 +429,18 @@ module Header = {
<h1 className="font-semibold text-xl md:text-2xl"> {cardHeaderText->React.string} </h1>
{switch authType {
| LoginWithPassword | LoginWithEmail =>
!(testLiveMode->Belt.Option.getWithDefault(false))
? getHeaderLink(
~prefix="New to Hyperswitch?",
~authType=SignUP,
~path="/register",
~sufix="Sign up",
)
: React.null
switch testLiveMode {
| Some(val) =>
!val
? getHeaderLink(
~prefix="New to Hyperswitch?",
~authType=SignUP,
~path="/register",
~sufix="Sign up",
)
: React.null
| _ => React.null
}

| SignUP =>
getHeaderLink(

0 comments on commit e3608c3

Please sign in to comment.