1- <script setup>
2- import { onMounted , computed } from ' vue' ;
1+ <script setup lang="ts" >
2+ import { onMounted , computed , ref , Ref } from ' vue' ;
33import { formatUnits } from ' @ethersproject/units' ;
44import { useBalances } from ' @/composables/useBalances' ;
5+ import { useNfts } from ' @/composables/useNfts' ;
56import space from ' @/helpers/space.json' ;
67import { _n , shorten , explorerUrl } from ' @/helpers/utils' ;
78import { ETH_CONTRACT } from ' @/helpers/constants' ;
9+ import type { Space } from ' @/types' ;
810
9- defineProps ({ space: Object });
11+ defineProps <{ space: Space }>();
12+
13+ const page: Ref <' tokens' | ' nfts' > = ref (' tokens' );
1014
1115const { loading, loaded, assets, loadBalances } = useBalances ();
16+ const { loading : nftsLoading, loaded : nftsLoaded, nfts, loadNfts } = useNfts ();
1217
1318const totalQuote = computed (() =>
1419 assets .value .reduce ((acc , asset ) => {
@@ -25,7 +30,10 @@ const sortedAssets = computed(() =>
2530 })
2631);
2732
28- onMounted (() => loadBalances (space .wallet ));
33+ onMounted (() => {
34+ loadBalances (space .wallet );
35+ loadNfts (space .wallet );
36+ });
2937 </script >
3038
3139<template >
@@ -44,7 +52,7 @@ onMounted(() => loadBalances(space.wallet));
4452 </div >
4553 <div class =" space-y-3" >
4654 <div >
47- <Label : label =" ' Treasury' " />
55+ <Label label =" Treasury" />
4856 <a
4957 :href =" explorerUrl('1', space.wallet)"
5058 target =" _blank"
@@ -60,31 +68,54 @@ onMounted(() => loadBalances(space.wallet));
6068 </a >
6169 </div >
6270 <div >
63- <Label :label =" 'Tokens'" />
64- <UiLoading v-if =" loading && !loaded" class =" px-4 py-3 block" />
65- <div
66- v-for =" (asset, i) in sortedAssets"
67- :key =" i"
68- class =" mx-4 py-3 border-b flex"
69- >
70- <div class =" flex-auto flex items-center" >
71- <Stamp :id =" asset.contract_address" type =" token" :size =" 32" />
72- <div class =" flex flex-col ml-3 leading-[20px]" >
71+ <div class =" flex pl-4" >
72+ <Link
73+ :is-active =" page === 'tokens'"
74+ text =" Tokens"
75+ class =" pr-3"
76+ @click =" page = 'tokens'"
77+ />
78+ <Link :is-active =" page === 'nfts'" text =" NFTs" @click =" page = 'nfts'" />
79+ </div >
80+ <div v-if =" page === 'tokens'" >
81+ <UiLoading v-if =" loading && !loaded" class =" px-4 py-3 block" />
82+ <div
83+ v-for =" (asset, i) in sortedAssets"
84+ :key =" i"
85+ class =" mx-4 py-3 border-b flex"
86+ >
87+ <div class =" flex-auto flex items-center" >
88+ <Stamp :id =" asset.contract_address" type =" token" :size =" 32" />
89+ <div class =" flex flex-col ml-3 leading-[20px]" >
90+ <div
91+ class =" text-skin-link"
92+ v-text =" shorten(asset.contract_ticker_symbol, 12)"
93+ />
94+ <div class =" text-sm" v-text =" shorten(asset.contract_name, 24)" />
95+ </div >
96+ </div >
97+ <div class =" flex-col items-end text-right leading-[20px]" >
7398 <div
7499 class =" text-skin-link"
75- v-text =" shorten(asset.contract_ticker_symbol, 12)"
100+ v-text ="
101+ _n(
102+ formatUnits(asset.balance || 0, asset.contract_decimals || 0)
103+ )
104+ "
76105 />
77- <div class =" text-sm" v-text =" shorten (asset.contract_name, 24) " />
106+ <div class =" text-sm" v-text =" `$${_n (asset.quote)}` " />
78107 </div >
79108 </div >
80- <div class =" flex-col items-end text-right leading-[20px]" >
81- <div
82- class =" text-skin-link"
83- v-text ="
84- _n(formatUnits(asset.balance || 0, asset.contract_decimals || 0))
85- "
86- />
87- <div class =" text-sm" v-text =" `$${_n(asset.quote)}`" />
109+ </div >
110+ <div v-else >
111+ <UiLoading v-if =" nftsLoading && !nftsLoaded" class =" px-4 py-3 block" />
112+ <div
113+ class =" grid gap-2 grid-cols-3 md:grid-cols-4 lg:grid-cols-6 py-3 px-2"
114+ >
115+ <div v-for =" (nft, i) in nfts" :key =" i" class =" block px-3 py-1 mb-3" >
116+ <NftPreview :item =" nft" class =" aspect-square rounded w-full" />
117+ <div class =" mt-2 text-sm truncate" >{{ nft.displayTitle }}</div >
118+ </div >
88119 </div >
89120 </div >
90121 </div >
0 commit comments