Skip to content

Commit

Permalink
Merge branch 'main' into dead-code-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Dec 1, 2023
2 parents 7fecb28 + 74e6908 commit a82019d
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 47 deletions.
6 changes: 3 additions & 3 deletions config/FeatureFlag.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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),
Expand All @@ -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
}
3 changes: 2 additions & 1 deletion src/screens/HyperSwitch/HSwitchUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ type paymentType = {
amount: int,
currency: string,
profile_id: string,
customer_id: string,
}
2 changes: 2 additions & 0 deletions src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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", ""),
}
}

Expand Down
1 change: 1 addition & 0 deletions src/screens/HyperSwitch/SDKPayment/TestPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 5 additions & 10 deletions src/screens/HyperSwitch/SDKPayment/WebSDK.res
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 2 additions & 0 deletions src/screens/HyperSwitch/Settings/HSwitchSettings.res
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ module PersonalSettings = {
->FeatureFlagUtils.featureFlagType
let personalSettings = if featureFlagDetails.sampleData {
[businessSettings, businessUnits, deleteSampleData]
} else if featureFlagDetails.businessProfile {
[businessSettings, businessUnits]
} else {
[businessSettings]
}
Expand Down
40 changes: 21 additions & 19 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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 = () => {
Expand Down Expand Up @@ -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} />
Expand Down
4 changes: 2 additions & 2 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)}>
Expand Down
20 changes: 12 additions & 8 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,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(
Expand Down

0 comments on commit a82019d

Please sign in to comment.