1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-18 15:33:21 +01:00
metamask-extension/ui/app/pages/swaps/intro-popup/intro-popup.js

105 lines
3.3 KiB
JavaScript
Raw Normal View History

2020-10-06 20:28:38 +02:00
import React, { useContext } from 'react'
import { useDispatch } from 'react-redux'
2020-10-06 20:28:38 +02:00
import { useHistory } from 'react-router-dom'
import PropTypes from 'prop-types'
import { setSwapsFromToken } from '../../../ducks/swaps/swaps'
import { I18nContext } from '../../../contexts/i18n'
import { BUILD_QUOTE_ROUTE } from '../../../helpers/constants/routes'
import { useNewMetricEvent } from '../../../hooks/useMetricEvent'
import { useSwapsEthToken } from '../../../hooks/useSwapsEthToken'
2020-10-06 20:28:38 +02:00
import Button from '../../../components/ui/button'
import Popover from '../../../components/ui/popover'
2020-11-03 00:41:28 +01:00
export default function IntroPopup({ onClose }) {
2020-10-06 20:28:38 +02:00
const dispatch = useDispatch(useDispatch)
const history = useHistory()
const t = useContext(I18nContext)
2020-11-03 00:41:28 +01:00
const enteredSwapsEvent = useNewMetricEvent({
event: 'Swaps Opened',
properties: { source: 'Intro popup', active_currency: 'ETH' },
category: 'swaps',
})
const blogPostVisitedEvent = useNewMetricEvent({
event: 'Blog Post Visited ',
category: 'swaps',
})
const contractAuditVisitedEvent = useNewMetricEvent({
event: 'Contract Audit Visited',
category: 'swaps',
})
const productOverviewDismissedEvent = useNewMetricEvent({
event: 'Product Overview Dismissed',
category: 'swaps',
})
const swapsEthToken = useSwapsEthToken()
2020-10-06 20:28:38 +02:00
return (
<div className="intro-popup">
<Popover
className="intro-popup__popover"
title={t('swapIntroPopupTitle')}
subtitle={t('swapIntroPopupSubTitle')}
onClose={() => {
productOverviewDismissedEvent()
onClose()
}}
footerClassName="intro-popup__footer"
2020-11-03 00:41:28 +01:00
footer={
2020-10-06 20:28:38 +02:00
<Button
type="confirm"
className="intro-popup__button"
onClick={() => {
onClose()
enteredSwapsEvent()
dispatch(setSwapsFromToken(swapsEthToken))
2020-10-06 20:28:38 +02:00
history.push(BUILD_QUOTE_ROUTE)
}}
>
2020-11-03 00:41:28 +01:00
{t('swapStartSwapping')}
2020-10-06 20:28:38 +02:00
</Button>
}
>
<div className="intro-popup__content">
<div className="intro-popup__liquidity-sources-label">
{t('swapIntroLiquiditySourcesLabel')}
</div>
<div className="intro-popup__source-logo-container">
<img src="images/source-logos-all.svg" alt="" />
2020-10-06 20:28:38 +02:00
</div>
<div className="intro-popup__learn-more-header">
{t('swapIntroLearnMoreHeader')}
</div>
<div
className="intro-popup__learn-more-link"
onClick={() => {
2020-11-03 00:41:28 +01:00
global.platform.openTab({
url:
'https://medium.com/metamask/introducing-metamask-swaps-84318c643785',
})
2020-10-06 20:28:38 +02:00
blogPostVisitedEvent()
}}
>
{t('swapIntroLearnMoreLink')}
</div>
<div
className="intro-popup__learn-more-link"
onClick={() => {
2020-11-03 00:41:28 +01:00
global.platform.openTab({
url:
'https://diligence.consensys.net/audits/private/lsjipyllnw2/',
})
2020-10-06 20:28:38 +02:00
contractAuditVisitedEvent()
}}
>
{t('swapLearnMoreContractsAuditReview')}
</div>
</div>
</Popover>
</div>
)
}
IntroPopup.propTypes = {
onClose: PropTypes.func.isRequired,
}