From 484a4ba7b089b5a29188b9efa9e159cc51e336e9 Mon Sep 17 00:00:00 2001 From: Alya Date: Fri, 20 Nov 2020 14:12:49 +0300 Subject: [PATCH] Fix href ts-ignore --- .../FaqExpandableItem/FaqExpandableItem.tsx | 9 +---- src/front/shared/components/Href/Href.tsx | 28 +++++++------- .../components/Href/TransactionLink.tsx | 6 +-- .../LinkTransaction/LinkTransaction.tsx | 14 ++++--- src/front/shared/pages/Swap/Share/Share.tsx | 4 +- .../Wallet/components/LinkAccount/index.tsx | 37 ++++++++++--------- 6 files changed, 46 insertions(+), 52 deletions(-) diff --git a/src/front/shared/components/FaqExpandableItem/FaqExpandableItem.tsx b/src/front/shared/components/FaqExpandableItem/FaqExpandableItem.tsx index 9e9984fee2..2e41c04123 100644 --- a/src/front/shared/components/FaqExpandableItem/FaqExpandableItem.tsx +++ b/src/front/shared/components/FaqExpandableItem/FaqExpandableItem.tsx @@ -6,16 +6,9 @@ import styles from './FaqExpandableItem.scss' import Href from 'components/Href/Href' - const FaqExpandableItem = ({ link, question }) => (
- {/* - //@ts-ignore */} - + {question}
diff --git a/src/front/shared/components/Href/Href.tsx b/src/front/shared/components/Href/Href.tsx index 2b3237c670..85af897952 100644 --- a/src/front/shared/components/Href/Href.tsx +++ b/src/front/shared/components/Href/Href.tsx @@ -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 - {children} + + {children} + ) } @@ -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) diff --git a/src/front/shared/components/Href/TransactionLink.tsx b/src/front/shared/components/Href/TransactionLink.tsx index f6afa94ee0..8388eb9416 100644 --- a/src/front/shared/components/Href/TransactionLink.tsx +++ b/src/front/shared/components/Href/TransactionLink.tsx @@ -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': @@ -19,12 +18,13 @@ const setApi = (type, id) => { } } - const TransactionLink = ({ type, id }) => (
- {id} + + {id} +
) diff --git a/src/front/shared/pages/History/LinkTransaction/LinkTransaction.tsx b/src/front/shared/pages/History/LinkTransaction/LinkTransaction.tsx index 83f1e9e68c..eda61314ec 100644 --- a/src/front/shared/pages/History/LinkTransaction/LinkTransaction.tsx +++ b/src/front/shared/pages/History/LinkTransaction/LinkTransaction.tsx @@ -3,15 +3,19 @@ import config from 'app-config' import Href from 'components/Href/Href' - const LinkTransaction = ({ type, children, hash }) => ( - {type.toLowerCase() === 'eth' && {children}} - {type.toLowerCase() === 'btc' && {children}} + {type.toLowerCase() === 'eth' && ( + {children} + )} + {type.toLowerCase() === 'btc' && ( + {children} + )} {/* type.toLowerCase() === 'usdt' && {children} */} - {Object.keys(config.erc20).includes(type.toLowerCase()) && {children}} + {Object.keys(config.erc20).includes(type.toLowerCase()) && ( + {children} + )} ) - export default LinkTransaction diff --git a/src/front/shared/pages/Swap/Share/Share.tsx b/src/front/shared/pages/Swap/Share/Share.tsx index 320b79e1cc..a79c2915d6 100644 --- a/src/front/shared/pages/Swap/Share/Share.tsx +++ b/src/front/shared/pages/Swap/Share/Share.tsx @@ -7,8 +7,7 @@ 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 && ( ) -) export default CSSModules(Share, styles) diff --git a/src/front/shared/pages/Wallet/components/LinkAccount/index.tsx b/src/front/shared/pages/Wallet/components/LinkAccount/index.tsx index f5ef962b77..30b6acef15 100644 --- a/src/front/shared/pages/Wallet/components/LinkAccount/index.tsx +++ b/src/front/shared/pages/Wallet/components/LinkAccount/index.tsx @@ -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 - && {children} +const erc20LinkAcount = (type, children, address, contractAddress) => + Object.keys(config.erc20).map( + (key) => + type.toLowerCase() === key && ( + + {children} + + ) ) const LinkAccount = ({ type, children, address, contractAddress, onClick }) => ( @@ -16,28 +19,26 @@ const LinkAccount = ({ type, children, address, contractAddress, onClick }) => ( {children} ) : ( <> - {type.toLowerCase() === 'eth' && - //@ts-ignore + {type.toLowerCase() === 'eth' && ( {children} - } - {type.toLowerCase() === 'ghost' && - //@ts-ignore + )} + {type.toLowerCase() === 'ghost' && ( {children} - } - {type.toLowerCase() === 'next' && - //@ts-ignore + )} + {type.toLowerCase() === 'next' && ( {children} - } - {(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 {children} - } + )} {erc20LinkAcount(type, children, address, contractAddress)} )} ) - export default LinkAccount