@@ -75,13 +75,19 @@ await getAddressesCount()
7575const page = ref (route .query .page ? parseInt (route .query .page ) : 1 )
7676const pages = computed (() => Math .ceil (count .value / 20 ))
7777
78+ const sort = reactive ({
79+ by: " spendable" ,
80+ dir: " desc" ,
81+ })
82+
7883const getAddresses = async () => {
7984 isRefetching .value = true
8085
8186 const { data } = await fetchAddresses ({
8287 limit: 20 ,
8388 offset: (page .value - 1 ) * 20 ,
84- sort: " desc" ,
89+ sort: sort .dir ,
90+ sort_by: sort .by ,
8591 })
8692 addresses .value = data .value
8793
@@ -104,6 +110,23 @@ watch(
104110 },
105111)
106112
113+ const handleSort = (by ) => {
114+ switch (sort .dir ) {
115+ case " desc" :
116+ if (sort .by == by) sort .dir = " asc"
117+ break
118+
119+ case " asc" :
120+ sort .dir = " desc"
121+
122+ break
123+ }
124+
125+ sort .by = by
126+
127+ getAddresses ()
128+ }
129+
107130const handlePrev = () => {
108131 if (page .value === 1 ) return
109132
@@ -167,7 +190,18 @@ const handleLast = async () => {
167190 <thead >
168191 <tr >
169192 <th ><Text size =" 12" weight =" 600" color =" tertiary" noWrap >Hash</Text ></th >
170- <th ><Text size =" 12" weight =" 600" color =" tertiary" noWrap >Balance</Text ></th >
193+ <th @click =" handleSort('spendable')" :class =" $style.sortable" >
194+ <Flex align =" center" gap =" 6" >
195+ <Text size =" 12" weight =" 600" color =" tertiary" noWrap >Balance</Text >
196+ <Icon
197+ v-if =" sort.by === 'spendable'"
198+ name =" chevron"
199+ size =" 12"
200+ color =" secondary"
201+ :style =" { transform: `rotate(${sort.dir === 'asc' ? '180' : '0'}deg)` }"
202+ />
203+ </Flex >
204+ </th >
171205 <th ><Text size =" 12" weight =" 600" color =" tertiary" noWrap >First Height</Text ></th >
172206 <th ><Text size =" 12" weight =" 600" color =" tertiary" noWrap >Last Height</Text ></th >
173207 </tr >
0 commit comments