-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
ImportTokenWarningModal.tsx
44 lines (37 loc) · 1.22 KB
/
ImportTokenWarningModal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { useTranslation } from '@pancakeswap/localization'
import { Token } from '@pancakeswap/sdk'
import { Box, InjectedModalProps, Modal } from '@pancakeswap/uikit'
import ImportToken from 'components/SearchModal/ImportToken'
import { useUnsupportedTokens } from 'hooks/Tokens'
import { useMemo } from 'react'
import { UnsupportedModal } from './UnsupportedModal'
interface Props extends InjectedModalProps {
tokens: Token[]
onCancel: () => void
}
const ImportTokenWarningModal: React.FC<React.PropsWithChildren<Props>> = ({ tokens, onDismiss, onCancel }) => {
const { t } = useTranslation()
const unsupportedTokens = useUnsupportedTokens()
const hasUnsupportedTokens = useMemo(() => {
return tokens.some((token) => {
return unsupportedTokens?.[token.address]
})
}, [tokens, unsupportedTokens])
if (hasUnsupportedTokens) {
return <UnsupportedModal onDismiss={onCancel} currencies={tokens} />
}
return (
<Modal
title={t('Import Token')}
onDismiss={() => {
onDismiss?.()
onCancel()
}}
>
<Box maxWidth="380px">
<ImportToken tokens={tokens} handleCurrencySelect={onDismiss} />
</Box>
</Modal>
)
}
export default ImportTokenWarningModal