Skip to content

Commit

Permalink
Merge branch 'main' into feat/SDK-UI-Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevaRamu0104 authored Nov 28, 2023
2 parents 30199de + 713eeb5 commit 6b944e2
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 89 deletions.
33 changes: 17 additions & 16 deletions public/hyperswitch/assets/Dark/hyperswitchLogoIconWithText.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/hyperswitch/assets/key-password.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/screens/HyperSwitch/HSwitchUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ module BackgroundImageWrapper = {
<UIUtils.RenderIf condition={children->Belt.Option.isSome}>
<div
className={`bg-no-repeat bg-center bg-hyperswitch_dark_bg bg-fixed ${customPageCss} ${heightWidthCss}`}
style={ReactDOMStyle.make(~backgroundImage=`url(${backgroundImageUrl})`, ())}>
style={ReactDOMStyle.make(
~backgroundImage=`url(${backgroundImageUrl})`,
~backgroundSize=`cover`,
(),
)}>
{children->Belt.Option.getWithDefault(React.null)}
</div>
</UIUtils.RenderIf>
Expand Down
37 changes: 8 additions & 29 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,14 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType,
}
}

let getUserWithEmail = async (body, email) => {
let getUserWithEmail = async body => {
try {
let url = getURL(~entityName=USERS, ~userType=#SIGNIN, ~methodType=Post, ())
let res = await updateDetails(url, body, Post)

let valuesDict = res->getDictFromJsonObject
let token = valuesDict->LogicUtils.getString("token", "")
let magicLinkSent = valuesDict->LogicUtils.getBool("is_email_sent", false)

// home
if !(token->HSwitchUtils.isEmptyString) {
let token = parseResponseJson(~json=res, ~email)
setAuthStatus(LoggedIn(HyperSwitchAuthTypes.getDummyAuthInfoForToken(token)))
} else if magicLinkSent {
// magic link
if magicLinkSent {
setAuthType(_ => MagicLinkEmailSent)
} else {
showToast(~message="Failed to send an email, Try again", ~toastType=ToastError, ())
Expand All @@ -64,11 +57,13 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType,
try {
let url = getURL(~entityName=USERS, ~userType=#SIGNIN, ~methodType=Post, ())
let res = await updateDetails(url, body, Post)

let token = parseResponseJson(~json=res, ~email)

// home
if !(token->HSwitchUtils.isEmptyString) {
setAuthStatus(LoggedIn(HyperSwitchAuthTypes.getDummyAuthInfoForToken(token)))
} else {
showToast(~message="Failed to sign in, Try again", ~toastType=ToastError, ())
setAuthStatus(LoggedOut)
}
} catch {
Expand Down Expand Up @@ -156,7 +151,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType,
| (true, SignUP) | (true, LoginWithEmail) => {
let body = getEmailBody(email, ~country, ())

getUserWithEmail(body, email)
getUserWithEmail(body)
}
| (true, ForgetPassword) =>
let body = email->getEmailBody()
Expand Down Expand Up @@ -194,7 +189,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType,
let resendEmail = () => {
let body = email->getEmailBody()
switch authType {
| MagicLinkEmailSent => getUserWithEmail(body, email)->ignore
| MagicLinkEmailSent => getUserWithEmail(body)->ignore
| ForgetPasswordEmailSent => setForgetPassword(body)->ignore
| ResendVerifyEmailSent => resendVerifyEmail(body)->ignore
| _ => ()
Expand Down Expand Up @@ -234,7 +229,6 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType,
onSubmit
render={({handleSubmit}) => {
<>
<InfoWithBack authType setAuthType />
<Header authType setAuthType email />
<form
onSubmit={handleSubmit}
Expand Down Expand Up @@ -271,22 +265,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType,
| _ => React.null
}}
</div>
<div className="text-center text-sm">
{"By continuing, you agree to our "->React.string}
<a
className="font-medium text-grey-900"
href="https://hyperswitch.io/terms-of-services"
target="__blank">
{"Terms of Service "->React.string}
</a>
{" & "->React.string}
<a
className="font-medium text-grey-900"
href="https://hyperswitch.io/privacyPolicy"
target="__blank">
{"Privacy Policy"->React.string}
</a>
</div>
{note(authType, setAuthType, isMagicLinkEnabled)}
</form>
</>
}}
Expand Down
2 changes: 1 addition & 1 deletion src/screens/login/HSwitchLoginFlow/HyperSwitchAuthForm.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let labelClass = "!text-black !font-medium"
module EmailPasswordForm = {
@react.component
let make = (~setAuthType, ~isMagicLinkEnabled) => {
<div className="flex flex-col gap-3 md:gap-8">
<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 />
Expand Down
19 changes: 10 additions & 9 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module AuthPage = {
open HyperSwitchAuth
@react.component
let make = (~authType, ~setAuthType, ~setAuthStatus, ~mode, ~setMode) => {
let {testLiveToggle, magicLink: isMagicLinkEnabled} =
let {testLiveToggle} =
HyperswitchAtom.featureFlagAtom
->Recoil.useRecoilValueFromAtom
->LogicUtils.safeParse
Expand All @@ -14,21 +14,22 @@ module AuthPage = {
<div
className="h-full flex flex-col items-center justify-between overflow-scoll text-grey-0 w-full mobile:w-30-rem">
<div className="flex flex-col items-center gap-6 flex-1 mt-4 mobile:my-20">
<Div layoutId="logo">
<HyperSwitchLogo logoHeight="h-6" theme={Dark} />
</Div>
<UIUtils.RenderIf condition={testLiveToggle}>
<ToggleLiveTestMode authType mode setMode setAuthType />
</UIUtils.RenderIf>
<Div
layoutId="form"
className="bg-white text-black mobile:border p-9 rounded-lg flex flex-col justify-between gap-5 mobile:gap-8">
<HyperSwitchAuth setAuthStatus authType setAuthType />
<Div layoutId="form" className="bg-white w-full text-black mobile:border rounded-lg">
<div className="px-7 py-6">
<HyperSwitchLogo logoHeight="h-8" theme={Dark} />
</div>
<div className="border-b w-full" />
<div className="p-7">
<HyperSwitchAuth setAuthStatus authType setAuthType />
</div>
</Div>
<Div
layoutId="footer-links"
className="justify-center text-sm mobile:text-base flex flex-col mobile:flex-row mobile:gap-3 items-center w-full max-w-xl text-center">
{note(authType, setAuthType, isMagicLinkEnabled)}
<TermsAndCondition />
</Div>
</div>
<PageFooterSection />
Expand Down
Loading

0 comments on commit 6b944e2

Please sign in to comment.