diff --git a/components/NftsComponent.js b/components/NftsComponent.js index bf276141..4d632c7b 100644 --- a/components/NftsComponent.js +++ b/components/NftsComponent.js @@ -13,7 +13,7 @@ import { nativeCurrency } from '../utils' import { isValidTaxon, nftThumbnail, nftNameLink, ipfsUrl, nftPriceData } from '../utils/nft' -import { nftLink, usernameOrAddress, timeOrDate, fullDateAndTime, niceCurrency, capitalize } from '../utils/format' +import { nftLink, usernameOrAddress, timeOrDate, fullDateAndTime, capitalize } from '../utils/format' import SEO from './SEO' import SearchBlock from './Layout/SearchBlock' @@ -21,6 +21,7 @@ import Tiles from './Tiles' import IssuerSelect from './UI/IssuerSelect' import CheckBox from './UI/CheckBox' import DateAndTimeRange from './UI/DateAndTimeRange' +import TokenSelector from './UI/TokenSelector' import RadioOptions from './UI/RadioOptions' import FormInput from './UI/FormInput' @@ -97,6 +98,21 @@ export default function NftsComponent({ const [issuerTaxonUrlPart, setIssuerTaxonUrlPart] = useState('?view=' + activeView) const [collectionUrlPart, setCollectionUrlPart] = useState(collectionQuery ? '&collection=' + collectionQuery : '') const [filtersHide, setFiltersHide] = useState(false) + const [selectedToken, setSelectedToken] = useState(() => { + if (saleCurrencyIssuer && saleCurrency) { + return { + currency: saleCurrency, + issuer: saleCurrencyIssuer + } + } else if (saleCurrency === nativeCurrency && !saleCurrencyIssuer) { + return { + currency: nativeCurrency + } + } + return { + currency: nativeCurrency + } + }) const controller = new AbortController() @@ -121,7 +137,7 @@ export default function NftsComponent({ const listTabList = [ { value: 'nfts', label: t('tabs.all') }, - { value: 'onSale', label: t('tabs.onSale', { nativeCurrency }) } + { value: 'onSale', label: t('tabs.onSale') } ] let saleDestinationTabList = [] @@ -194,8 +210,11 @@ export default function NftsComponent({ if (listTab === 'onSale') { //destination: "public", "knownBrokers", "publicAndKnownBrokers", "all", "buyNow" listUrlPart = '?list=onSale&destination=' + saleDestinationTab - if (saleCurrencyIssuer && saleCurrency) { - listUrlPart = listUrlPart + '¤cy=' + saleCurrency + '¤cyIssuer=' + saleCurrencyIssuer + if (selectedToken?.currency) { + listUrlPart = listUrlPart + '¤cy=' + selectedToken.currency + if (selectedToken.issuer) { + listUrlPart = listUrlPart + '¤cyIssuer=' + selectedToken.issuer + } } else { listUrlPart = listUrlPart + '¤cy=' + nativeCurrency?.toLowerCase() } @@ -437,7 +456,8 @@ export default function NftsComponent({ includeBurned, includeWithoutMediaData, mintedPeriod, - burnedPeriod + burnedPeriod, + selectedToken ]) useEffect(() => { @@ -519,6 +539,25 @@ export default function NftsComponent({ setTab: setOrder, paramName: 'order' }) + + // Add token parameters + if (selectedToken?.currency) { + queryAddList.push({ + name: 'saleCurrency', + value: selectedToken.currency + }) + if (selectedToken.issuer) { + queryAddList.push({ + name: 'saleCurrencyIssuer', + value: selectedToken.issuer + }) + } else { + queryRemoveList.push('saleCurrencyIssuer') + } + } else { + queryRemoveList.push('saleCurrency') + queryRemoveList.push('saleCurrencyIssuer') + } } else { queryRemoveList.push('saleDestination') queryRemoveList.push('saleCurrency') @@ -552,7 +591,7 @@ export default function NftsComponent({ setTabParams(router, tabsToSet, queryAddList, queryRemoveList) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [order, rawData, listTab, saleDestinationTab, includeBurned, includeWithoutMediaData]) + }, [order, rawData, listTab, saleDestinationTab, includeBurned, includeWithoutMediaData, selectedToken]) const onTaxonInput = (value) => { if (/^\d+$/.test(value) && issuer && isValidTaxon(value)) { @@ -638,7 +677,7 @@ export default function NftsComponent({ (isValidTaxon(taxonQuery) ? ' ' + taxonQuery : '') + (ownerQuery ? ', ' + t('table.owner') + ': ' + ownerQuery : '') + (activeView === 'list' ? ' ' + t('tabs.list') : '') + - (listTab === 'onSale' ? ' ' + t('tabs.onSale', { nativeCurrency }) : '') + + (listTab === 'onSale' ? ' ' + t('tabs.onSale') : '') + (listTab === 'onSale' && (saleDestinationTab === 'buyNow' || saleDestinationTab === 'public') ? ', ' + t('tabs.buyNow') : '') + @@ -701,29 +740,17 @@ export default function NftsComponent({ )} {!burnedPeriod && listTab === 'onSale' && (
- {t('table.on-sale')} +
+ {t('table.currency')} + +
+
- {saleCurrencyIssuer && saleCurrency && ( - <> - - - - )}
)} {nftExplorer && ( diff --git a/public/locales/de/common.json b/public/locales/de/common.json index 2cb5d9ec..5e8d37c2 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -557,7 +557,7 @@ "sell": "Verkaufen", "buyNow": "Jetzt kaufen", "publicAndKnownBrokers": "Öffentlich & MP", - "onSale": "Zum Verkauf für {{nativeCurrency}}", + "onSale": "Gelistet", "all-tokens": "Alle Tokens", "native-currency-only": "Nur {{nativeCurrency}}", "mintedNew": "Neuste", diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 582e8096..0a6d75f0 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -557,7 +557,7 @@ "sell": "Sell", "buyNow": "Buy now", "publicAndKnownBrokers": "Public & MP", - "onSale": "On sale for {{nativeCurrency}}", + "onSale": "Listed", "all-tokens": "All tokens", "native-currency-only": "{{nativeCurrency}} only", "mintedNew": "Latest", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 1814ebb8..f3a6cb43 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -557,7 +557,7 @@ "sell": "Venta", "buyNow": "Comprar ya", "publicAndKnownBrokers": "Público Y Mercado", - "onSale": "En venta por {{nativeCurrency}}", + "onSale": "Listado", "all-tokens": "Todos los tokens", "native-currency-only": "Solo {{nativeCurrency}}", "mintedNew": "Latest", diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index 41434403..d899abba 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -557,7 +557,7 @@ "sell": "Vendre", "buyNow": "Acheter maintenant", "publicAndKnownBrokers": "Public & MP", - "onSale": "En vente pour {{nativeCurrency}}", + "onSale": "Sont en vente", "all-tokens": "Tous les tokens", "native-currency-only": "Uniquement {{nativeCurrency}}", "mintedNew": "Derniers", diff --git a/public/locales/id/common.json b/public/locales/id/common.json index 7db4838c..01e6f6fe 100644 --- a/public/locales/id/common.json +++ b/public/locales/id/common.json @@ -557,7 +557,7 @@ "sell": "Jual", "buyNow": "Buy now", "publicAndKnownBrokers": "Publik & Broker Terkenal", - "onSale": "Dijual dengan {{nativeCurrency}}", + "onSale": "Sedang dijual", "all-tokens": "Semua Token", "native-currency-only": "Hanya {{nativeCurrency}}", "mintedNew": "Latest", diff --git a/public/locales/ja/common.json b/public/locales/ja/common.json index 508cf82c..60c43c5f 100644 --- a/public/locales/ja/common.json +++ b/public/locales/ja/common.json @@ -557,7 +557,7 @@ "sell": "売却", "buyNow": "今すぐ購入", "publicAndKnownBrokers": "パブリック & MP", - "onSale": "{{nativeCurrency}}で販売中", + "onSale": "販売中です", "all-tokens": "全トークン", "native-currency-only": "{{nativeCurrency}}のみ", "mintedNew": "新しい", diff --git a/public/locales/ko/common.json b/public/locales/ko/common.json index 066d027b..9bf33d04 100644 --- a/public/locales/ko/common.json +++ b/public/locales/ko/common.json @@ -557,7 +557,7 @@ "sell": "판매", "buyNow": "Buy now", "publicAndKnownBrokers": "공공 & MP", - "onSale": "{{nativeCurrency}}로 판매 중", + "onSale": "판매되고 있습니다", "all-tokens": "모든 토큰", "native-currency-only": "{{nativeCurrency}}만", "mintedNew": "최신", diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index de40767c..5442b00e 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -557,7 +557,7 @@ "sell": "Продажа", "buyNow": "Купить сейчас", "publicAndKnownBrokers": "Публичные и на MП", - "onSale": "На продаже за {{nativeCurrency}}", + "onSale": "На продаже", "all-tokens": "Все токены", "native-currency-only": "Только {{nativeCurrency}}", "mintedNew": "Новые",