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(refactor): refactor login components folder #6176

Merged
merged 1 commit into from
Dec 14, 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const BackArrowWrapper = styled.div<{ hideBackArrow?: boolean; marginTop?: strin
justify-content: ${(props) => (props.hideBackArrow ? 'flex-end' : 'space-between')};
margin-bottom: 24px;
align-items: center;
margin-top: ${(props) => (props.marginTop ? props.marginTop : 'auto')};
margin-top: ${(props) => props.marginTop || 'auto'};
`
const BackArrow = styled.div`
display: flex;
Expand All @@ -24,70 +24,76 @@ const EmailAndGuid = styled.div`
align-items: center;
`

const BackArrowHeader = (props: {
type Props = {
formValues: LoginFormType
handleBackArrowClick: () => void
hideGuid?: boolean
marginTop?: string
platform?: PlatformTypes
product?: ProductAuthOptions
}) => {
const isExchangeLogin = props.product === ProductAuthOptions.EXCHANGE
}

const BackArrowHeader = ({
formValues,
handleBackArrowClick,
hideGuid,
marginTop,
platform,
product
}: Props) => {
const isExchangeLogin = product === ProductAuthOptions.EXCHANGE
const email = isExchangeLogin
? props.formValues.exchangeEmail
: props.formValues.email || props.formValues.sofiLoginEmail
const guid = props.formValues?.guid
const firstPartGuid = guid && guid.slice(0, 4)
const lastPartGuid = guid && guid.slice(-4)
const hideBackArrow =
props.platform === PlatformTypes.ANDROID || props.platform === PlatformTypes.IOS
? formValues.exchangeEmail
: formValues.email || formValues.sofiLoginEmail
const guid = formValues?.guid
const firstPartGuid = guid?.slice(0, 4)
const lastPartGuid = guid?.slice(-4)
const hideBackArrow = platform === PlatformTypes.ANDROID || platform === PlatformTypes.IOS
return (
<>
<BackArrowWrapper marginTop={props.marginTop} hideBackArrow={hideBackArrow}>
{!hideBackArrow && (
<BackArrow onClick={props.handleBackArrowClick}>
<Icon
data-e2e='signupBack'
name='arrow-back'
size='24px'
color='blue600'
style={{ marginRight: '8px' }}
role='button'
/>
<BackArrowWrapper marginTop={marginTop} hideBackArrow={hideBackArrow}>
{!hideBackArrow && (
<BackArrow onClick={handleBackArrowClick}>
<Icon
data-e2e='signupBack'
name='arrow-back'
size='24px'
color='blue600'
style={{ marginRight: '8px' }}
role='button'
/>

<Text color='grey900' size='14px' weight={500} lineHeight='1.5'>
<FormattedMessage id='copy.back' defaultMessage='Back' />
</Text>
</BackArrow>
<Text color='grey900' size='14px' weight={500} lineHeight='1.5'>
<FormattedMessage id='copy.back' defaultMessage='Back' />
</Text>
</BackArrow>
)}
<EmailAndGuid>
{hideGuid || (email && isMobile()) || isExchangeLogin ? (
<Text
color='blue600'
size='12px'
weight={600}
lineHeight='1.5'
style={{ marginRight: '2px' }}
>
{email}
</Text>
) : (
<Text color='grey400' size='12px' weight={600} lineHeight='1.5'>
({firstPartGuid}...{lastPartGuid})
</Text>
)}
<EmailAndGuid>
{props.hideGuid || email || (email && isMobile()) || isExchangeLogin ? (
<Text
color='blue600'
size='12px'
weight={600}
lineHeight='1.5'
style={{ marginRight: '2px' }}
>
{email}
</Text>
) : (
<Text color='grey400' size='12px' weight={600} lineHeight='1.5'>
{formValues.step !== LoginSteps.CHECK_EMAIL &&
formValues.email &&
!hideGuid &&
!isMobile() &&
!isExchangeLogin && (
<Text size='12px' weight={500} color='grey400'>
({firstPartGuid}...{lastPartGuid})
</Text>
)}
{props.formValues.step !== LoginSteps.CHECK_EMAIL &&
props.formValues.email &&
!props.hideGuid &&
!isMobile() &&
!isExchangeLogin && (
<Text size='12px' weight={500} color='grey400'>
({firstPartGuid}...{lastPartGuid})
</Text>
)}
</EmailAndGuid>
</BackArrowWrapper>
</>
</EmailAndGuid>
</BackArrowWrapper>
)
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { connect, ConnectedProps } from 'react-redux'
import { useDispatch } from 'react-redux'
import { LinkContainer } from 'react-router-bootstrap'
import { bindActionCreators } from 'redux'

import { Link } from 'blockchain-info-components'
import { actions } from 'data'
import { trackEvent } from 'data/analytics/slice'
import { Analytics } from 'data/analytics/types'
import { PlatformTypes, ProductAuthOptions } from 'data/types'

const NeedHelpLink = ({ analyticsActions, origin, platform, product, unified }: Props) => (
<LinkContainer
to={product === ProductAuthOptions.WALLET || unified ? '/recover' : '/help-exchange'}
onClick={() => {
analyticsActions.trackEvent({
const NeedHelpLink = ({ origin, platform, product, unified }: Props) => {
const dispatch = useDispatch()

const onClick = () => {
dispatch(
trackEvent({
key: Analytics.LOGIN_FORGOT_PASSWORD_CLICKED,
properties: {
device_origin: platform,
Expand All @@ -22,26 +22,25 @@ const NeedHelpLink = ({ analyticsActions, origin, platform, product, unified }:
unified
}
})
}}
>
<Link size='13px' weight={600} data-e2e='loginForgotPassword'>
<FormattedMessage id='scenes.help.forgotpassword' defaultMessage='Forgot your password?' />
</Link>
</LinkContainer>
)
)
}

const mapDispatchToProps = (dispatch) => ({
analyticsActions: bindActionCreators(actions.analytics, dispatch)
})
const linkTo = product === ProductAuthOptions.WALLET || unified ? '/recover' : '/help-exchange'

const connector = connect(null, mapDispatchToProps)
return (
<LinkContainer to={linkTo} onClick={onClick}>
<Link size='13px' weight={600} data-e2e='loginForgotPassword'>
<FormattedMessage id='scenes.help.forgotpassword' defaultMessage='Forgot your password?' />
</Link>
</LinkContainer>
)
}

type OwnProps = {
type Props = {
origin: string
platform?: PlatformTypes
product: ProductAuthOptions
unified?: boolean
}
type Props = OwnProps & ConnectedProps<typeof connector>

export default connector(NeedHelpLink)
export default NeedHelpLink
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const Row = styled.div`
`}
`

const SignUpLink = (props) => {
const hideSignupLink =
props.platform === PlatformTypes.ANDROID || props.platform === PlatformTypes.IOS
return hideSignupLink ? null : (
const SignUpLink = ({ platform }: { platform?: PlatformTypes }) => {
if (platform === PlatformTypes.ANDROID || platform === PlatformTypes.IOS) return null

return (
<SubCard>
<LinkContainer data-e2e='signupLink' to='/signup'>
<Row>
Expand Down
Loading