Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/signin signup changes #21

Merged
merged 8 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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