Skip to content

Commit 919276b

Browse files
committed
chore(login): collocate states
1 parent 1a0ab1b commit 919276b

File tree

20 files changed

+116
-193
lines changed

20 files changed

+116
-193
lines changed

packages/blockchain-wallet-v4-frontend/src/data/auth/selectors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function getMobileLoginStarted(state: RootState): AuthStateType['mobileLo
4646
return state.auth.mobileLoginStarted
4747
}
4848

49-
export function getMagicLinkData(state: RootState): AuthStateType['magicLinkData'] {
49+
export function getMagicLinkData(state: RootState) {
5050
return state.auth.magicLinkData
5151
}
5252

packages/blockchain-wallet-v4-frontend/src/scenes/Login/Exchange/EnterEmail/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ const LoginWrapper = styled(Wrapper)`
2626
`
2727

2828
const EnterEmail = (props: Props) => {
29-
const { busy, formValues, invalid, magicLinkData, submitting, walletTabClicked } = props
29+
const { busy, formValues, invalid, isMobilePlatform, submitting, walletTabClicked } = props
3030

3131
return (
3232
<LoginWrapper>
3333
<ProductTabMenu
3434
active={ProductAuthOptions.EXCHANGE}
3535
onWalletTabClick={walletTabClicked}
36-
platform={magicLinkData?.platform_type}
36+
isMobilePlatform={isMobilePlatform}
3737
product={ProductAuthOptions.EXCHANGE}
3838
/>
3939
<WrapperWithPadding>
@@ -74,7 +74,7 @@ const EnterEmail = (props: Props) => {
7474
</ActionButton>
7575
</LinkRow>
7676
</WrapperWithPadding>
77-
<SignupLink platform={magicLinkData?.platform_type} />
77+
{isMobilePlatform && <SignupLink />}
7878
</LoginWrapper>
7979
)
8080
}

packages/blockchain-wallet-v4-frontend/src/scenes/Login/Exchange/EnterPassword/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ const LoginWrapper = styled(Wrapper)`
3232

3333
const EnterPasswordExchange = (props: Props) => {
3434
const {
35-
cache,
3635
exchangeError,
3736
formValues,
3837
handleBackArrowClickExchange,
3938
invalid,
40-
magicLinkData,
39+
isMobilePlatform,
4140
productAuthMetadata,
4241
submitting,
4342
walletTabClicked
@@ -65,7 +64,7 @@ const EnterPasswordExchange = (props: Props) => {
6564
<ProductTabMenu
6665
active={ProductAuthOptions.EXCHANGE}
6766
onWalletTabClick={walletTabClicked}
68-
platform={magicLinkData?.platform_type}
67+
isMobilePlatform={isMobilePlatform}
6968
product={ProductAuthOptions.EXCHANGE}
7069
/>
7170
<WrapperWithPadding>
@@ -74,7 +73,7 @@ const EnterPasswordExchange = (props: Props) => {
7473
handleBackArrowClick={handleBackArrowClickExchange}
7574
hideGuid
7675
marginTop='28px'
77-
platform={magicLinkData?.platform_type}
76+
hideBackArrow={isMobilePlatform}
7877
product={ProductAuthOptions.EXCHANGE}
7978
/>
8079
<FormGroup>
@@ -131,11 +130,10 @@ const EnterPasswordExchange = (props: Props) => {
131130
origin='PASSWORD'
132131
platform={productAuthMetadata.platform}
133132
product={ProductAuthOptions.EXCHANGE}
134-
unified={cache.unifiedAccount}
135133
/>
136134
</CenteredColumn>
137135
</WrapperWithPadding>
138-
<SignupLink platform={magicLinkData?.platform_type} />
136+
{isMobilePlatform && <SignupLink />}
139137
</LoginWrapper>
140138
)
141139
}

packages/blockchain-wallet-v4-frontend/src/scenes/Login/Exchange/Institutional/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const InstitutionalPortal = (props: Props) => {
4848
formValues,
4949
handleBackArrowClickExchange,
5050
invalid,
51-
magicLinkData,
51+
isMobilePlatform,
5252
productAuthMetadata,
5353
submitting
5454
} = props
@@ -144,7 +144,7 @@ const InstitutionalPortal = (props: Props) => {
144144
/>
145145
</LinkRow>
146146
</WrapperWithPadding>
147-
<SignupLink platform={magicLinkData?.platform_type} />
147+
{isMobilePlatform && <SignupLink />}
148148
</LoginWrapper>
149149
)
150150
}

packages/blockchain-wallet-v4-frontend/src/scenes/Login/Exchange/TwoFA/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@ const LoginWrapper = styled(Wrapper)`
3535
const TwoFAExchange = (props: Props) => {
3636
const {
3737
busy,
38-
cache,
3938
exchangeError,
4039
formValues,
4140
handleBackArrowClickExchange,
4241
invalid,
43-
magicLinkData,
42+
isMobilePlatform,
4443
productAuthMetadata,
4544
submitting
4645
} = props
@@ -71,7 +70,7 @@ const TwoFAExchange = (props: Props) => {
7170
formValues={formValues}
7271
handleBackArrowClick={handleBackArrowClickExchange}
7372
hideGuid
74-
platform={magicLinkData?.platform_type}
73+
hideBackArrow={isMobilePlatform}
7574
/>
7675
<FormGroup>
7776
<FormItem>
@@ -129,11 +128,10 @@ const TwoFAExchange = (props: Props) => {
129128
origin='2FA'
130129
platform={productAuthMetadata.platform}
131130
product={ProductAuthOptions.EXCHANGE}
132-
unified={cache.unifiedAccount}
133131
/>
134132
</LinkRow>
135133
</WrapperWithPadding>
136-
<SignupLink platform={magicLinkData?.platform_type} />
134+
{isMobilePlatform && <SignupLink />}
137135
</LoginWrapper>
138136
)
139137
}

packages/blockchain-wallet-v4-frontend/src/scenes/Login/Sofi/ContinueOnMobile/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import React from 'react'
22
import { FormattedMessage } from 'react-intl'
3-
import { useDispatch } from 'react-redux'
43
import styled from 'styled-components'
54

65
import { Badge, Button, Image, Text } from 'blockchain-info-components'
76
import { Wrapper } from 'components/Public'
8-
import { actions } from 'data'
9-
import { isBrowserAndroid, isBrowserIOS } from 'services/browser'
107
import { isMobile, media } from 'services/styles'
118

12-
import { Props } from '../..'
139
import { CircleBackground } from '../../model'
10+
import { useDispatch } from 'react-redux'
11+
import { push } from 'connected-react-router'
1412

1513
const ContentWrapper = styled.div`
1614
display: flex;
@@ -37,12 +35,12 @@ const AppButtons = styled.footer`
3735
`};
3836
`
3937

40-
const ContinueOnMobile = (props: Props) => {
38+
const ContinueOnMobile = () => {
4139
const dispatch = useDispatch()
4240
// Add check here to make sure that there is wallet data
4341
// route should navigate to login if there's no wallet data
4442
const sofiWalletRedirect = () => {
45-
dispatch(actions.router.push('/home'))
43+
dispatch(push('/home'))
4644
}
4745

4846
const APP_URL = 'https://blockchainwallet.page.link/dashboard'

packages/blockchain-wallet-v4-frontend/src/scenes/Login/Sofi/Email/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { media } from 'services/styles'
1717

1818
import { Props } from '../..'
1919
import { ActionButton, LinkRow, LoginFormLabel, SoFiWrapperWithPadding } from '../../model'
20+
import { push } from 'connected-react-router'
2021

2122
const LoginWrapper = styled(Wrapper)`
2223
display: flex;
@@ -43,22 +44,22 @@ const HelperText = styled(Text)`
4344
`
4445

4546
const Email = (props: Props) => {
46-
const { busy, formValues, invalid, routerActions, submitting } = props
47+
const { busy, formValues, invalid, submitting } = props
4748

4849
const { sofiJwtPayload } = useSelector((state: RootState) => state.profile.sofiData).getOrElse(
4950
{}
5051
) as SofiMigrationStatusResponseType
5152

5253
useEffect(() => {
5354
if (!sofiJwtPayload) {
54-
routerActions.push('/sofi-error')
55+
push('/sofi-error')
5556
}
5657
}, [])
5758

5859
return (
5960
<LoginWrapper>
6061
<SoFiWrapperWithPadding>
61-
<BackArrow onClick={() => routerActions.push('/sofi')}>
62+
<BackArrow onClick={() => push('/sofi')}>
6263
<Icon
6364
data-e2e='signupBack'
6465
name='arrow-back'

packages/blockchain-wallet-v4-frontend/src/scenes/Login/Sofi/Success/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ import { actions } from 'data'
99
import { isBrowserAndroid, isBrowserIOS } from 'services/browser'
1010
import { isMobile } from 'services/styles'
1111

12-
import { Props } from '../..'
13-
1412
const ContentWrapper = styled.div`
1513
display: flex;
1614
text-align: center;
1715
align-items: center;
1816
flex-direction: column;
1917
`
2018

21-
const SofiSuccess = (props: Props) => {
19+
const SofiSuccess = () => {
2220
const dispatch = useDispatch()
2321
// Add check here to make sure that there is wallet data
2422
// route should navigate to login if there's no wallet data

packages/blockchain-wallet-v4-frontend/src/scenes/Login/Sofi/VerifySSN/index.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react'
1+
import React from 'react'
22
import { FormattedMessage } from 'react-intl'
33
import { useDispatch } from 'react-redux'
44
import { Field } from 'redux-form'
@@ -11,17 +11,10 @@ import TextBox from 'components/Form/TextBox'
1111
import { Wrapper } from 'components/Public'
1212
import { actions } from 'data'
1313
import { Analytics } from 'data/types'
14-
import { removeWhitespace } from 'services/forms/normalizers'
1514
import { media } from 'services/styles'
1615

1716
import { Props } from '../..'
18-
import {
19-
ActionButton,
20-
GuidError,
21-
LinkRow,
22-
LoginFormLabel,
23-
SoFiWrapperWithPadding
24-
} from '../../model'
17+
import { ActionButton, LinkRow, LoginFormLabel, SoFiWrapperWithPadding } from '../../model'
2518

2619
const LoginWrapper = styled(Wrapper)`
2720
display: flex;
@@ -38,7 +31,7 @@ const FormBody = styled.div`
3831
`
3932

4033
const SofiVerifyID = (props: Props) => {
41-
const { busy, formActions, formValues, invalid, submitting } = props
34+
const { busy, formValues, invalid, submitting } = props
4235

4336
const dispatch = useDispatch()
4437

packages/blockchain-wallet-v4-frontend/src/scenes/Login/VerifyMagicLink/template.success.tsx

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
import React from 'react'
22
import { FormattedMessage } from 'react-intl'
3+
import { useDispatch } from 'react-redux'
34
import styled from 'styled-components'
45

56
import { Banner, Button, Icon, Image, Text } from 'blockchain-info-components'
6-
import { Wrapper } from 'components/Public'
7+
import { actions } from 'data'
78
import { media } from 'services/styles'
89

9-
import { Props } from '..'
1010
import { LoginWrapper } from '../model'
1111

12-
const InfoWrapper = styled.div`
13-
width: 100%;
14-
text-align: left;
15-
${media.mobile`
16-
text-align: center;`}
17-
`
1812
const DeviceInfoWrapper = styled.div`
1913
margin-top: 20px;
2014
`
@@ -86,25 +80,28 @@ const SuccessWrapper = styled.div`
8680
flex-direction: column;
8781
`
8882

89-
const Success = (props) => {
90-
const { approver, requester } = props
91-
return props.deviceAuthorized ? (
92-
<LoginWrapper>
93-
<SuccessWrapper>
94-
<Icon color='success' name='checkmark-circle-filled' size='40px' />
95-
<Text size='20px' weight={600} color='black' style={{ marginTop: '8px' }}>
96-
<FormattedMessage id='scenes.login.device_verified' defaultMessage='Device verified!' />
97-
</Text>
83+
const Success = ({ approver, deviceAuthorized, requester }) => {
84+
const dispatch = useDispatch()
85+
const authorizeDevice = (state: boolean) => dispatch(actions.auth.authorizeVerifyDevice(state))
9886

99-
<Text color='grey900' style={{ marginTop: '8px' }} size='16px' weight={500}>
100-
<FormattedMessage
101-
id='scenes.login.device_verified.copy'
102-
defaultMessage='You can safely close this tab or page. Go back to the other Blockchain.com tab or page to continue.'
103-
/>
104-
</Text>
105-
</SuccessWrapper>
106-
</LoginWrapper>
107-
) : (
87+
if (deviceAuthorized) {
88+
return (
89+
<LoginWrapper>
90+
<SuccessWrapper>
91+
<Icon color='success' name='checkmark-circle-filled' size='40px' />
92+
93+
<Text color='grey900' style={{ marginTop: '8px' }} size='16px' weight={500}>
94+
<FormattedMessage
95+
id='scenes.login.device_verified.copy'
96+
defaultMessage='You can safely close this tab or page. Go back to the other Blockchain.com tab or page to continue.'
97+
/>
98+
</Text>
99+
</SuccessWrapper>
100+
</LoginWrapper>
101+
)
102+
}
103+
104+
return (
108105
<LoginWrapper>
109106
<FormBody>
110107
<Image name='blockchain-icon' width='40px' height='40px' />
@@ -232,7 +229,7 @@ const Success = (props) => {
232229
<ApproveRejectButtons
233230
data-e2e='approveLogin'
234231
nature='warning'
235-
onClick={() => props.authActions.authorizeVerifyDevice(true)}
232+
onClick={() => authorizeDevice(true)}
236233
>
237234
<FormattedMessage id='modals.mobilenumberverify.verify' defaultMessage='Verify' />
238235
</ApproveRejectButtons>
@@ -242,7 +239,7 @@ const Success = (props) => {
242239
<ApproveRejectButtons
243240
data-e2e='rejectLogin'
244241
nature='primary'
245-
onClick={() => props.authActions.authorizeVerifyDevice(false)}
242+
onClick={() => authorizeDevice(false)}
246243
>
247244
<FormattedMessage id='scenes.authorizelogin.reject' defaultMessage='Reject' />
248245
</ApproveRejectButtons>

0 commit comments

Comments
 (0)