Skip to content

Commit 75c74a3

Browse files
committed
feat: several unified market fixes (#1748)
* feat: several unified market fixes * feat: use the right rows number for desktop
1 parent 0342ebf commit 75c74a3

File tree

19 files changed

+218
-121
lines changed

19 files changed

+218
-121
lines changed

webapp/src/components/AssetPage/Collection/Collection.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import React from 'react'
22
import { Link } from 'react-router-dom'
3+
import { Stats } from 'decentraland-ui'
4+
import { Network } from '@dcl/schemas'
35
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
46
import { locations } from '../../../modules/routing/locations'
5-
import { Props } from './Collection.types'
7+
import { contracts } from '../../../modules/vendor/decentraland/contracts'
8+
import { config } from '../../../config'
9+
import { Network as AppNetwork } from '../../../modules/contract/types'
610
import CollectionImage from '../../CollectionImage'
7-
import { Stats } from 'decentraland-ui'
811
import CollectionProvider from '../../CollectionProvider'
12+
import { Props } from './Collection.types'
913
import styles from './Collection.module.css'
1014

15+
const network = config.get('NETWORK') as AppNetwork
16+
1117
const Collection = (props: Props) => {
1218
const { asset } = props
1319

@@ -18,14 +24,23 @@ const Collection = (props: Props) => {
1824
return null
1925
}
2026

27+
let name = collection.name
28+
if (asset.network === Network.ETHEREUM) {
29+
const networkContracts = contracts[network]
30+
const contract = networkContracts.find(
31+
contract => contract.address === asset.contractAddress
32+
)
33+
name = contract?.name || name
34+
}
35+
2136
return (
2237
<Stats title={t('global.collection')}>
2338
<Link to={locations.collection(asset.contractAddress)}>
2439
<div className={styles.container}>
2540
<div className={styles.image}>
2641
<CollectionImage contractAddress={asset.contractAddress} />
2742
</div>
28-
<span className={styles.name}>{collection.name}</span>
43+
<span className={styles.name}>{name}</span>
2944
</div>
3045
</Link>
3146
</Stats>

webapp/src/components/AssetPage/ListingsTable/ListingsTable.module.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@
3333

3434
.badgeContainer :global(.dcl.badge) {
3535
color: white;
36+
height: 18px;
3637
background-color: transparent !important;
3738
}
3839

3940
.badgeContainer {
4041
display: flex;
4142
flex-direction: row;
4243
gap: 10px;
44+
align-items: center;
4345
}
4446

4547
.ListingsTable .goToNFT {
@@ -49,7 +51,7 @@
4951

5052
.emptyTable {
5153
width: 100%;
52-
height: 350px;
54+
height: 398px;
5355
display: flex;
5456
flex-direction: column;
5557
align-items: center;
@@ -62,6 +64,7 @@
6264
display: flex;
6365
align-items: center;
6466
font-size: 14px;
67+
flex-wrap: wrap;
6568
}
6669

6770
.manaField :global(.ui.header:last-child) {
@@ -98,4 +101,8 @@
98101
.manaField {
99102
flex-wrap: wrap;
100103
}
104+
:global(.ui.small.inverted.button) {
105+
min-width: auto;
106+
border: none;
107+
}
101108
}

webapp/src/components/AssetPage/ListingsTable/ListingsTable.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { formatDataToTable } from './utils'
1212
import { Props } from './ListingsTable.types'
1313
import styles from './ListingsTable.module.css'
1414

15-
export const ROWS_PER_PAGE = 6
15+
export const ROWS_PER_PAGE = 5
1616
const INITIAL_PAGE = 1
1717

1818
const ListingsTable = (props: Props) => {
@@ -27,6 +27,7 @@ const ListingsTable = (props: Props) => {
2727

2828
// We're doing this outside of redux to avoid having to store all orders when we only care about the first ROWS_PER_PAGE
2929
useEffect(() => {
30+
let cancel = false
3031
if (asset) {
3132
setIsLoading(true)
3233

@@ -46,6 +47,7 @@ const ListingsTable = (props: Props) => {
4647
orderAPI
4748
.fetchOrders(params, sortBy)
4849
.then(response => {
50+
if (cancel) return
4951
setTotalPages(Math.ceil(response.total / ROWS_PER_PAGE) || 0)
5052
setOrders(
5153
formatDataToTable(
@@ -57,11 +59,14 @@ const ListingsTable = (props: Props) => {
5759
)
5860
setTotal(response.total)
5961
})
60-
.finally(() => setIsLoading(false))
62+
.finally(() => !cancel && setIsLoading(false))
6163
.catch(error => {
6264
console.error(error)
6365
})
6466
}
67+
return () => {
68+
cancel = true
69+
}
6570
}, [asset, setIsLoading, setOrders, sortBy, page, isMobileOrTablet])
6671

6772
return (

webapp/src/components/AssetPage/ListingsTable/utils.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ export const formatDataToTable = (
6767
</div>
6868
{order && (
6969
<div>
70-
{isMobile ? (
71-
<Icon name="chevron right" className={styles.gotToNFT} />
72-
) : (
73-
<Button
74-
inverted
75-
as={Link}
76-
to={locations.nft(order.contractAddress, order.tokenId)}
77-
size="small"
78-
>
79-
{t('listings_table.view_listing')}
80-
</Button>
81-
)}
70+
<Button
71+
inverted
72+
as={Link}
73+
to={locations.nft(order.contractAddress, order.tokenId)}
74+
size="small"
75+
>
76+
{isMobile ? (
77+
<Icon name="chevron right" className={styles.gotToNFT} />
78+
) : (
79+
t('listings_table.view_listing')
80+
)}
81+
</Button>
8282
</div>
8383
)}
8484
</div>

webapp/src/components/AssetPage/ListingsTableContainer/ListingsTableContainer.module.css

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717
padding-left: 20px;
1818
}
1919

20-
.tableContainer {
21-
display: flex;
22-
flex-direction: column;
23-
border: 2px solid var(--secondary);
24-
border-radius: 12px;
25-
margin-top: 48px;
20+
.listingsTableContainer :global(.filtertabsContainer) {
21+
height: 69px;
22+
}
23+
24+
.listingsTableContainer :global(.ui.basic.table tbody tr) {
25+
height: 65px;
26+
}
27+
28+
.listingsTableContainer :global(.dcl.mana.inline) {
29+
line-height: 20px;
2630
}
2731

2832
.sortByDropdown {

webapp/src/components/AssetPage/ListingsTableContainer/ListingsTableContainer.tsx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { OwnersTable } from '../OwnersTable'
77
import { ListingsTable } from '../ListingsTable'
88
import TableContainer from '../../Table/TableContainer'
99
import { Props, SortByType } from './ListingsTableContainer.types'
10+
import styles from './ListingsTableContainer.module.css'
1011

1112
const ListingsTableContainer = forwardRef<HTMLDivElement, Props>(
1213
(props, ref) => {
@@ -80,29 +81,31 @@ const ListingsTableContainer = forwardRef<HTMLDivElement, Props>(
8081
}, [BelowTabs.OWNERS, handleTabChange, locations.search])
8182

8283
return (
83-
<TableContainer
84-
children={
85-
belowTab === BelowTabs.LISTINGS.value ? (
86-
<ListingsTable asset={item} sortBy={sortBy as OrderSortBy} />
87-
) : (
88-
<OwnersTable
89-
asset={item}
90-
orderDirection={sortBy as OrderDirection}
91-
/>
92-
)
93-
}
94-
ref={ref}
95-
tabsList={[BelowTabs.LISTINGS, BelowTabs.OWNERS]}
96-
activeTab={belowTab}
97-
handleTabChange={(tab: string) => handleTabChange(tab)}
98-
sortbyList={
99-
belowTab === BelowTabs.LISTINGS.value
100-
? listingSortByOptions
101-
: ownerSortByOptions
102-
}
103-
handleSortByChange={(value: string) => setSortBy(value as SortByType)}
104-
sortBy={sortBy}
105-
/>
84+
<div className={styles.listingsTableContainer}>
85+
<TableContainer
86+
children={
87+
belowTab === BelowTabs.LISTINGS.value ? (
88+
<ListingsTable asset={item} sortBy={sortBy as OrderSortBy} />
89+
) : (
90+
<OwnersTable
91+
asset={item}
92+
orderDirection={sortBy as OrderDirection}
93+
/>
94+
)
95+
}
96+
ref={ref}
97+
tabsList={[BelowTabs.LISTINGS, BelowTabs.OWNERS]}
98+
activeTab={belowTab}
99+
handleTabChange={(tab: string) => handleTabChange(tab)}
100+
sortbyList={
101+
belowTab === BelowTabs.LISTINGS.value
102+
? listingSortByOptions
103+
: ownerSortByOptions
104+
}
105+
handleSortByChange={(value: string) => setSortBy(value as SortByType)}
106+
sortBy={sortBy}
107+
/>
108+
</div>
106109
)
107110
}
108111
)

webapp/src/components/AssetPage/OwnersTable/OwnersTable.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
.emptyTable {
3939
width: 100%;
40-
height: 350px;
40+
height: 448px;
4141
display: flex;
4242
flex-direction: column;
4343
align-items: center;

webapp/src/components/AssetPage/OwnersTable/OwnersTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { formatDataToTable } from './utils'
1313
import { OrderDirection, Props } from './OwnersTable.types'
1414
import styles from './OwnersTable.module.css'
1515

16-
export const ROWS_PER_PAGE = 6
16+
export const ROWS_PER_PAGE = 5
1717
const INITIAL_PAGE = 1
1818

1919
const OwnersTable = (props: Props) => {

webapp/src/components/AssetPage/RentalHistory/RentalHistory.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const RentalHistory = (props: Props) => {
2626

2727
// We're doing this outside of redux to avoid having to store all orders when we only care about the last open one
2828
useEffect(() => {
29+
let cancel = false
2930
if (asset) {
3031
rentalsAPI
3132
.getRentalListings({
@@ -36,15 +37,19 @@ const RentalHistory = (props: Props) => {
3637
page: (page - 1) * ROWS_PER_PAGE
3738
})
3839
.then(response => {
40+
if (cancel) return
3941
setTotal(response.total)
4042
setRentals(formatDataToTable(response.results))
4143
setTotalPages(Math.ceil(response.total / ROWS_PER_PAGE) | 0)
4244
})
43-
.finally(() => setIsLoading(false))
45+
.finally(() => !cancel && setIsLoading(false))
4446
.catch(error => {
4547
console.error(error)
4648
})
4749
}
50+
return () => {
51+
cancel = true
52+
}
4853
}, [asset, setIsLoading, setRentals, page])
4954

5055
return rentals.length > 0 ? (

webapp/src/components/AssetPage/Title/Title.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const Title = ({ asset }: Props) => {
1212
return (
1313
<div className={styles.title}>
1414
<span className={styles.text}>
15-
{getAssetName(asset)} {isNFT(asset) ? `#${asset.issuedId}` : ''}{' '}
15+
{getAssetName(asset)}{' '}
16+
{isNFT(asset) && asset.issuedId ? `#${asset.issuedId}` : ''}{' '}
1617
</span>
1718
{/* TODO (lists): this may be moved after the new detail page for unified markets */}
1819
{!isMobile && !isNFT(asset) && asset.network === Network.MATIC ? (

0 commit comments

Comments
 (0)