Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
f3d5fe08
Unverified
Commit
f3d5fe08
authored
Nov 16, 2022
by
aballerr
Committed by
GitHub
Nov 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: setting up a single buy state (#5206)
* setting up a single buy state
parent
247fbfdf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
86 deletions
+25
-86
CollectionAsset.tsx
src/nft/components/collection/CollectionAsset.tsx
+2
-6
AssetPriceDetails.tsx
src/nft/components/details/AssetPriceDetails.tsx
+23
-80
No files found.
src/nft/components/collection/CollectionAsset.tsx
View file @
f3d5fe08
...
@@ -51,14 +51,13 @@ export const CollectionAsset = ({
...
@@ -51,14 +51,13 @@ export const CollectionAsset = ({
const
setBagExpanded
=
useBag
((
state
)
=>
state
.
setBagExpanded
)
const
setBagExpanded
=
useBag
((
state
)
=>
state
.
setBagExpanded
)
const
trace
=
useTrace
({
page
:
PageName
.
NFT_COLLECTION_PAGE
})
const
trace
=
useTrace
({
page
:
PageName
.
NFT_COLLECTION_PAGE
})
const
{
erc1155TokenQuantity
,
isSelected
}
=
useMemo
(()
=>
{
const
{
isSelected
}
=
useMemo
(()
=>
{
const
matchingItems
=
itemsInBag
.
filter
(
const
matchingItems
=
itemsInBag
.
filter
(
(
item
)
=>
asset
.
tokenId
===
item
.
asset
.
tokenId
&&
asset
.
address
===
item
.
asset
.
address
(
item
)
=>
asset
.
tokenId
===
item
.
asset
.
tokenId
&&
asset
.
address
===
item
.
asset
.
address
)
)
const
erc1155TokenQuantity
=
matchingItems
.
filter
((
x
)
=>
x
.
asset
.
tokenType
===
TokenType
.
ERC1155
).
length
const
isSelected
=
matchingItems
.
length
>
0
const
isSelected
=
matchingItems
.
length
>
0
return
{
return
{
erc1155TokenQuantity
,
isSelected
,
isSelected
,
}
}
},
[
asset
,
itemsInBag
])
},
[
asset
,
itemsInBag
])
...
@@ -137,9 +136,6 @@ export const CollectionAsset = ({
...
@@ -137,9 +136,6 @@ export const CollectionAsset = ({
showInline
showInline
/>
/>
</
StyledContainer
>
</
StyledContainer
>
{
asset
.
tokenType
===
TokenType
.
ERC1155
&&
erc1155TokenQuantity
>
0
&&
(
<
Card
.
Erc1155Controls
quantity=
{
erc1155TokenQuantity
.
toString
()
}
/>
)
}
{
asset
.
rarity
&&
provider
&&
(
{
asset
.
rarity
&&
provider
&&
(
<
Card
.
Ranking
<
Card
.
Ranking
rarity=
{
asset
.
rarity
}
rarity=
{
asset
.
rarity
}
...
...
src/nft/components/details/AssetPriceDetails.tsx
View file @
f3d5fe08
...
@@ -2,9 +2,9 @@ import { useWeb3React } from '@web3-react/core'
...
@@ -2,9 +2,9 @@ import { useWeb3React } from '@web3-react/core'
import
{
OpacityHoverState
}
from
'
components/Common
'
import
{
OpacityHoverState
}
from
'
components/Common
'
import
{
useNftBalanceQuery
}
from
'
graphql/data/nft/NftBalance
'
import
{
useNftBalanceQuery
}
from
'
graphql/data/nft/NftBalance
'
import
useCopyClipboard
from
'
hooks/useCopyClipboard
'
import
useCopyClipboard
from
'
hooks/useCopyClipboard
'
import
{
CancelListingIcon
,
MinusIcon
,
PlusIcon
}
from
'
nft/components/icons
'
import
{
CancelListingIcon
}
from
'
nft/components/icons
'
import
{
useBag
,
useProfilePageState
,
useSellAsset
}
from
'
nft/hooks
'
import
{
useBag
,
useProfilePageState
,
useSellAsset
}
from
'
nft/hooks
'
import
{
CollectionInfoForAsset
,
GenieAsset
,
ProfilePageStateType
,
TokenType
,
WalletAsset
}
from
'
nft/types
'
import
{
CollectionInfoForAsset
,
GenieAsset
,
ProfilePageStateType
,
WalletAsset
}
from
'
nft/types
'
import
{
ethNumberStandardFormatter
,
formatEthPrice
,
getMarketplaceIcon
,
timeLeft
,
useUsdPrice
}
from
'
nft/utils
'
import
{
ethNumberStandardFormatter
,
formatEthPrice
,
getMarketplaceIcon
,
timeLeft
,
useUsdPrice
}
from
'
nft/utils
'
import
{
shortenAddress
}
from
'
nft/utils/address
'
import
{
shortenAddress
}
from
'
nft/utils/address
'
import
{
useMemo
}
from
'
react
'
import
{
useMemo
}
from
'
react
'
...
@@ -100,43 +100,10 @@ const BuyNowButtonContainer = styled.div`
...
@@ -100,43 +100,10 @@ const BuyNowButtonContainer = styled.div`
position: relative;
position: relative;
`
`
const
Erc1155BuyNowButton
=
styled
.
div
`
display: grid;
grid-template-columns: 1fr 1fr 1fr;
width: 100%;
background-color:
${({
theme
})
=>
theme
.
backgroundSurface
}
;
border:
${({
theme
})
=>
`1px solid
${
theme
.
backgroundOutline
}
`
}
;
border-radius: 12px;
margin-top: 12px;
text-align: center;
cursor: pointer;
justify-content: space-between;
overflow-x: hidden;
`
const
Tertiary
=
styled
(
ThemedText
.
BodySecondary
)
`
const
Tertiary
=
styled
(
ThemedText
.
BodySecondary
)
`
color:
${({
theme
})
=>
theme
.
textTertiary
}
;
color:
${({
theme
})
=>
theme
.
textTertiary
}
;
`
`
const
Erc1155BuyNowText
=
styled
.
div
`
display: flex;
width: 100%;
padding: 10px 12px;
justify-content: center;
cursor: default;
`
const
Erc1155ChangeButton
=
styled
(
Erc1155BuyNowText
)
<
{
remove
:
boolean
}
>
`
background-color:
${({
theme
,
remove
})
=>
(
remove
?
theme
.
accentFailureSoft
:
theme
.
accentActionSoft
)}
;
color:
${({
theme
,
remove
})
=>
(
remove
?
theme
.
accentFailure
:
theme
.
accentAction
)}
;
cursor: pointer;
${
hoverState
}
&:hover::after {
border-radius: 0px;
}
`
const
UploadLink
=
styled
.
a
`
const
UploadLink
=
styled
.
a
`
color:
${({
theme
})
=>
theme
.
textSecondary
}
;
color:
${({
theme
})
=>
theme
.
textSecondary
}
;
cursor: pointer;
cursor: pointer;
...
@@ -291,14 +258,10 @@ export const AssetPriceDetails = ({ asset, collection }: AssetPriceDetailsProps)
...
@@ -291,14 +258,10 @@ export const AssetPriceDetails = ({ asset, collection }: AssetPriceDetailsProps)
const
bagExpanded
=
useBag
((
s
)
=>
s
.
bagExpanded
)
const
bagExpanded
=
useBag
((
s
)
=>
s
.
bagExpanded
)
const
USDPrice
=
useUsdPrice
(
asset
)
const
USDPrice
=
useUsdPrice
(
asset
)
const
isErc1555
=
asset
.
tokenType
===
TokenType
.
ERC1155
const
[,
setCopied
]
=
useCopyClipboard
()
const
[,
setCopied
]
=
useCopyClipboard
()
const
{
quantity
,
assetInBag
}
=
useMemo
(()
=>
{
const
{
assetInBag
}
=
useMemo
(()
=>
{
return
{
return
{
quantity
:
itemsInBag
.
filter
(
(
x
)
=>
x
.
asset
.
tokenType
===
'
ERC1155
'
&&
x
.
asset
.
tokenId
===
asset
.
tokenId
&&
x
.
asset
.
address
===
asset
.
address
).
length
,
assetInBag
:
itemsInBag
.
some
(
assetInBag
:
itemsInBag
.
some
(
(
item
)
=>
asset
.
tokenId
===
item
.
asset
.
tokenId
&&
asset
.
address
===
item
.
asset
.
address
(
item
)
=>
asset
.
tokenId
===
item
.
asset
.
tokenId
&&
asset
.
address
===
item
.
asset
.
address
),
),
...
@@ -353,9 +316,10 @@ export const AssetPriceDetails = ({ asset, collection }: AssetPriceDetailsProps)
...
@@ -353,9 +316,10 @@ export const AssetPriceDetails = ({ asset, collection }: AssetPriceDetailsProps)
</
ThemedText
.
BodySecondary
>
</
ThemedText
.
BodySecondary
>
)
}
)
}
</
PriceRow
>
</
PriceRow
>
{
expirationDate
&&
<
Tertiary
fontSize=
"14px"
>
Sale ends:
{
timeLeft
(
expirationDate
)
}
</
Tertiary
>
}
{
expirationDate
&&
expirationDate
>
new
Date
()
&&
(
<
Tertiary
fontSize=
"14px"
>
Sale ends:
{
timeLeft
(
expirationDate
)
}
</
Tertiary
>
)
}
<
div
>
<
div
>
{
!
isErc1555
||
!
assetInBag
?
(
<
BuyNowButtonContainer
>
<
BuyNowButtonContainer
>
<
BuyNowButton
<
BuyNowButton
assetInBag=
{
assetInBag
}
assetInBag=
{
assetInBag
}
...
@@ -363,7 +327,7 @@ export const AssetPriceDetails = ({ asset, collection }: AssetPriceDetailsProps)
...
@@ -363,7 +327,7 @@ export const AssetPriceDetails = ({ asset, collection }: AssetPriceDetailsProps)
useAccentColor=
{
true
}
useAccentColor=
{
true
}
onClick=
{
()
=>
{
onClick=
{
()
=>
{
assetInBag
?
removeAssetsFromBag
([
asset
])
:
addAssetsToBag
([
asset
])
assetInBag
?
removeAssetsFromBag
([
asset
])
:
addAssetsToBag
([
asset
])
if
(
!
assetInBag
&&
!
isErc1555
&&
!
bagExpanded
)
{
if
(
!
assetInBag
&&
!
bagExpanded
)
{
toggleBag
()
toggleBag
()
}
}
}
}
}
}
...
@@ -373,27 +337,6 @@ export const AssetPriceDetails = ({ asset, collection }: AssetPriceDetailsProps)
...
@@ -373,27 +337,6 @@ export const AssetPriceDetails = ({ asset, collection }: AssetPriceDetailsProps)
</
SubHeader
>
</
SubHeader
>
</
BuyNowButton
>
</
BuyNowButton
>
</
BuyNowButtonContainer
>
</
BuyNowButtonContainer
>
)
:
(
<
Erc1155BuyNowButton
>
<
BuyNowButtonContainer
>
<
Erc1155ChangeButton
remove=
{
true
}
onClick=
{
()
=>
removeAssetsFromBag
([
asset
])
}
>
<
MinusIcon
width=
"20px"
height=
"20px"
/>
</
Erc1155ChangeButton
>
</
BuyNowButtonContainer
>
<
BuyNowButtonContainer
>
<
Erc1155BuyNowText
>
<
ThemedText
.
SubHeader
lineHeight=
"20px"
>
{
quantity
}
</
ThemedText
.
SubHeader
>
</
Erc1155BuyNowText
>
</
BuyNowButtonContainer
>
<
BuyNowButtonContainer
>
<
Erc1155ChangeButton
remove=
{
false
}
onClick=
{
()
=>
addAssetsToBag
([
asset
])
}
>
<
PlusIcon
width=
"20px"
height=
"20px"
/>
</
Erc1155ChangeButton
>
</
BuyNowButtonContainer
>
</
Erc1155BuyNowButton
>
)
}
</
div
>
</
div
>
</
BestPriceContainer
>
</
BestPriceContainer
>
)
:
(
)
:
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment