-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into sc-platform/issue-3087-display-object-ext
- Loading branch information
Showing
43 changed files
with
611 additions
and
352 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
apps/wallet-dashboard/app/(protected)/assets/[objectId]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
'use client'; | ||
|
||
import React, { useCallback } from 'react'; | ||
import { useParams } from 'next/navigation'; | ||
import { AssetCard, Button, RouteLink, SendAssetPopup } from '@/components'; | ||
import { isAssetTransferable, useGetObject } from '@iota/core'; | ||
import { usePopups } from '@/hooks'; | ||
import { useCurrentAccount } from '@iota/dapp-kit'; | ||
import { ASSETS_ROUTE } from '@/lib/constants/routes.constants'; | ||
|
||
const VisualAssetDetailPage = () => { | ||
const params = useParams(); | ||
const objectId = params.objectId as string; | ||
const { data: asset } = useGetObject(objectId); | ||
const activeAccount = useCurrentAccount(); | ||
|
||
const { openPopup, closePopup } = usePopups(); | ||
|
||
const showSendAssetPopup = useCallback(() => { | ||
if (asset?.data) { | ||
openPopup(<SendAssetPopup asset={asset?.data} onClose={closePopup} />); | ||
} | ||
}, [asset, openPopup, closePopup]); | ||
|
||
const assetIsTransferable = asset?.data ? isAssetTransferable(asset?.data) : false; | ||
|
||
return ( | ||
<div className="flex h-full w-full flex-col space-y-4 px-40"> | ||
<RouteLink path={ASSETS_ROUTE.path} title="Back" /> | ||
{asset?.data ? ( | ||
<AssetCard key={asset.data.objectId} asset={asset.data} /> | ||
) : ( | ||
<div className="flex justify-center p-20">Asset not found</div> | ||
)} | ||
{assetIsTransferable && activeAccount ? ( | ||
<Button onClick={showSendAssetPopup}>Send Asset</Button> | ||
) : null} | ||
</div> | ||
); | ||
}; | ||
|
||
export default VisualAssetDetailPage; |
50 changes: 0 additions & 50 deletions
50
apps/wallet-dashboard/app/(protected)/assets/everything-else/page.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,97 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
function AssetsDashboardPage(): JSX.Element { | ||
'use client'; | ||
|
||
import { AssetCard, VirtualList } from '@/components'; | ||
import { ASSETS_ROUTE } from '@/lib/constants/routes.constants'; | ||
import { Panel, Title, Chip } from '@iota/apps-ui-kit'; | ||
import { hasDisplayData, useGetOwnedObjects } from '@iota/core'; | ||
import { useCurrentAccount } from '@iota/dapp-kit'; | ||
import { IotaObjectData } from '@iota/iota-sdk/client'; | ||
import { useState } from 'react'; | ||
import { AssetCategory } from '@/lib/enums'; | ||
import Link from 'next/link'; | ||
|
||
const ASSET_CATEGORIES: { label: string; value: AssetCategory }[] = [ | ||
{ | ||
label: 'Visual', | ||
value: AssetCategory.Visual, | ||
}, | ||
{ | ||
label: 'Other', | ||
value: AssetCategory.Other, | ||
}, | ||
]; | ||
|
||
export default function AssetsDashboardPage(): React.JSX.Element { | ||
const [selectedCategory, setSelectedCategory] = useState<AssetCategory>(AssetCategory.Visual); | ||
|
||
const account = useCurrentAccount(); | ||
const { | ||
data: ownedObjects, | ||
fetchNextPage, | ||
hasNextPage, | ||
isFetchingNextPage, | ||
} = useGetOwnedObjects(account?.address); | ||
|
||
const [visual, nonVisual] = (() => { | ||
const visual: IotaObjectData[] = []; | ||
const nonVisual: IotaObjectData[] = []; | ||
|
||
ownedObjects?.pages | ||
.flatMap((page) => page.data) | ||
.filter((asset) => asset.data && asset.data.objectId) | ||
.forEach((asset) => { | ||
if (asset.data) { | ||
if (hasDisplayData(asset)) { | ||
visual.push(asset.data); | ||
} else { | ||
nonVisual.push(asset.data); | ||
} | ||
} | ||
}); | ||
|
||
return [visual, nonVisual]; | ||
})(); | ||
|
||
const categoryToAsset: Record<AssetCategory, IotaObjectData[]> = { | ||
[AssetCategory.Visual]: visual, | ||
[AssetCategory.Other]: nonVisual, | ||
}; | ||
|
||
const assetList = categoryToAsset[selectedCategory]; | ||
|
||
return ( | ||
<div className="flex items-center justify-center pt-12"> | ||
<h1>ASSETS</h1> | ||
</div> | ||
<Panel> | ||
<Title title="Assets" /> | ||
<div className="px-lg"> | ||
<div className="flex flex-row items-center justify-start gap-xs py-xs"> | ||
{ASSET_CATEGORIES.map((tab) => ( | ||
<Chip | ||
key={tab.label} | ||
label={tab.label} | ||
onClick={() => setSelectedCategory(tab.value)} | ||
selected={selectedCategory === tab.value} | ||
/> | ||
))} | ||
</div> | ||
|
||
<div className="max-h-[600px] overflow-auto py-sm"> | ||
<VirtualList | ||
items={assetList} | ||
hasNextPage={hasNextPage} | ||
isFetchingNextPage={isFetchingNextPage} | ||
fetchNextPage={fetchNextPage} | ||
estimateSize={() => 180} | ||
render={(asset) => ( | ||
<Link href={ASSETS_ROUTE.path + `/${asset.objectId}`}> | ||
<AssetCard asset={asset} /> | ||
</Link> | ||
)} | ||
/> | ||
</div> | ||
</div> | ||
</Panel> | ||
); | ||
} | ||
|
||
export default AssetsDashboardPage; |
54 changes: 0 additions & 54 deletions
54
apps/wallet-dashboard/app/(protected)/assets/visual-assets/page.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export enum AssetCategory { | ||
Visual = 'Visual', | ||
Other = 'Other', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.