import React from 'react'; import PropTypes from 'prop-types'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; import Box from '../../ui/box'; import Button from '../../ui/button'; import Typography from '../../ui/typography/typography'; import CollectiblesDetectionNotice from '../collectibles-detection-notice'; import CollectiblesItems from '../collectibles-items'; import { COLORS, TYPOGRAPHY, TEXT_ALIGN, JUSTIFY_CONTENT, FLEX_DIRECTION, FONT_WEIGHT, ALIGN_ITEMS, } from '../../../helpers/constants/design-system'; import { useI18nContext } from '../../../hooks/useI18nContext'; import { getIsMainnet, getUseNftDetection } from '../../../selectors'; import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes'; import { checkAndUpdateAllNftsOwnershipStatus, detectNfts, } from '../../../store/actions'; import { useCollectiblesCollections } from '../../../hooks/useCollectiblesCollections'; import ZENDESK_URLS from '../../../helpers/constants/zendesk-url'; export default function CollectiblesTab({ onAddNFT }) { const useNftDetection = useSelector(getUseNftDetection); const isMainnet = useSelector(getIsMainnet); const history = useHistory(); const t = useI18nContext(); const dispatch = useDispatch(); const { collectiblesLoading, collections, previouslyOwnedCollection } = useCollectiblesCollections(); const onEnableAutoDetect = () => { history.push(EXPERIMENTAL_ROUTE); }; const onRefresh = () => { if (isMainnet) { dispatch(detectNfts()); } checkAndUpdateAllNftsOwnershipStatus(); }; if (collectiblesLoading) { return
{t('loadingNFTs')}
; } return ( {Object.keys(collections).length > 0 || previouslyOwnedCollection.collectibles.length > 0 ? ( ) : ( <> {isMainnet && !useNftDetection ? ( ) : null} {t('noNFTs')} )} {t('missingNFT')} {!isMainnet && Object.keys(collections).length < 1 ? null : ( <> {isMainnet && !useNftDetection ? ( ) : ( )} {t('or')} )} ); } CollectiblesTab.propTypes = { onAddNFT: PropTypes.func.isRequired, };