Skip to content

/nft-explorer new feature - search on sale for any token #438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 54 additions & 24 deletions components/NftsComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ 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'
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'
Expand Down Expand Up @@ -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()

Expand All @@ -121,7 +137,7 @@ export default function NftsComponent({

const listTabList = [
{ value: 'nfts', label: t('tabs.all') },
{ value: 'onSale', label: t('tabs.onSale', { nativeCurrency }) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of removing the usage of t('tabs.onSale') we need to update it in all languages.
we can just make it as "Listed".

t('tabs.onSale', { nativeCurrency }) will become t('tabs.onSale')

{ value: 'onSale', label: t('tabs.onSale') }
]

let saleDestinationTabList = []
Expand Down Expand Up @@ -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 + '&currency=' + saleCurrency + '&currencyIssuer=' + saleCurrencyIssuer
if (selectedToken?.currency) {
listUrlPart = listUrlPart + '&currency=' + selectedToken.currency
if (selectedToken.issuer) {
listUrlPart = listUrlPart + '&currencyIssuer=' + selectedToken.issuer
}
} else {
listUrlPart = listUrlPart + '&currency=' + nativeCurrency?.toLowerCase()
}
Expand Down Expand Up @@ -437,7 +456,8 @@ export default function NftsComponent({
includeBurned,
includeWithoutMediaData,
mintedPeriod,
burnedPeriod
burnedPeriod,
selectedToken
])

useEffect(() => {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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')
: '') +
Expand Down Expand Up @@ -707,23 +746,14 @@ export default function NftsComponent({
tab={saleDestinationTab}
setTab={setSaleDestinationTab}
name="saleDestination"
/>
{saleCurrencyIssuer && saleCurrency && (
<>
<FormInput
title={t('table.currency')}
defaultValue={niceCurrency(saleCurrency)}
disabled={true}
hideButton={true}
/>
<FormInput
title={t('table.currency-issuer')}
defaultValue={saleCurrencyIssuer}
disabled={true}
hideButton={true}
/>
</>
)}
/>
<div>
{t('table.currency')}
<TokenSelector
value={selectedToken}
onChange={setSelectedToken}
/>
</div>
</div>
)}
{nftExplorer && (
Expand Down
2 changes: 1 addition & 1 deletion public/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/id/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/ja/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@
"sell": "売却",
"buyNow": "今すぐ購入",
"publicAndKnownBrokers": "パブリック & MP",
"onSale": "{{nativeCurrency}}で販売中",
"onSale": "トークンで販売中",
"all-tokens": "全トークン",
"native-currency-only": "{{nativeCurrency}}のみ",
"mintedNew": "新しい",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/ko/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@
"sell": "판매",
"buyNow": "Buy now",
"publicAndKnownBrokers": "공공 & MP",
"onSale": "{{nativeCurrency}}로 판매 중",
"onSale": "토큰으로 판매 중",
"all-tokens": "모든 토큰",
"native-currency-only": "{{nativeCurrency}}만",
"mintedNew": "최신",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/ru/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@
"sell": "Продажа",
"buyNow": "Купить сейчас",
"publicAndKnownBrokers": "Публичные и на MП",
"onSale": "На продаже за {{nativeCurrency}}",
"onSale": "На продаже за токены",
"all-tokens": "Все токены",
"native-currency-only": "Только {{nativeCurrency}}",
"mintedNew": "Новые",
Expand Down