Skip to content

Commit

Permalink
fix(wallet-dashboard): other assets
Browse files Browse the repository at this point in the history
  • Loading branch information
cpl121 committed Dec 19, 2024
1 parent bd7d2c9 commit f62f401
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
19 changes: 10 additions & 9 deletions apps/wallet-dashboard/app/(protected)/assets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,22 @@ export default function AssetsDashboardPage(): React.JSX.Element {
const account = useCurrentAccount();
const { data, isFetching, fetchNextPage, hasNextPage, refetch } = useGetOwnedObjects(
account?.address,
undefined,
{
MatchNone: [{ StructType: '0x2::coin::Coin' }],
},
OBJECTS_PER_REQ,
);

const assets: IotaObjectData[] = [];
const visualAssets: IotaObjectData[] = [];
const otherAssets: IotaObjectData[] = [];

for (const page of data?.pages || []) {
for (const asset of page.data) {
if (asset.data && asset.data.objectId) {
if (selectedCategory == AssetCategory.Visual) {
if (hasDisplayData(asset)) {
assets.push(asset.data);
}
} else if (selectedCategory == AssetCategory.Other) {
assets.push(asset.data);
if (hasDisplayData(asset)) {
visualAssets.push(asset.data);
} else {
otherAssets.push(asset.data);
}
}
}
Expand All @@ -71,7 +72,7 @@ export default function AssetsDashboardPage(): React.JSX.Element {
</div>

<AssetList
assets={assets}
assets={selectedCategory == AssetCategory.Visual ? visualAssets : otherAssets}
selectedCategory={selectedCategory}
onClick={onAssetClick}
hasNextPage={hasNextPage}
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-dashboard/components/tiles/AssetTileLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function AssetTileLink({ asset, type, onClick }: AssetTileLinkProps): Rea
{type === AssetCategory.Visual ? (
<VisualAssetTile asset={asset} icon={<VisibilityOff />} onClick={handleClick} />
) : (
<NonVisualAssetCard asset={asset} onClick={handleClick} />
<NonVisualAssetCard asset={asset} />
)}
</>
);
Expand Down
24 changes: 14 additions & 10 deletions apps/wallet-dashboard/components/tiles/NonVisualAssetTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ import { Card, CardAction, CardActionType, CardBody, CardType } from '@iota/apps
import { IotaObjectData } from '@iota/iota-sdk/client';
import { formatAddress, parseStructTag } from '@iota/iota-sdk/utils';
import { ArrowTopRight } from '@iota/ui-icons';
import { ExplorerLink } from '../ExplorerLink';
import { ExplorerLinkType } from '@iota/core';

type NonVisualAssetCardProps = {
asset: IotaObjectData;
} & Pick<React.ComponentProps<typeof Card>, 'onClick'>;
} & React.ComponentProps<typeof Card>;

export function NonVisualAssetCard({ asset, onClick }: NonVisualAssetCardProps): React.JSX.Element {
export function NonVisualAssetCard({ asset }: NonVisualAssetCardProps): React.JSX.Element {
const { address, module, name } = parseStructTag(asset.type!);
return (
<Card type={CardType.Default} isHoverable onClick={onClick}>
<CardBody
title={formatAddress(asset.objectId!)}
subtitle={`${formatAddress(address)}::${module}::${name}`}
isTextTruncated
/>
<CardAction type={CardActionType.Link} icon={<ArrowTopRight />} />
</Card>
<ExplorerLink objectID={asset.objectId} type={ExplorerLinkType.Object}>
<Card type={CardType.Default} isHoverable>
<CardBody
title={formatAddress(asset.objectId!)}
subtitle={`${formatAddress(address)}::${module}::${name}`}
isTextTruncated
/>
<CardAction type={CardActionType.Link} icon={<ArrowTopRight />} />
</Card>
</ExplorerLink>
);
}

0 comments on commit f62f401

Please sign in to comment.