diff --git a/apps/ui-kit/src/lib/components/molecules/card/CardAction.tsx b/apps/ui-kit/src/lib/components/molecules/card/CardAction.tsx index 11f4769a09c..c811db7fa03 100644 --- a/apps/ui-kit/src/lib/components/molecules/card/CardAction.tsx +++ b/apps/ui-kit/src/lib/components/molecules/card/CardAction.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { ArrowRight, ArrowTopRight } from '@iota/ui-icons'; +import { ArrowRight } from '@iota/ui-icons'; import { Button, ButtonSize, ButtonType } from '@/components/atoms/button'; import { CardActionType } from './card.enums'; @@ -10,17 +10,22 @@ export type CardActionProps = { subtitle?: string; type: CardActionType; onClick?: () => void; - isExternalLink?: boolean; + icon?: React.ReactNode; }; -export function CardAction({ type, onClick, subtitle, title, isExternalLink }: CardActionProps) { +export function CardAction({ type, onClick, subtitle, title, icon }: CardActionProps) { + function handleActionClick(event: React.MouseEvent) { + event?.stopPropagation(); + onClick?.(); + } + if (type === CardActionType.Link) { return (
- {isExternalLink ? : } + {icon ? icon : }
); } @@ -48,7 +53,7 @@ export function CardAction({ type, onClick, subtitle, title, isExternalLink }: C type={ButtonType.Outlined} size={ButtonSize.Small} text={title} - onClick={onClick} + onClick={handleActionClick} /> ); diff --git a/apps/wallet/src/ui/app/pages/home/nfts/HiddenAsset.tsx b/apps/wallet/src/ui/app/pages/home/nfts/HiddenAsset.tsx new file mode 100644 index 00000000000..4651fc56e7a --- /dev/null +++ b/apps/wallet/src/ui/app/pages/home/nfts/HiddenAsset.tsx @@ -0,0 +1,99 @@ +// Copyright (c) Mysten Labs, Inc. +// Modifications Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { ErrorBoundary } from '_components'; +import { ampli } from '_src/shared/analytics/ampli'; +import { type IotaObjectData } from '@iota/iota-sdk/client'; +import { useNavigate } from 'react-router-dom'; +import { useHiddenAssets } from '../assets/HiddenAssetsProvider'; +import { + getKioskIdFromOwnerCap, + isKioskOwnerToken, + useGetNFTMeta, + useGetObject, + useKioskClient, +} from '@iota/core'; +import { + Card, + CardAction, + CardActionType, + CardBody, + CardImage, + CardType, + ImageShape, + ImageType, +} from '@iota/apps-ui-kit'; +import { formatAddress } from '@iota/iota-sdk/utils'; +import { useResolveVideo } from '_src/ui/app/hooks/useResolveVideo'; +import { VisibilityOff } from '@iota/ui-icons'; + +export interface HiddenAssetProps { + data: IotaObjectData | null | undefined; + display: + | { + [key: string]: string; + } + | null + | undefined; +} + +export default function HiddenAsset(item: HiddenAssetProps) { + const { showAsset } = useHiddenAssets(); + const kioskClient = useKioskClient(); + const navigate = useNavigate(); + const { objectId, type } = item.data!; + const { data: objectData } = useGetObject(objectId); + const { data: nftMeta } = useGetNFTMeta(objectId); + + const nftName = nftMeta?.name || formatAddress(objectId); + const nftImageUrl = nftMeta?.imageUrl || ''; + const video = useResolveVideo(objectData); + + function handleHiddenAssetClick() { + navigate( + isKioskOwnerToken(kioskClient.network, item.data) + ? `/kiosk?${new URLSearchParams({ + kioskId: getKioskIdFromOwnerCap(item.data!), + })}` + : `/nft-details?${new URLSearchParams({ + objectId, + }).toString()}`, + ); + ampli.clickedCollectibleCard({ + objectId, + collectibleType: type!, + }); + } + return ( + + + + {video ? ( + + + { + showAsset(objectId); + }} + icon={} + /> + + + ); +} diff --git a/apps/wallet/src/ui/app/pages/home/nfts/HiddenAssets.tsx b/apps/wallet/src/ui/app/pages/home/nfts/HiddenAssets.tsx index c547f71bc0c..abab72eadb2 100644 --- a/apps/wallet/src/ui/app/pages/home/nfts/HiddenAssets.tsx +++ b/apps/wallet/src/ui/app/pages/home/nfts/HiddenAssets.tsx @@ -2,76 +2,16 @@ // Modifications Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import { ErrorBoundary, NFTDisplayCard } from '_components'; -import { ampli } from '_src/shared/analytics/ampli'; -import { Button } from '_src/ui/app/shared/ButtonUI'; -import { EyeClose16 } from '@iota/icons'; -import { type IotaObjectData } from '@iota/iota-sdk/client'; -import { Link } from 'react-router-dom'; -import { useHiddenAssets } from '../assets/HiddenAssetsProvider'; -import { getKioskIdFromOwnerCap, isKioskOwnerToken, useKioskClient } from '@iota/core'; +import HiddenAsset, { type HiddenAssetProps } from './HiddenAsset'; interface HiddenAssetsProps { - items: { - data: IotaObjectData | null | undefined; - display: - | { - [key: string]: string; - } - | null - | undefined; - }[]; + items: HiddenAssetProps[]; } export default function HiddenAssets({ items }: HiddenAssetsProps) { - const { showAsset } = useHiddenAssets(); - const kioskClient = useKioskClient(); - return ( -
- {items?.map((object) => { - const { objectId, type } = object.data!; - return ( -
- { - ampli.clickedCollectibleCard({ - objectId, - collectibleType: type!, - }); - }} - className="relative truncate no-underline" - > - - - - -
-
-
- ); - })} +
+ {items?.map((object) => )}
); } diff --git a/apps/wallet/src/ui/app/pages/home/nfts/NonVisualAssets.tsx b/apps/wallet/src/ui/app/pages/home/nfts/NonVisualAssets.tsx index 191e512fec8..3b38a9665a3 100644 --- a/apps/wallet/src/ui/app/pages/home/nfts/NonVisualAssets.tsx +++ b/apps/wallet/src/ui/app/pages/home/nfts/NonVisualAssets.tsx @@ -6,6 +6,7 @@ import { ExplorerLink, ExplorerLinkType } from '_components'; import { type IotaObjectData } from '@iota/iota-sdk/client'; import { formatAddress, parseStructTag } from '@iota/iota-sdk/utils'; import { Card, CardAction, CardActionType, CardBody, CardType } from '@iota/apps-ui-kit'; +import { ArrowTopRight } from '@iota/ui-icons'; interface NonVisualAssetsProps { items: IotaObjectData[]; @@ -30,7 +31,10 @@ export default function NonVisualAssets({ items }: NonVisualAssetsProps) { title={formatAddress(item.objectId!)} subtitle={`${formatAddress(address)}::${module}::${name}`} /> - + } + /> ); diff --git a/apps/wallet/src/ui/app/pages/home/nfts/index.tsx b/apps/wallet/src/ui/app/pages/home/nfts/index.tsx index 92c0389d0f9..28bfcf32b28 100644 --- a/apps/wallet/src/ui/app/pages/home/nfts/index.tsx +++ b/apps/wallet/src/ui/app/pages/home/nfts/index.tsx @@ -133,25 +133,26 @@ function NftsPage() { return (
- {isAssetsLoaded && (filteredAssets.length || filteredHiddenAssets.length) && ( - - {ASSET_CATEGORIES.map(({ label, value }) => ( - setSelectedAssetCategory(value)} - label={label} - selected={selectedAssetCategory === value} - disabled={ - AssetCategory.Hidden === value - ? !hiddenAssetIds.length - : AssetCategory.Visual === value - ? !ownedAssets?.visual.length - : !ownedAssets?.other.length - } - /> - ))} - - )} + {isAssetsLoaded && + Boolean(filteredAssets.length || filteredHiddenAssets.length) && ( + + {ASSET_CATEGORIES.map(({ label, value }) => ( + setSelectedAssetCategory(value)} + label={label} + selected={selectedAssetCategory === value} + disabled={ + AssetCategory.Hidden === value + ? !hiddenAssetIds.length + : AssetCategory.Visual === value + ? !ownedAssets?.visual.length + : !ownedAssets?.other.length + } + /> + ))} + + )} {isError ? ( @@ -161,17 +162,19 @@ function NftsPage() { {(error as Error).message} ) : null} - {selectedAssetCategory === AssetCategory.Visual ? ( - - ) : selectedAssetCategory === AssetCategory.Other ? ( - - ) : selectedAssetCategory === AssetCategory.Hidden ? ( - - ) : ( -
- No Assets found -
- )} +
+ {selectedAssetCategory === AssetCategory.Visual ? ( + + ) : selectedAssetCategory === AssetCategory.Other ? ( + + ) : selectedAssetCategory === AssetCategory.Hidden ? ( + + ) : ( +
+ No Assets found +
+ )} +
{isSpinnerVisible ? ( diff --git a/apps/wallet/src/ui/app/shared/page-main-layout/PageMainLayout.tsx b/apps/wallet/src/ui/app/shared/page-main-layout/PageMainLayout.tsx index 162b4abbfe8..e26a09c18b9 100644 --- a/apps/wallet/src/ui/app/shared/page-main-layout/PageMainLayout.tsx +++ b/apps/wallet/src/ui/app/shared/page-main-layout/PageMainLayout.tsx @@ -62,7 +62,6 @@ export function PageMainLayout({ rightContent={topNavMenuEnabled ? : undefined} /> ) : null} -