Skip to content

Commit

Permalink
Merge pull request #546 from liteflow-labs/fix/erc-1155-cart-case
Browse files Browse the repository at this point in the history
Fix / ERC1155 token card fixed price sale cases
  • Loading branch information
antho1404 authored Jan 31, 2024
2 parents 8daa355 + 67fe1c8 commit 28e4ddf
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 4 deletions.
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

0 comments on commit 28e4ddf

Please sign in to comment.