Skip to content

Commit

Permalink
Merge pull request #532 from liteflow-labs/feature/display-deleted-data
Browse files Browse the repository at this point in the history
Display deleted data
  • Loading branch information
antho1404 authored Jan 26, 2024
2 parents 50733b1 + 9a08f7d commit 8daa355
Show file tree
Hide file tree
Showing 28 changed files with 123 additions and 57 deletions.
2 changes: 2 additions & 0 deletions components/History/HistoryList.gql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ query FetchAssetHistory(
orderBy: DATE_DESC
first: $limit
offset: $offset
includeWhenAssetDeleted: YES
includeWhenCurrencyDeleted: YES
) {
pageInfo {
hasNextPage
Expand Down
6 changes: 4 additions & 2 deletions components/Link/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Link as ChakraLink, Flex, LinkProps } from '@chakra-ui/react'
import { Box, Link as ChakraLink, Flex, LinkProps } from '@chakra-ui/react'
import { HiOutlineExternalLink } from '@react-icons/all-files/hi/HiOutlineExternalLink'
import NextLink, { LinkProps as NextLinkProps } from 'next/link'
import { forwardRef } from 'react'

type IProps = Omit<LinkProps, 'href'> &
Omit<NextLinkProps, 'href'> & {
externalIcon?: boolean
condition?: boolean
} & (
| { isExternal: true; href: LinkProps['href'] }
| { isExternal?: false; href: NextLinkProps['href'] }
)

const Link = forwardRef<any, IProps>(function Link(props, ref) {
const { children, href, isExternal, externalIcon, ...rest } = props
const { children, href, isExternal, externalIcon, condition, ...rest } = props
if (condition === false) return <Box {...rest}>{children}</Box>
if (isExternal) {
return (
<ChakraLink
Expand Down
6 changes: 5 additions & 1 deletion layouts/navbar.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ query NavbarAccount($account: Address!, $lastNotification: Datetime!) {
address
name
image
notifications(filter: { createdAt: { greaterThan: $lastNotification } }) {
notifications(
filter: { createdAt: { greaterThan: $lastNotification } }
includeWhenCollectionDeleted: YES
includeWhenTradeDeleted: YES
) {
totalCount
}
}
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@magiclabs/wagmi-connector": "^1.1.5",
"@metamask/jazzicon": "^2.0.0",
"@nft/chat": "^0.2.0",
"@nft/webhook": "^1.0.0-beta.49",
"@nft/webhook": "^1.0.0-beta.51",
"@rainbow-me/rainbowkit": "^1.3.3",
"@react-icons/all-files": "^4.1.0",
"@uiw/react-markdown-preview": "^5.0.7",
Expand Down Expand Up @@ -63,7 +63,7 @@
"@graphql-codegen/typescript-react-apollo": "^4.1.0",
"@graphql-eslint/eslint-plugin": "^3.20.1",
"@next/bundle-analyzer": "^14.0.4",
"@nft/api-graphql": "^1.0.0-beta.49",
"@nft/api-graphql": "^1.0.0-beta.51",
"@types/nodemailer": "^6.4.14",
"@types/nprogress": "^0.2.3",
"@types/react": "^18.2.48",
Expand Down
2 changes: 2 additions & 0 deletions pages/checkout/[id].gql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ query Checkout($id: UUID!, $address: Address, $now: Datetime!) {
collectionAddress
tokenId
id
deletedAt
collection {
chainId
address
Expand Down Expand Up @@ -80,6 +81,7 @@ query Checkout($id: UUID!, $address: Address, $now: Datetime!) {
id
decimals
symbol
deletedAt
}
}
}
7 changes: 6 additions & 1 deletion pages/checkout/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ const CheckoutPage: NextPage<Props> = ({ now }) => {
await push(`/tokens/${asset.id}`)
}, [asset, toast, t, push])

if (offer === null || asset === null) {
if (
offer === null ||
asset === null ||
asset?.deletedAt ||
offer?.currency.deletedAt
) {
return <Error statusCode={404} />
}
return (
Expand Down
1 change: 1 addition & 0 deletions pages/collection/[chainId]/[id]/index.gql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ query FetchCollectionDetails($collectionAddress: Address!, $chainId: Int!) {
collection(address: $collectionAddress, chainId: $chainId) {
address
chainId
deletedAt
cover
image
name
Expand Down
3 changes: 2 additions & 1 deletion pages/collection/[chainId]/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ const CollectionPage: FC<Props> = ({ now }) => {

const { changeLimit } = usePaginate()

if (collection === null) return <Error statusCode={404} />
if (collection === null || collection?.deletedAt)
return <Error statusCode={404} />
return (
<LargeLayout>
<Head
Expand Down
1 change: 1 addition & 0 deletions pages/create/[chainId]/[collectionAddress].gql
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ query FetchAccountAndCollection(
address
name
standard
deletedAt
}
}
3 changes: 2 additions & 1 deletion pages/create/[chainId]/[collectionAddress].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ const CreatePage: NextPage = () => {
[push, t, toast],
)

if (collection === null) return <Error statusCode={404} />
if (collection === null || collection?.deletedAt)
return <Error statusCode={404} />
return (
<SmallLayout>
<Head
Expand Down
2 changes: 2 additions & 0 deletions pages/notification.gql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ query GetNotifications($address: Address!, $cursor: Cursor) {
first: 12
orderBy: CREATED_AT_DESC
after: $cursor
includeWhenCollectionDeleted: YES
includeWhenTradeDeleted: YES
) {
pageInfo {
hasNextPage
Expand Down
1 change: 1 addition & 0 deletions pages/tokens/[id]/bid.gql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ query BidOnAsset(
tokenId: $tokenId
) {
id
deletedAt
chainId
collectionAddress
tokenId
Expand Down
2 changes: 1 addition & 1 deletion pages/tokens/[id]/bid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const BidPage: NextPage<Props> = ({ now }) => {
await push(`/tokens/${assetId}`)
}, [toast, t, push, assetId])

if (asset === null) return <Error statusCode={404} />
if (asset === null || asset?.deletedAt) return <Error statusCode={404} />
return (
<SmallLayout>
<Head
Expand Down
1 change: 1 addition & 0 deletions pages/tokens/[id]/index.gql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ query FetchAsset(
tokenId: $tokenId
) {
id
deletedAt
tokenId
tokenUri
chainId
Expand Down
2 changes: 1 addition & 1 deletion pages/tokens/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const DetailPage: NextPage<Props> = ({ now: nowProp }) => {
[refresh, refreshAsset, toast],
)

if (asset === null) return <Error statusCode={404} />
if (asset === null || asset?.deletedAt) return <Error statusCode={404} />
return (
<LargeLayout>
<Head
Expand Down
1 change: 1 addition & 0 deletions pages/tokens/[id]/offer.gql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ query OfferForAsset(
tokenId: $tokenId
) {
id
deletedAt
chainId
collectionAddress
tokenId
Expand Down
2 changes: 1 addition & 1 deletion pages/tokens/[id]/offer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const OfferPage: NextPage<Props> = ({ now }) => {
await push(`/tokens/${assetId}`)
}, [toast, t, push, assetId])

if (asset === null) return <Error statusCode={404} />
if (asset === null || asset?.deletedAt) return <Error statusCode={404} />
return (
<SmallLayout>
<Head
Expand Down
3 changes: 3 additions & 0 deletions pages/users/[id]/bids/placed.gql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ query FetchUserBidsPlaced(
signature: { isNull: false }
makerAddress: { equalTo: $address }
}
includeWhenAssetDeleted: YES
includeWhenCurrencyDeleted: YES
) {
pageInfo {
hasNextPage
Expand Down Expand Up @@ -49,6 +51,7 @@ query FetchUserBidsPlaced(
name
image
imageMimetype
deletedAt
}
}
}
Expand Down
23 changes: 13 additions & 10 deletions pages/users/[id]/bids/placed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const BidPlacedPage: NextPage = () => {
<Flex
as={Link}
href={`/tokens/${item.asset.id}`}
condition={!item.asset.deletedAt} // disable link if asset is deleted
gap={3}
>
<Image
Expand Down Expand Up @@ -237,16 +238,18 @@ const BidPlacedPage: NextPage = () => {
</Text>
</CancelOfferButton>
) : (
<Button
as={Link}
href={`/tokens/${item.asset.id}/bid`}
variant="outline"
colorScheme="gray"
>
<Text as="span" isTruncated>
{t('user.bid-placed.actions.new')}
</Text>
</Button>
!item.asset.deletedAt && ( // only display new button if asset is not deleted
<Button
as={Link}
href={`/tokens/${item.asset.id}/bid`}
variant="outline"
colorScheme="gray"
>
<Text as="span" isTruncated>
{t('user.bid-placed.actions.new')}
</Text>
</Button>
)
)}
</>
)}
Expand Down
4 changes: 4 additions & 0 deletions pages/users/[id]/bids/received.gql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ query FetchUserBidsReceived(
makerAddress: { notEqualTo: $address }
asset: { ownerships: { some: { ownerAddress: { equalTo: $address } } } }
}
includeWhenAssetDeleted: YES
includeWhenCurrencyDeleted: YES
) {
pageInfo {
hasNextPage
Expand All @@ -43,6 +45,7 @@ query FetchUserBidsReceived(
id
decimals
symbol
deletedAt
}
asset {
id
Expand All @@ -52,6 +55,7 @@ query FetchUserBidsReceived(
name
image
imageMimetype
deletedAt
}
}
}
Expand Down
41 changes: 22 additions & 19 deletions pages/users/[id]/bids/received.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const BidReceivedPage: NextPage<Props> = ({ now }) => {
<Flex
as={Link}
href={`/tokens/${item.asset.id}`}
condition={!item.asset.deletedAt} // disable link if asset is deleted
gap={3}
>
<Image
Expand Down Expand Up @@ -223,25 +224,27 @@ const BidReceivedPage: NextPage<Props> = ({ now }) => {
</Td>
<Td>{dateFromNow(item.createdAt)}</Td>
<Td isNumeric>
{ownerLoggedIn && (
<AcceptOfferButton
offer={item}
title={t('user.bid-received.accept.title')}
variant="outline"
colorScheme="gray"
onAccepted={onAccepted}
onError={(e) =>
toast({
status: 'error',
title: formatError(e),
})
}
>
<Text as="span" isTruncated>
{t('user.bid-received.actions.accept')}
</Text>
</AcceptOfferButton>
)}
{ownerLoggedIn &&
!item.asset.deletedAt && // only display accept button if asset and currency are not deleted
!item.currency.deletedAt && (
<AcceptOfferButton
offer={item}
title={t('user.bid-received.accept.title')}
variant="outline"
colorScheme="gray"
onAccepted={onAccepted}
onError={(e) =>
toast({
status: 'error',
title: formatError(e),
})
}
>
<Text as="span" isTruncated>
{t('user.bid-received.actions.accept')}
</Text>
</AcceptOfferButton>
)}
</Td>
</Tr>
))}
Expand Down
Loading

0 comments on commit 8daa355

Please sign in to comment.