Skip to content
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

Fix / ERC1155 token card fixed price sale cases #546

Merged
merged 4 commits into from
Jan 31, 2024
Merged
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
3 changes: 3 additions & 0 deletions components/HomeSection/Assets.gql
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ query FetchAssets(
decimals
symbol
}
maker {
address
}
}
}
}
Expand Down
18 changes: 15 additions & 3 deletions components/Sales/Direct/CardFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Divider, Flex, HStack, Text } from '@chakra-ui/react'
import useTranslation from 'next-translate/useTranslation'
import { FC, useMemo } from 'react'
import useAccount from '../../../hooks/useAccount'
import { isSameAddress } from '../../../utils'
import AddToCartButton from '../../Button/AddToCart'
import Link from '../../Link/Link'
import Price from '../../Price/Price'
Expand All @@ -13,21 +15,31 @@ type Props = {
decimals: number
symbol: string
}
maker: {
address: string
}
}
numberOfSales: number
hasMultiCurrency: boolean
isOwner: boolean
showButton?: boolean
}

const SaleDirectCardFooter: FC<Props> = ({
sale,
numberOfSales,
hasMultiCurrency,
isOwner,
showButton = true,
}) => {
const { t } = useTranslation('components')
const { address } = useAccount()

// TODO: we should have a modal if there is more than one sale like we have on detail page
// issue is tracked on https://github.com/liteflow-labs/starter-kit/issues/529 for this modal improvement
const isOwner = useMemo(
() => (address ? isSameAddress(sale.maker.address, address) : false),
[address, sale.maker],
)

const chip = useMemo(() => {
switch (numberOfSales) {
case 0:
Expand Down Expand Up @@ -94,7 +106,7 @@ const SaleDirectCardFooter: FC<Props> = ({
: chip}
</Text>
</Flex>
{showButton && (
{showButton && address && (
<>
<Divider orientation="vertical" />
<AddToCartButton
Expand Down
4 changes: 3 additions & 1 deletion components/Token/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export type Props = {
decimals: number
symbol: string
}
maker: {
address: string
}
}[]
}
| undefined
Expand Down Expand Up @@ -107,7 +110,6 @@ const TokenCard: FC<Props> = ({ asset }) => {
sale={sale}
numberOfSales={numberOfSales}
hasMultiCurrency={hasMultiCurrency}
isOwner={isOwner}
showButton={isHovered}
/>
)
Expand Down
3 changes: 3 additions & 0 deletions pages/checkout/[id].gql
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ query Checkout($id: UUID!, $address: Address, $now: Datetime!) {
decimals
symbol
}
maker {
address
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions pages/collection/[chainId]/[id]/index.gql
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ query FetchCollectionAssets(
decimals
symbol
}
maker {
address
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions pages/explore/explore.gql
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ query FetchAllERC721And1155(
decimals
symbol
}
maker {
address
}
}
}
creator {
Expand Down
3 changes: 3 additions & 0 deletions pages/tokens/[id]/bid.gql
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ query BidOnAsset(
decimals
symbol
}
maker {
address
}
}
}
ownerships(first: 1) {
Expand Down
3 changes: 3 additions & 0 deletions pages/tokens/[id]/offer.gql
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ query OfferForAsset(
decimals
symbol
}
maker {
address
}
}
}
creator {
Expand Down
3 changes: 3 additions & 0 deletions pages/users/[id]/assetDetail.gql
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ fragment AssetDetail on Asset {
decimals
symbol
}
maker {
address
}
}
}
creator {
Expand Down
Loading