Skip to content

Commit

Permalink
Merge pull request #3619 from swaponline/href-ts
Browse files Browse the repository at this point in the history
Fix href ts-ignore
  • Loading branch information
alyavasilyeva authored Nov 20, 2020
2 parents 98bad44 + 6c31e78 commit 2eb8507
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@ import styles from './FaqExpandableItem.scss'

import Href from 'components/Href/Href'


const FaqExpandableItem = ({ link, question }) => (
<div styleName="container">
{/*
//@ts-ignore */}
<Href
tab={link}
styleName="header"
rel="noreferrer noopener"
>
<Href tab={link} styleName="header" rel="noreferrer noopener">
{question}
</Href>
</div>
Expand Down
28 changes: 13 additions & 15 deletions src/front/shared/components/Href/Href.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import React from 'react'
import PropTypes from 'prop-types'

import { NavLink } from 'react-router-dom'

import cssModules from 'react-css-modules'

import styles from './Href.scss'

interface HrefProps {
children: React.ReactNode
to?: string
redirect?: string
tab?: string
rel?: string
className?: string
}

const Href = ({ children, to, redirect, tab, rel, className }) => {
const Href = ({ children, to, redirect, tab, rel, className }: HrefProps) => {
if (to) {
return (
//@ts-ignore
<NavLink styleName="link">{children}</NavLink>
<NavLink styleName="link" to={to}>
{children}
</NavLink>
)
}

Expand All @@ -28,13 +35,4 @@ const Href = ({ children, to, redirect, tab, rel, className }) => {
)
}

Href.propTypes = {
children: PropTypes.node.isRequired,
to: PropTypes.string,
redirect: PropTypes.string,
tab: PropTypes.string,
rel: PropTypes.string,
className: PropTypes.string,
}

export default cssModules(Href, styles)
6 changes: 3 additions & 3 deletions src/front/shared/components/Href/TransactionLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Href from './Href'
import config from 'app-config'
import { FormattedMessage } from 'react-intl'


const setApi = (type, id) => {
switch (type) {
case 'BTC':
Expand All @@ -19,12 +18,13 @@ const setApi = (type, id) => {
}
}


const TransactionLink = ({ type, id }) => (
<div>
<FormattedMessage id="transactionLink28" defaultMessage="Transaction: " />
<strong>
<Href tab={setApi(type, id)} rel="noopener noreferrer">{id}</Href>
<Href tab={setApi(type, id)} rel="noopener noreferrer">
{id}
</Href>
</strong>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ import config from 'app-config'

import Href from 'components/Href/Href'


const LinkTransaction = ({ type, children, hash }) => (
<Fragment>
{type.toLowerCase() === 'eth' && <Href tab={`${config.link.etherscan}/tx/${hash}`} >{children}</Href>}
{type.toLowerCase() === 'btc' && <Href tab={`${config.link.bitpay}/tx/${hash}`} >{children}</Href>}
{type.toLowerCase() === 'eth' && (
<Href tab={`${config.link.etherscan}/tx/${hash}`}>{children}</Href>
)}
{type.toLowerCase() === 'btc' && (
<Href tab={`${config.link.bitpay}/tx/${hash}`}>{children}</Href>
)}
{/* type.toLowerCase() === 'usdt' && <Href tab={`${config.link.usdt}/tx/${hash}`} >{children}</Href> */}
{Object.keys(config.erc20).includes(type.toLowerCase()) && <Href tab={`${config.link.etherscan}/tx/${hash}`}>{children}</Href>}
{Object.keys(config.erc20).includes(type.toLowerCase()) && (
<Href tab={`${config.link.etherscan}/tx/${hash}`}>{children}</Href>
)}
</Fragment>
)


export default LinkTransaction
4 changes: 1 addition & 3 deletions src/front/shared/pages/Swap/Share/Share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import { Button } from 'components/controls'
import Href from 'components/Href/Href'
import { FormattedMessage } from 'react-intl'


const Share = ({ flow }) => (
const Share = ({ flow }) =>
flow.step >= 5 && (
<Href tab="https://twitter.com/intent/tweet?url=https://swaponline.io/&text=I%20just%20make%20swap%20on%20&hashtags=AtomicSwap,DEX,Bitcoin,SWAP&via=SwapOnlineTeam">
<Button brand>
<FormattedMessage id="Share" defaultMessage="Share Twitter" />
</Button>
</Href>
)
)

export default CSSModules(Share, styles)
37 changes: 19 additions & 18 deletions src/front/shared/pages/Wallet/components/LinkAccount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import config from 'app-config'

import Href from 'components/Href/Href'


const erc20LinkAcount = (type, children, address, contractAddress) => Object.keys(config.erc20)
.map(key => type.toLowerCase() === key
//@ts-ignore
&& <Href key={key} tab={`${config.link.etherscan}/token/${contractAddress}?a=${address}`} >{children}</Href>
const erc20LinkAcount = (type, children, address, contractAddress) =>
Object.keys(config.erc20).map(
(key) =>
type.toLowerCase() === key && (
<Href key={key} tab={`${config.link.etherscan}/token/${contractAddress}?a=${address}`}>
{children}
</Href>
)
)

const LinkAccount = ({ type, children, address, contractAddress, onClick }) => (
Expand All @@ -16,28 +19,26 @@ const LinkAccount = ({ type, children, address, contractAddress, onClick }) => (
<a onClick={onClick}>{children}</a>
) : (
<>
{type.toLowerCase() === 'eth' &&
//@ts-ignore
{type.toLowerCase() === 'eth' && (
<Href tab={`${config.link.etherscan}/address/${address}`}>{children}</Href>
}
{type.toLowerCase() === 'ghost' &&
//@ts-ignore
)}
{type.toLowerCase() === 'ghost' && (
<Href tab={`${config.link.ghostscan}/address/${address}`}>{children}</Href>
}
{type.toLowerCase() === 'next' &&
//@ts-ignore
)}
{type.toLowerCase() === 'next' && (
<Href tab={`${config.link.nextExplorer}/#/address/${address}`}>{children}</Href>
}
{(type.toLowerCase() === 'btc' || type.toLowerCase() === 'btc (pin-protected)' || type.toLowerCase() === 'btc (sms-protected)' || type.toLowerCase() === 'btc (multisig)')
&&
)}
{(type.toLowerCase() === 'btc' ||
type.toLowerCase() === 'btc (pin-protected)' ||
type.toLowerCase() === 'btc (sms-protected)' ||
type.toLowerCase() === 'btc (multisig)') && (
//@ts-ignore
<Href tab={`${config.link.bitpay}/address/${address}`}>{children}</Href>
}
)}
{erc20LinkAcount(type, children, address, contractAddress)}
</>
)}
</>
)


export default LinkAccount

0 comments on commit 2eb8507

Please sign in to comment.