2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2021-09-27 19:42:51 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { useHistory } from 'react-router-dom';
|
|
|
|
import { useMetricEvent } from '../../../hooks/useMetricEvent';
|
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
2021-09-10 22:21:04 +02:00
|
|
|
import { IMPORT_TOKEN_ROUTE } from '../../../helpers/constants/routes';
|
2021-02-04 19:15:23 +01:00
|
|
|
import Button from '../../ui/button';
|
2021-09-10 20:03:42 +02:00
|
|
|
import Box from '../../ui/box/box';
|
|
|
|
import { TEXT_ALIGN } from '../../../helpers/constants/design-system';
|
|
|
|
import { detectNewTokens } from '../../../store/actions';
|
2018-10-16 22:54:34 +02:00
|
|
|
|
2021-09-27 19:42:51 +02:00
|
|
|
export default function ImportTokenLink({ isMainnet }) {
|
2020-06-12 18:22:00 +02:00
|
|
|
const addTokenEvent = useMetricEvent({
|
|
|
|
eventOpts: {
|
|
|
|
category: 'Navigation',
|
|
|
|
action: 'Token Menu',
|
|
|
|
name: 'Clicked "Add Token"',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
const t = useI18nContext();
|
|
|
|
const history = useHistory();
|
2018-10-16 22:54:34 +02:00
|
|
|
|
2020-06-12 18:22:00 +02:00
|
|
|
return (
|
2021-09-10 20:03:42 +02:00
|
|
|
<Box className="import-token-link" textAlign={TEXT_ALIGN.CENTER}>
|
2021-09-27 19:42:51 +02:00
|
|
|
{isMainnet && (
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
className="import-token-link__link"
|
|
|
|
type="link"
|
|
|
|
onClick={() => detectNewTokens()}
|
|
|
|
>
|
|
|
|
{t('refreshList')}
|
|
|
|
</Button>
|
|
|
|
{t('or')}
|
|
|
|
</>
|
|
|
|
)}
|
2021-09-10 20:03:42 +02:00
|
|
|
<Button
|
|
|
|
className="import-token-link__link"
|
|
|
|
type="link"
|
2020-06-12 18:22:00 +02:00
|
|
|
onClick={() => {
|
2021-09-10 22:21:04 +02:00
|
|
|
history.push(IMPORT_TOKEN_ROUTE);
|
2021-02-04 19:15:23 +01:00
|
|
|
addTokenEvent();
|
2020-06-12 18:22:00 +02:00
|
|
|
}}
|
|
|
|
>
|
2021-09-27 19:42:51 +02:00
|
|
|
{isMainnet
|
|
|
|
? t('importTokens')
|
|
|
|
: t('importTokens').charAt(0).toUpperCase() +
|
|
|
|
t('importTokens').slice(1)}
|
2020-06-12 18:22:00 +02:00
|
|
|
</Button>
|
2021-09-10 20:03:42 +02:00
|
|
|
</Box>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-10-16 22:54:34 +02:00
|
|
|
}
|
2021-09-27 19:42:51 +02:00
|
|
|
|
|
|
|
ImportTokenLink.propTypes = {
|
|
|
|
isMainnet: PropTypes.bool,
|
|
|
|
};
|