Skip to content

Commit

Permalink
Merge branch 'dev' into fix/collection-filters-chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
antho1404 authored Feb 5, 2024
2 parents 2442cce + 06740da commit ec3df4b
Show file tree
Hide file tree
Showing 76 changed files with 969 additions and 683 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.gql.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module.exports = {
root: true,
parser: '@graphql-eslint/eslint-plugin',
parserOptions: {
schema: 'node_modules/@nft/api-graphql/schema.graphql',
operations: '**/*.gql',
},
plugins: ['@graphql-eslint/eslint-plugin'],
extends: ['plugin:@graphql-eslint/operations-recommended'],
rules: {
Expand Down
2 changes: 2 additions & 0 deletions .graphqlrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: './node_modules/@nft/api-graphql/schema.graphql'
documents: '{components,hooks,pages}/**/*.{graphql,gql}'
4 changes: 0 additions & 4 deletions components/Cart/Step/Selection.gql
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ query FetchCartItems($offerIds: [UUID!]!) {
name
image
imageMimetype
unlockedContent {
url
mimetype
}
animationUrl
animationMimetype
}
Expand Down
4 changes: 2 additions & 2 deletions components/Cart/Step/Transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import useSigner from '../../../hooks/useSigner'
import ConnectButtonWithNetworkSwitch from '../../Button/ConnectWithNetworkSwitch'
import List, { ListItem } from '../../List/List'
import BatchPurchaseModal from '../../Modal/BatchPurchase'
import Price, { formatPrice } from '../../Price/Price'
import Price from '../../Price/Price'
import CartItemSummary from '../ItemSummary'

type Props = {
Expand Down Expand Up @@ -190,7 +190,7 @@ const CartStepTransaction: FC<Props> = ({
isLoading={approvalLoading[item.currency.id] || false}
>
{t('cart.step.transaction.button.approve', {
value: formatPrice(item.amount, item.currency),
value: item.currency.symbol,
})}
</ConnectButtonWithNetworkSwitch>
) : balances[item.currency.id] &&
Expand Down
24 changes: 9 additions & 15 deletions components/Filter/FilterBy/Trait.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ const FilterByTrait: FC<Props> = ({
notifyOnNetworkStatusChange: true,
})

const traitsData = data?.collection?.traitsOfCollection.nodes
const hasNextPage = data?.collection?.traitsOfCollection.pageInfo.hasNextPage
const traitsData = data?.collectionTraits?.nodes
const hasNextPage = data?.collectionTraits?.pageInfo.hasNextPage

const loadMore = useCallback(async () => {
const newOffset = offset + PAGINATION_LIMIT
Expand All @@ -76,22 +76,16 @@ const FilterByTrait: FC<Props> = ({
// Cannot use concatToQuery function because of nested cache
// Nested cache comes from the shape of FetchCollectionTraits query above
updateQuery: (prevResult, { fetchMoreResult }) => {
if (
!fetchMoreResult ||
!fetchMoreResult.collection?.traitsOfCollection
)
if (!fetchMoreResult || !fetchMoreResult.collectionTraits)
return prevResult
return {
...fetchMoreResult,
collection: {
...fetchMoreResult.collection,
traitsOfCollection: {
...fetchMoreResult.collection.traitsOfCollection,
nodes: [
...(prevResult?.collection?.traitsOfCollection.nodes || []),
...fetchMoreResult.collection.traitsOfCollection.nodes,
],
},
collectionTraits: {
...fetchMoreResult.collectionTraits,
nodes: [
...(prevResult?.collectionTraits?.nodes || []),
...fetchMoreResult.collectionTraits.nodes,
],
},
}
},
Expand Down
84 changes: 41 additions & 43 deletions components/History/HistoryList.gql
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,51 @@ query FetchAssetHistory(
$offset: Int!
$filter: [AssetHistoryAction!]
) {
asset(
chainId: $chainId
collectionAddress: $collectionAddress
tokenId: $tokenId
assetHistories(
filter: {
chainId: { equalTo: $chainId }
collectionAddress: { equalTo: $collectionAddress }
tokenId: { equalTo: $tokenId }
action: { in: $filter }
}
orderBy: DATE_DESC
first: $limit
offset: $offset
includeWhenAssetDeleted: YES
includeWhenCurrencyDeleted: YES
) {
chainId
collectionAddress
tokenId
histories(
filter: { action: { in: $filter } }
orderBy: DATE_DESC
first: $limit
offset: $offset
) {
pageInfo {
hasNextPage
hasPreviousPage
}
nodes {
action
date
unitPrice
quantity
fromAddress
from {
address
name
image
verification {
status
}
}
toAddress
to {
address
name
image
verification {
status
}
pageInfo {
hasNextPage
hasPreviousPage
}
nodes {
action
date
unitPrice
quantity
fromAddress
from {
address
name
image
verification {
status
}
transactionHash
currency {
decimals
symbol
}
toAddress
to {
address
name
image
verification {
status
}
}
transactionHash
currency {
decimals
symbol
}
}
}
}
10 changes: 4 additions & 6 deletions components/History/HistoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ const HistoryList: FC<IProps> = ({ chainId, collectionAddress, tokenId }) => {
filter,
},
})
const histories = historyData?.asset?.histories.nodes
const histories = historyData?.assetHistories?.nodes

const ListItem = (
history: NonNullable<
FetchAssetHistoryQuery['asset']
>['histories']['nodes'][0],
history: NonNullable<FetchAssetHistoryQuery['assetHistories']>['nodes'][0],
i: number,
) => {
switch (history.action) {
Expand Down Expand Up @@ -140,9 +138,9 @@ const HistoryList: FC<IProps> = ({ chainId, collectionAddress, tokenId }) => {
<Pagination
page={page}
onPageChange={setPage}
hasNextPage={historyData?.asset?.histories.pageInfo.hasNextPage}
hasNextPage={historyData?.assetHistories?.pageInfo.hasNextPage}
hasPreviousPage={
historyData?.asset?.histories.pageInfo.hasPreviousPage
historyData?.assetHistories?.pageInfo.hasPreviousPage
}
withoutLimit
withoutNumbers
Expand Down
60 changes: 23 additions & 37 deletions components/HomeSection/Assets.gql
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ query FetchDefaultAssetIds($limit: Int!) {
}
}

query FetchAssets(
$now: Datetime!
$limit: Int!
$assetIds: [String!]!
$address: Address
) {
query FetchAssets($limit: Int!, $assetIds: [String!]!, $address: Address) {
assets(
filter: { quantity: { greaterThan: "0" }, id: { in: $assetIds } }
first: $limit
Expand Down Expand Up @@ -49,42 +44,33 @@ query FetchAssets(
owned: ownership(ownerAddress: $address) {
quantity
}
bestBid: bids(
orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
first: 1
) {
nodes {
unitPrice
amount
currency {
image
name
id
decimals
symbol
}
bestBid {
unitPrice
amount
currency {
image
name
id
decimals
symbol
}
}
firstSale: sales(
first: 1
orderBy: [UNIT_PRICE_IN_REF_ASC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
) {
totalCount
totalCurrencyDistinctCount
nodes {
firstSale {
id
unitPrice
currency {
image
name
id
unitPrice
currency {
image
name
id
decimals
symbol
}
decimals
symbol
}
maker {
address
}
}
totalSalesCount
totalSalesCurrencyDistinctCount
}
}
}
1 change: 0 additions & 1 deletion components/HomeSection/Assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const AssetsHomeSection: FC<Props> = ({ date }) => {

const assetsQuery = useFetchAssetsQuery({
variables: {
now: date,
limit: PAGINATION_LIMIT,
assetIds: assetIds || [],
address: address || '',
Expand Down
65 changes: 65 additions & 0 deletions components/HomeSection/Banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Box, Button, Flex, Heading, VStack } from '@chakra-ui/react'
import Link from '../../components/Link/Link'
import MarkdownViewer from '../../components/MarkdownViewer'
import useEnvironment from '../../hooks/useEnvironment'
import Image from '../Image/Image'
import Slider from '../Slider/Slider'

const BannerHomeSection = () => {
const { HOME_BANNERS } = useEnvironment()

if (!HOME_BANNERS.length || HOME_BANNERS.length === 0) return null
return (
<Flex as={HOME_BANNERS.length > 1 ? Slider : 'div'}>
{HOME_BANNERS.map((banner) => (
<Flex
key={banner.title}
position="relative"
alignItems="center"
h="500px"
flex="0 0 100%"
bg="gray.100"
>
<Image
src={banner.image}
alt={banner.title}
fill
sizes="(min-width: 80em) 1216px, 100vw"
objectFit="cover"
priority
/>
<Flex
flexDirection="column"
alignItems="flex-start"
gap={6}
zIndex={1}
px={{ base: 8, sm: 12, lg: 24 }}
color={banner.textColor}
>
<VStack alignItems="flex-start" spacing={1}>
<Heading variant="title">{banner.title}</Heading>
{banner.content && (
<Box>
<MarkdownViewer source={banner.content} noTruncate />
</Box>
)}
</VStack>
{banner.button && (
<Button
as={Link}
href={banner.button.href}
isExternal={banner.button.isExternal}
px={{ base: 4, sm: 6, md: 16 }}
mt={4}
>
{banner.button.text}
</Button>
)}
</Flex>
</Flex>
))}
</Flex>
)
}

export default BannerHomeSection
24 changes: 9 additions & 15 deletions components/HomeSection/Featured.gql
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,15 @@ query FetchFeaturedAssets(
}
}
}
bestBid: bids(
orderBy: [UNIT_PRICE_IN_REF_DESC, CREATED_AT_ASC]
filter: { expiredAt: { greaterThan: $now } }
first: 1
) {
nodes {
unitPrice
amount
currency {
image
name
id
decimals
symbol
}
bestBid {
unitPrice
amount
currency {
image
name
id
decimals
symbol
}
}
sales(
Expand Down
Loading

0 comments on commit ec3df4b

Please sign in to comment.