Skip to content

Commit

Permalink
feat(ts): use connector and ConnectedProps
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Apr 19, 2020
1 parent 1428f34 commit ac280e3
Show file tree
Hide file tree
Showing 54 changed files with 653 additions and 702 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"typescript-sort-keys/interface": 2,
"typescript-sort-keys/string-enum": 2,
"@typescript-eslint/no-unused-vars": 2,
"@typescript-eslint/switch-exhaustiveness-check": 2,
"@typescript-eslint/consistent-type-definitions": ["error", "type"]
"@typescript-eslint/switch-exhaustiveness-check": 2
}
}
],
Expand Down
1 change: 1 addition & 0 deletions packages/blockchain-info-components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DefaultTheme } from 'styled-components'
import { IcoMoonType } from './src/Icons/Icomoon'
import { ImageType } from './src/Images/Images'

export const Badge: StatelessComponent<any>
export const Banner: StatelessComponent<any>
export const BlockchainLoader: StatelessComponent<{
width?: string
Expand Down
46 changes: 31 additions & 15 deletions packages/blockchain-wallet-v4-frontend/src/assets/locales/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ type MessagesType = {
'copy.private_key': 'Private Key'
'dentityverification.verify.resubmit.reason.missing': 'The required photos are missing'
'exchange-side-nav-tooltip-connected': 'connected'
'faq.tooltip.description': 'Frequently Asked Questions'
'formhelper.ageovereighteen': 'Must be 18 or older'
'formhelper.exchange.learnmore': 'Learn more.'
'formhelper.exchange.require2fa': 'Exchange deposits require 2FA.'
Expand Down Expand Up @@ -385,14 +386,6 @@ type MessagesType = {
'identityverification.verify.resubmit.reason.quality': 'We were unable to read the images you submitted due to image quality'
'identityverification.verify.supportecountrieslist': 'Not all countries are supported at this time. Check our up to date <a href="https://support.blockchain.com/hc/en-us/articles/360018751932" target="_blank" rel="noopener noreferrrer">list of countries</a> before proceeding.'
'identityverification.verify.supportedcountries': 'Is my country supported?'
'layouts.public.alreadyhave_1': 'Already have a Wallet?'
'layouts.public.donthave_1': "Don't have a Wallet?"
'layouts.public.footer.about': 'About'
'layouts.public.footer.blog': 'Blog'
'layouts.public.footer.explorer': 'Data'
'layouts.public.footer.support': 'Support'
'layouts.public.login': 'Log In'
'layouts.public.register': 'Create One Now'
'layouts.wallet.header.Sign Out': 'Sign Out'
'layouts.wallet.header.announcements.emailreminder': 'Confirm your email address to properly secure your account'
'layouts.wallet.header.announcements.emailreminder.change': 'Change Email'
Expand Down Expand Up @@ -555,7 +548,6 @@ type MessagesType = {
'modals.confirm.title.verify_identity': 'Verify Your Identity'
'modals.confirm.title/bitpay': "You've Entered a BitPay URL"
'modals.details.borrow.addcollat': 'Add Collateral'
'modals.details.borrow.close': 'Close'
'modals.details.borrow.endborrow': 'End Borrowing'
'modals.details.borrow.retryrepayment': 'Retry Repayment'
'modals.disable2fa.disable': 'Disable'
Expand Down Expand Up @@ -779,7 +771,6 @@ type MessagesType = {
'modals.onboarding.linktoexchangeaccount.success.title': 'Success!'
'modals.pairingcode.title': 'Scan Pairing Code'
'modals.prompt.button': 'Submit'
'modals.qrcode.back': 'Go back'
'modals.qrcode.scan': 'Scan QR Code'
'modals.qrcode.title': 'Request'
'modals.qrcode.tooltip': 'Ask the sender to scan this QR code with their bitcoin wallet.'
Expand Down Expand Up @@ -1085,6 +1076,7 @@ type MessagesType = {
'modals.sunriverlinkerror.campaign_has_expired': "We're sorry, this specific airdrop is over. Completing your profile will still give you access to higher Swap limits and future airdrops."
'modals.sunriverlinkerror.error': 'Oops! We had trouble processing your airdrop. Please try again.'
'modals.sunriverlinkerror.title': 'Whoops!'
'modals.support.contact_support': 'Contact Support'
'modals.support.need_some_help': 'Need some help?'
'modals.support.our_support': 'Our Blockchain Support Team is standing by.'
'modals.swap_upgrade.amount_after_upgrade': 'Upgrade to Tier {tierIndex} and Swap up to {amount} every day.'
Expand Down Expand Up @@ -1321,7 +1313,9 @@ type MessagesType = {
'scenes.exchange.exchangeform.max': 'MAX'
'scenes.exchange.exchangeform.min': 'MIN'
'scenes.exchange.exchangeform.nosourcexlmaccount': 'Minimum of 1 XLM needed for new accounts. Learn about Stellar’s minimum balance requirement.'
'scenes.exchange.exchangeform.notifications.kyclearnmore': 'Learn more'
'scenes.exchange.exchangeform.notifications.kycrejected': 'We had trouble approving your identity. Your Swap feature has been disabled at this time.'
'scenes.exchange.exchangeform.notifications.paxlearnmore': 'Learn more'
'scenes.exchange.exchangeform.notifications.usdddisclaimer': 'A USD Digital token is not itself a US dollar, but Paxos Trust Company, LLC is responsible for backing every token with a US dollar held in segregated accounts at FDIC-insured, U.S. banks. Paxos Trust Company, LLC is also responsible for issuing and redeeming each token in exchange for $1.00.'
'scenes.exchange.exchangeform.refreshlatest': 'Refresh status.'
'scenes.exchange.exchangeform.retry': 'Retry.'
Expand Down Expand Up @@ -1429,6 +1423,7 @@ type MessagesType = {
'scenes.lockbox.dashboard.transactions.thatsit': "That's it! No more transactions 📭"
'scenes.lockbox.dashboard.updaterequirednotice.dismiss': "I've already updated"
'scenes.lockbox.dashboard.updaterequirednotice.download': 'Download Software'
'scenes.lockbox.dashboard.updaterequirednotice.learn': 'Learn more'
'scenes.lockbox.dashboard.updaterequirednotice.subtitle': 'In order to continue using your Lockbox, you must first update your device and reinstall the apps via the following updating software.'
'scenes.lockbox.dashboard.updaterequirednotice.title': 'Software Update Required'
'scenes.lockbox.menu.currencylist.error': 'Oops. Something went wrong. Click <span class="link">here</span> to refresh.'
Expand Down Expand Up @@ -1492,6 +1487,8 @@ type MessagesType = {
'scenes.login.password': 'Password'
'scenes.login.resendsms': 'Resend SMS'
'scenes.login.sendguid': 'Send my Wallet ID'
'scenes.login.wallet.link': 'Dont have a wallet?'
'scenes.login.wallet.signup': 'Sign Up'
'scenes.login.welcome': 'Welcome back!'
'scenes.login.wrong_password': 'Error decrypting wallet. Wrong password'
'scenes.login.yubikey': 'Yubikey'
Expand Down Expand Up @@ -1547,6 +1544,8 @@ type MessagesType = {
'scenes.profile.identityverification.swaplimit.wanttolearnmore': 'Want to learn more?'
'scenes.profile.identityverification.tradingtitle': 'Trading Limits'
'scenes.profile.idv.swaplimit.airdropdisclaimer1': "Gold verification is currently under review. Once verified you'll be able to use Swap (trading up to {tier2Limit}) and also be eligible for future crypto airdrops!"
'scenes.public.register.createExchange': 'Create an Exchange Account'
'scenes.public.register.createWallet': 'Create Wallet'
'scenes.recover.firststep.funds': 'Recover Funds'
'scenes.recover.firststep.mnemonic': 'Your Backup Phrase'
'scenes.recover.firststep.mnemonic_explain': 'Enter your 12 word phrase, lowercase, with spaces between each word, to recover your funds & transactions.'
Expand All @@ -1556,9 +1555,18 @@ type MessagesType = {
'scenes.recover.secondstep.funds': 'Recover Funds'
'scenes.recover.secondstep.password': 'Password'
'scenes.recover.secondstep.recover': 'Recover Funds'
'scenes.register.browserwarning': 'Your browser is not supported. Please update to at least Chrome 45, Firefox 45, Safari 8, IE 11, or Opera'
'scenes.register.browserwarning': 'Your browser is not supported. Please update to at least Chrome 45, Firefox 45, Safari 8, IE 11, or Opera '
'scenes.register.confirmpassword': 'Confirm Password'
'scenes.register.createaccount': 'Create an Account'
'scenes.register.exchange.subcard': 'You will be taken to our trading experience to continue sign up.'
'scenes.register.exchangecard.infotitle': 'The world’s most trusted crypto exchange.'
'scenes.register.exchangecard.item.1.bold': 'Lightning-fast trades'
'scenes.register.exchangecard.item.1.regular': 'mean you get the best price.'
'scenes.register.exchangecard.item.2.bold': 'Over 20 trading pairs'
'scenes.register.exchangecard.item.2.regular': 'including USD, GBP, and EUR.'
'scenes.register.exchangecard.item.3.bold': 'Control your money'
'scenes.register.exchangecard.item.3.regular': 'by connecting your Wallet.'
'scenes.register.exchangecard.title': 'Blockchain Exchange'
'scenes.register.getstarted': 'Get started by signing up'
'scenes.register.invalidstrongpassword': 'Your password is not strong enough'
'scenes.register.password': 'Password'
'scenes.register.registerform.blockchain.default.privacypolicy': 'Privacy Policy.'
Expand All @@ -1568,6 +1576,17 @@ type MessagesType = {
'scenes.register.registerform.blockchain.read_1': 'By creating an account, you agree to Blockchain’s'
'scenes.register.registerform.blockchain.terms': 'Terms of Service'
'scenes.register.registerform.blockchainkyc.read': 'By hitting continue, I agree to Blockchain’s'
'scenes.register.securelybuy': 'Securely buy, sell, and store crypto.'
'scenes.register.wallet.link': 'Already have a wallet?'
'scenes.register.wallet.signin': 'Sign In'
'scenes.register.walletcard.infotitle': 'Be your own bank.'
'scenes.register.walletcard.item.1.bold': 'Easily buy and sell'
'scenes.register.walletcard.item.1.regular': 'Bitcoin, Ether, and more.'
'scenes.register.walletcard.item.2.bold': 'Securely store your'
'scenes.register.walletcard.item.2.regular': 'on mobile or desktop.'
'scenes.register.walletcard.item.3.bold': 'Control your money'
'scenes.register.walletcard.item.3.regular': 'by holding your private keys.'
'scenes.register.walletcard.title': 'Blockchain Wallet'
'scenes.register.youremail': 'Your Email'
'scenes.reminder.captcha': 'Captcha'
'scenes.reminder.email': 'Email'
Expand Down Expand Up @@ -1699,7 +1718,6 @@ type MessagesType = {
'scenes.securitysettings.advancedsettings.walletaccesstor.settings.allow': 'Allow'
'scenes.securitysettings.advancedsettings.walletaccesstor.settings.block': 'Block'
'scenes.securitysettings.basicsecurity.recoveryphrase.description': 'Your backup phrase contains all of the private keys within your wallet. Please write these 12 words down, in order, and keep them somewhere safe offline. This phrase gives you (or anyone who has it) a way to restore your wallet and access your funds.'
'scenes.securitysettings.basicsecurity.recoveryphrase.description.verifyphrase': 'Using the 12 words you just wrote down, please enter the following words exactly as you see them to complete the backup process.'
'scenes.securitysettings.basicsecurity.recoveryphrase.description2': 'In the event that you lose your password or our service is unavailable, this will be your safety net.'
'scenes.securitysettings.basicsecurity.recoveryphrase.title': 'Backup Phrase'
'scenes.securitysettings.basicsecurity.twostepverification.description': 'Your browser will be remembered for a short period of time, allowing you to login again without having to re-authenticate.'
Expand All @@ -1713,8 +1731,6 @@ type MessagesType = {
'scenes.securitysettings.basicsecurity.twostepverificationremember.settings.enable': 'Enable'
'scenes.securitysettings.basicsecurity.walletrecovery.settings.backupagain': 'Backup Again'
'scenes.securitysettings.basicsecurity.walletrecovery.settings.backupfunds': 'Backup Funds'
'scenes.securitysettings.basicsecurity.walletrecovery.settings.donotstore': 'Do not store your backup phrase on your computer or anywhere online. It is very important to keep your backup phrase offline in a private place. As a reminder: anyone with access to your backup phrase can access your funds.'
'scenes.securitysettings.basicsecurity.walletrecovery.settings.securitytip': 'Security Tip'
'scenes.settings.addresses.archive': 'Archive'
'scenes.settings.addresses.bch.archive': 'Archive'
'scenes.settings.addresses.bch.edit_name': 'Edit Wallet Name'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ import { SkeletonRectangle } from 'blockchain-info-components'
import React from 'react'
import SelectBoxBtc from './template'

type LinkStatePropsType = {
data: RemoteDataType<
string,
{
data: Array<AccountTypes>
}
>
supportedCoins: SupportedCoinsType
}

type Props = LinkStatePropsType

class SelectBoxBtcAddresses extends React.PureComponent<Props> {
render () {
const { data, ...rest } = this.props
Expand All @@ -42,4 +30,17 @@ const mapStateToProps = (state, ownProps) => ({
data: getData(state, ownProps)
})

export default connect(mapStateToProps)(SelectBoxBtcAddresses)
const connector = connect(mapStateToProps)

type LinkStatePropsType = {
data: RemoteDataType<
string,
{
data: Array<AccountTypes>
}
>
supportedCoins: SupportedCoinsType
}
type Props = LinkStatePropsType

export default connector(SelectBoxBtcAddresses)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { actions, model } from 'data'
import { all, path, propEq } from 'ramda'
import { bindActionCreators } from 'redux'
import { Button, Icon, Text, TextGroup } from 'blockchain-info-components'
import { connect } from 'react-redux'
import { connect, ConnectedProps } from 'react-redux'
import { ctas, headers, limits, messages, status } from './services'
import { Exchange } from 'blockchain-wallet-v4/src'
import { formatFiat } from 'core/exchange/currency'
Expand Down Expand Up @@ -105,22 +105,6 @@ export const ActionButton = styled(Button)`

const { TIERS_STATES } = model.profile

type LinkDispatchPropsType = {
goToSwap: () => void
identityVerificationActions: typeof actions.components.identityVerification
}

type OwnProps = {
column: boolean
emailVerified: boolean
mobileVerified: boolean
tier: 1 | 2
userData: UserDataType
userTiers: UserTiersType
}

type Props = LinkDispatchPropsType & OwnProps

export const TierCard = ({
column,
emailVerified,
Expand Down Expand Up @@ -253,7 +237,19 @@ const mapDispatchToProps = dispatch => ({
goToSwap: () => dispatch(actions.router.push('/swap'))
})

export default connect(
const connector = connect(
getData,
mapDispatchToProps
)(TierCard)
)

type OwnProps = {
column: boolean
emailVerified: boolean
mobileVerified: boolean
tier: 1 | 2
userData: UserDataType
userTiers: UserTiersType
}
type Props = OwnProps & ConnectedProps<typeof connector>

export default connector(TierCard)
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { actions } from 'data'
import { bindActionCreators, Dispatch } from 'redux'
import { connect } from 'react-redux'
import { connect, ConnectedProps } from 'react-redux'

import { BlueCartridge } from 'components/Cartridge'
import { FormattedMessage } from 'react-intl'
import { Icon } from 'blockchain-info-components'
import React from 'react'
import styled, { css } from 'styled-components'

type LinkDispatchPropsType = {
modalActions: typeof actions.modals
}
const customCartridge = css`
display: flex;
align-items: center;
Expand All @@ -28,9 +25,7 @@ const BackupLink = styled.span`
cursor: pointer;
`

class MnemonicRequiredForCustodySend extends React.PureComponent<
LinkDispatchPropsType
> {
class MnemonicRequiredForCustodySend extends React.PureComponent<Props> {
handleClick = () => {
this.props.modalActions.showModal('RECOVERY_PHRASE_MODAL')
}
Expand Down Expand Up @@ -60,11 +55,15 @@ class MnemonicRequiredForCustodySend extends React.PureComponent<
}
}

const mapDispatchToProps = (dispatch: Dispatch): LinkDispatchPropsType => ({
const mapDispatchToProps = (dispatch: Dispatch) => ({
modalActions: bindActionCreators(actions.modals, dispatch)
})

export default connect(
const connector = connect(
null,
mapDispatchToProps
)(MnemonicRequiredForCustodySend)
)

type Props = ConnectedProps<typeof connector>

export default connector(MnemonicRequiredForCustodySend)
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ import { UserDataType } from 'data/types'
import React from 'react'
import styled from 'styled-components'

type LinkStatePropsType = {
domains: { [key in string]: string }
sbOrders: Array<SBOrderType>
userData: UserDataType | null
}
type State = { widgetOpen: boolean }
type CustomIframe = State
type Props = LinkStatePropsType & CustomIframe

const Wrapper = styled.div`
position: absolute;
bottom: 0;
Expand Down Expand Up @@ -91,4 +82,15 @@ const mapStateToProps = (state: RootState): LinkStatePropsType => ({
userData: selectors.modules.profile.getUserData(state).getOrElse(null)
})

export default connect(mapStateToProps)(ZendeskWidget)
const connector = connect(mapStateToProps)

type LinkStatePropsType = {
domains: { [key in string]: string }
sbOrders: Array<SBOrderType>
userData: UserDataType | null
}
type State = { widgetOpen: boolean }
type CustomIframe = State
type Props = LinkStatePropsType & CustomIframe

export default connector(ZendeskWidget)
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export type UserDataType = {
resubmission: null
settings: null
state: UserActivationStateType
tags: Array<TagsType>
tags: TagsType
tiers: {
current: 0 | 1 | 2
next: 0 | 1 | 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const mapDispatchToProps = dispatch => ({
authActions: bindActionCreators(actions.auth, dispatch)
})

export default connect(
const connector = connect(
undefined,
mapDispatchToProps
)(SettingsContainer)
)

export default connector(SettingsContainer)
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import { actions } from 'data'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { connect, ConnectedProps } from 'react-redux'
import { getData } from './selectors'
import { RemoteDataType } from 'core/types'
import React from 'react'
import WhatsNewIcon from './template'

type LinkStatePropsType = {
data: RemoteDataType<string, { numOfNewAnnouncements: number }>
}

type LinkDispatchPropsType = {
modalActions: typeof actions.modals
}

type Props = LinkStatePropsType & LinkDispatchPropsType

class WhatsNewIconContainer extends React.PureComponent<Props> {
handleClick = () => {
this.props.modalActions.showModal('WHATS_NEW_MODAL')
Expand Down Expand Up @@ -44,7 +34,17 @@ const mapDispatchToProps = dispatch => ({
modalActions: bindActionCreators(actions.modals, dispatch)
})

export default connect(
const connector = connect(
mapStateToProps,
mapDispatchToProps
)(WhatsNewIconContainer)
)

type LinkStatePropsType = {
data: RemoteDataType<string, { numOfNewAnnouncements: number }>
}
type LinkDispatchPropsType = {
modalActions: typeof actions.modals
}
type Props = ConnectedProps<typeof connector>

export default connector(WhatsNewIconContainer)

0 comments on commit ac280e3

Please sign in to comment.