From b1d8b41236a5ef272d0fc8222d4a5f426aa82e8c Mon Sep 17 00:00:00 2001 From: pandablue0809 Date: Wed, 2 Jul 2025 07:22:12 +0900 Subject: [PATCH 1/3] add tokenSelector --- components/NftsComponent.js | 60 ++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/components/NftsComponent.js b/components/NftsComponent.js index a78acddd7..c40bce722 100644 --- a/components/NftsComponent.js +++ b/components/NftsComponent.js @@ -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,19 @@ 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 null + }) const controller = new AbortController() @@ -121,7 +135,7 @@ export default function NftsComponent({ const listTabList = [ { value: 'nfts', label: t('tabs.all') }, - { value: 'onSale', label: t('tabs.onSale', { nativeCurrency }) } + { value: 'onSale', label: 'On sale for tokens' } ] let saleDestinationTabList = [] @@ -194,8 +208,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 +454,8 @@ export default function NftsComponent({ includeBurned, includeWithoutMediaData, mintedPeriod, - burnedPeriod + burnedPeriod, + selectedToken ]) useEffect(() => { @@ -519,6 +537,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 +589,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 +675,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' ? ' ' + 'On sale for tokens': '') + (listTab === 'onSale' && (saleDestinationTab === 'buyNow' || saleDestinationTab === 'public') ? ', ' + t('tabs.buyNow') : '') + @@ -708,7 +745,16 @@ export default function NftsComponent({ setTab={setSaleDestinationTab} name="saleDestination" /> - {saleCurrencyIssuer && saleCurrency && ( + {nftExplorer && ( +
+ {t('table.currency')} + +
+ )} + {!nftExplorer && saleCurrencyIssuer && saleCurrency && ( <> Date: Wed, 2 Jul 2025 07:34:41 +0900 Subject: [PATCH 2/3] set default currency --- components/NftsComponent.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/NftsComponent.js b/components/NftsComponent.js index 611047055..0d4d4d1c6 100644 --- a/components/NftsComponent.js +++ b/components/NftsComponent.js @@ -109,7 +109,9 @@ export default function NftsComponent({ currency: nativeCurrency } } - return null + return { + currency: nativeCurrency + } }) const controller = new AbortController() From 634640afb8110e3f11762744530353febfedf35e Mon Sep 17 00:00:00 2001 From: pandablue0809 Date: Fri, 11 Jul 2025 17:00:28 +0900 Subject: [PATCH 3/3] add tokenselector on nfts page --- components/NftsComponent.js | 40 ++++++++++------------------------- public/locales/de/common.json | 2 +- public/locales/en/common.json | 2 +- public/locales/es/common.json | 2 +- public/locales/fr/common.json | 2 +- public/locales/id/common.json | 2 +- public/locales/ja/common.json | 2 +- public/locales/ko/common.json | 2 +- public/locales/ru/common.json | 2 +- 9 files changed, 19 insertions(+), 37 deletions(-) diff --git a/components/NftsComponent.js b/components/NftsComponent.js index 0d4d4d1c6..d8b883587 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' @@ -137,7 +137,7 @@ export default function NftsComponent({ const listTabList = [ { value: 'nfts', label: t('tabs.all') }, - { value: 'onSale', label: 'On sale for tokens' } + { value: 'onSale', label: t('tabs.onSale') } ] let saleDestinationTabList = [] @@ -677,7 +677,7 @@ export default function NftsComponent({ (isValidTaxon(taxonQuery) ? ' ' + taxonQuery : '') + (ownerQuery ? ', ' + t('table.owner') + ': ' + ownerQuery : '') + (activeView === 'list' ? ' ' + t('tabs.list') : '') + - (listTab === 'onSale' ? ' ' + 'On sale for tokens': '') + + (listTab === 'onSale' ? ' ' + t('tabs.onSale') : '') + (listTab === 'onSale' && (saleDestinationTab === 'buyNow' || saleDestinationTab === 'public') ? ', ' + t('tabs.buyNow') : '') + @@ -746,32 +746,14 @@ export default function NftsComponent({ tab={saleDestinationTab} setTab={setSaleDestinationTab} name="saleDestination" - /> - {nftExplorer && ( -
- {t('table.currency')} - -
- )} - {!nftExplorer && saleCurrencyIssuer && saleCurrency && ( - <> - - - - )} + /> +
+ {t('table.currency')} + +
)} {nftExplorer && ( diff --git a/public/locales/de/common.json b/public/locales/de/common.json index 2cb5d9ec3..2fd3b3e24 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": "Zum Verkauf für Tokens", "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 582e80961..1f16bc1e6 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": "On sale for tokens", "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 1814ebb8b..81b97a465 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": "En venta por tokens", "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 41434403f..9b562e3f4 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": "En vente pour tokens", "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 7db4838ca..0051fe8b9 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": "Dijual dengan tokens", "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 508cf82c4..c84eaf0dd 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 066d027b7..3832e620f 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 de40767c1..22124a407 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": "Новые",