Skip to content

Commit

Permalink
chore(refactor): refactor exchane login pages (#6177)
Browse files Browse the repository at this point in the history
  • Loading branch information
mperdomo-bc authored Dec 14, 2023
1 parent 5b84609 commit 0cf45dd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,7 @@ const LoginWrapper = styled(Wrapper)`
`

const EnterEmail = (props: Props) => {
const {
busy,
cache,
formValues,
invalid,
magicLinkData,
productAuthMetadata,
submitting,
walletTabClicked
} = props
const { busy, formValues, invalid, magicLinkData, submitting, walletTabClicked } = props

return (
<LoginWrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect } from 'react'
import { FormattedMessage } from 'react-intl'
import { useDispatch } from 'react-redux'
import { Field } from 'redux-form'
import styled from 'styled-components'

Expand All @@ -10,6 +11,7 @@ import FormItem from 'components/Form/FormItem'
import FormLabel from 'components/Form/FormLabel'
import PasswordBox from 'components/Form/PasswordBox'
import { Wrapper } from 'components/Public'
import { trackEvent } from 'data/analytics/slice'
import { Analytics, ExchangeErrorCodes, ProductAuthOptions } from 'data/types'
import { required } from 'services/forms'
import { media } from 'services/styles'
Expand All @@ -30,7 +32,6 @@ const LoginWrapper = styled(Wrapper)`

const EnterPasswordExchange = (props: Props) => {
const {
analyticsActions,
cache,
exchangeError,
formValues,
Expand All @@ -42,18 +43,22 @@ const EnterPasswordExchange = (props: Props) => {
walletTabClicked
} = props

const dispatch = useDispatch()

useEffect(() => {
analyticsActions.trackEvent({
key: Analytics.LOGIN_PASSWORD_INPUT_PAGE_ENTERED,
properties: {
device_origin: productAuthMetadata?.product || 'WEB',
originalTimestamp: new Date().toISOString()
}
})
dispatch(
trackEvent({
key: Analytics.LOGIN_PASSWORD_INPUT_PAGE_ENTERED,
properties: {
device_origin: productAuthMetadata?.product || 'WEB',
originalTimestamp: new Date().toISOString()
}
})
)
}, [])

const passwordError = exchangeError && exchangeError === ExchangeErrorCodes.INVALID_CREDENTIALS
const sanctionedRegionError = exchangeError && exchangeError === ExchangeErrorCodes.NOT_ACCEPTABLE
const passwordError = exchangeError === ExchangeErrorCodes.INVALID_CREDENTIALS
const sanctionedRegionError = exchangeError === ExchangeErrorCodes.NOT_ACCEPTABLE

return (
<LoginWrapper>
Expand All @@ -65,7 +70,7 @@ const EnterPasswordExchange = (props: Props) => {
/>
<WrapperWithPadding>
<BackArrowHeader
{...props}
formValues={formValues}
handleBackArrowClick={handleBackArrowClickExchange}
hideGuid
marginTop='28px'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect } from 'react'
import { FormattedMessage } from 'react-intl'
import { Field } from 'redux-form'
import { push } from 'connected-react-router'
import { clearFields, Field } from 'redux-form'
import styled from 'styled-components'

import { HeartbeatLoader, Icon, Text } from 'blockchain-info-components'
Expand Down Expand Up @@ -41,10 +42,6 @@ const BackArrow = styled.div`
`

const InstitutionalPortal = (props: Props) => {
useEffect(() => {
props.formActions.clearFields(LOGIN_FORM, false, false, 'exchangeEmail')
}, [])

const {
busy,
exchangeError,
Expand All @@ -53,14 +50,18 @@ const InstitutionalPortal = (props: Props) => {
invalid,
magicLinkData,
productAuthMetadata,
routerActions,
submitting
} = props
const passwordError = exchangeError && exchangeError === ExchangeErrorCodes.INVALID_CREDENTIALS

const passwordError = exchangeError === ExchangeErrorCodes.INVALID_CREDENTIALS

const backArrowClick = () => {
handleBackArrowClickExchange()
routerActions.push('/login?product=exchange')
push('/login?product=exchange')
}
useEffect(() => {
clearFields(LOGIN_FORM, false, false, 'exchangeEmail')
}, [])
return (
<LoginWrapper>
<WrapperWithPadding>
Expand Down Expand Up @@ -113,7 +114,7 @@ const InstitutionalPortal = (props: Props) => {
id='scenes.login.exchange.wrong_password'
defaultMessage='Login failed - wrong password.'
/>
{/* some sort of prompts to reset password? */}
{/* some sort of prompts to reset password? */}
</FormError>
)}
</FormItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect } from 'react'
import { FormattedMessage } from 'react-intl'
import { useDispatch } from 'react-redux'
import { Field } from 'redux-form'
import styled from 'styled-components'

Expand All @@ -10,6 +11,7 @@ import FormItem from 'components/Form/FormItem'
import FormLabel from 'components/Form/FormLabel'
import TextBox from 'components/Form/TextBox'
import { Wrapper } from 'components/Public'
import { trackEvent } from 'data/analytics/slice'
import { ProductAuthOptions } from 'data/auth/types'
import { Analytics, ExchangeErrorCodes } from 'data/types'
import { required } from 'services/forms'
Expand All @@ -31,7 +33,6 @@ const LoginWrapper = styled(Wrapper)`
`
const TwoFAExchange = (props: Props) => {
const {
analyticsActions,
authType,
busy,
cache,
Expand All @@ -43,25 +44,29 @@ const TwoFAExchange = (props: Props) => {
productAuthMetadata,
submitting
} = props
const twoFactorError = exchangeError && exchangeError === ExchangeErrorCodes.WRONG_2FA
const twoFactorError = exchangeError === ExchangeErrorCodes.WRONG_2FA

const dispatch = useDispatch()

useEffect(() => {
const twoFAType = getTwoFaType(authType)
analyticsActions.trackEvent({
key: Analytics.LOGIN_2FA_PAGE_VIEWED,
properties: {
'2fa_type': twoFAType,
device_origin: productAuthMetadata?.product || 'WEB',
originalTimestamp: new Date().toISOString()
}
})
dispatch(
trackEvent({
key: Analytics.LOGIN_2FA_PAGE_VIEWED,
properties: {
'2fa_type': twoFAType,
device_origin: productAuthMetadata?.product || 'WEB',
originalTimestamp: new Date().toISOString()
}
})
)
}, [])

return (
<LoginWrapper>
<WrapperWithPadding>
<BackArrowHeader
{...props}
formValues={formValues}
handleBackArrowClick={handleBackArrowClickExchange}
hideGuid
platform={magicLinkData?.platform_type}
Expand Down

0 comments on commit 0cf45dd

Please sign in to comment.