@@ -6,62 +6,61 @@ import {
66 TableHeader ,
77 TableRow ,
88} from '@/components/ui/table/table' ;
9- import { Fragment , useCallback , useEffect , useState , type FC } from 'react' ;
9+ import { Fragment , type FC } from 'react' ;
1010
11- import iconSort from '@/assets/lend/icon-sort.svg ' ;
11+ import { lendRequestStore } from '@/components/MoneyMarket/stores/lend-request.store ' ;
1212import { AmountRenderer } from '@/components/ui/amount-renderer' ;
1313import { Button } from '@/components/ui/button' ;
1414import { InfoButton } from '@/components/ui/info-button' ;
15- import {
16- OrderColumn ,
17- OrderType ,
18- type OrderSorting ,
19- } from '@/components/ui/table/table.types' ;
15+ import type { MoneyMarketPoolReserve } from '@sovryn/slayer-sdk' ;
2016import { Check , X } from 'lucide-react' ;
21- import type { LendAsset } from '../../LendAssetsList.types' ;
2217
2318type AssetsTableProps = {
24- assets : LendAsset [ ] ;
19+ assets : MoneyMarketPoolReserve [ ] ;
2520} ;
2621
2722export const AssetsTable : FC < AssetsTableProps > = ( { assets } ) => {
28- const [ sortDirection , setSortDirection ] = useState < OrderSorting > (
29- OrderType . ASC ,
30- ) ;
31- const [ sortedAssets , setSortedAssets ] = useState < LendAsset [ ] > ( assets ) ;
32- useEffect ( ( ) => {
33- setSortedAssets ( assets ) ;
34- } , [ assets ] ) ;
23+ // const [sortDirection, setSortDirection] = useState<OrderSorting>(
24+ // OrderType.ASC,
25+ // );
26+ // const [sortedAssets, setSortedAssets] =
27+ // useState<MoneyMarketPoolReserve[]>(assets);
28+ // useEffect(() => {
29+ // setSortedAssets(assets);
30+ // }, [assets]);
3531
36- const sortAssets = useCallback (
37- ( column : keyof LendAsset ) => {
38- const newSortDirection =
39- sortDirection === OrderType . ASC ? OrderType . DESC : OrderType . ASC ;
40- setSortDirection ( newSortDirection ) ;
32+ // const sortAssets = useCallback(
33+ // (column: keyof MoneyMarketPoolReserve ) => {
34+ // const newSortDirection =
35+ // sortDirection === OrderType.ASC ? OrderType.DESC : OrderType.ASC;
36+ // setSortDirection(newSortDirection);
4137
42- const sorted = [ ...sortedAssets ] . sort ( ( a , b ) => {
43- if ( column === OrderColumn . SYMBOL ) {
44- return newSortDirection === OrderType . ASC
45- ? a [ column ] . localeCompare ( b [ column ] )
46- : b [ column ] . localeCompare ( a [ column ] ) ;
47- } else if ( column === OrderColumn . BALANCE ) {
48- const balanceA = parseFloat ( a . balance . replace ( / , / g, '' ) ) ;
49- const balanceB = parseFloat ( b . balance . replace ( / , / g, '' ) ) ;
50- return newSortDirection === OrderType . ASC
51- ? balanceA - balanceB
52- : balanceB - balanceA ;
53- } else if ( column === OrderColumn . APY ) {
54- const apyA = parseFloat ( a . apy . replace ( '%' , '' ) ) ;
55- const apyB = parseFloat ( b . apy . replace ( '%' , '' ) ) ;
56- return newSortDirection === OrderType . ASC ? apyA - apyB : apyB - apyA ;
57- }
58- return 0 ;
59- } ) ;
38+ // // const sorted = [...sortedAssets].sort((a, b) => {
39+ // // if (column === OrderColumn.SYMBOL) {
40+ // // return newSortDirection === OrderType.ASC
41+ // // ? a[column].localeCompare(b[column])
42+ // // : b[column].localeCompare(a[column]);
43+ // / / } else if (column === OrderColumn.BALANCE) {
44+ // // const balanceA = parseFloat(a.balance.replace(/,/g, ''));
45+ // // const balanceB = parseFloat(b.balance.replace(/,/g, ''));
46+ // // return newSortDirection === OrderType.ASC
47+ // // ? balanceA - balanceB
48+ // // : balanceB - balanceA;
49+ // / / } else if (column === OrderColumn.APY) {
50+ // // const apyA = parseFloat(a.apy.replace('%', ''));
51+ // // const apyB = parseFloat(b.apy.replace('%', ''));
52+ // // return newSortDirection === OrderType.ASC ? apyA - apyB : apyB - apyA;
53+ // / / }
54+ // // return 0;
55+ // / / });
6056
61- setSortedAssets ( sorted ) ;
62- } ,
63- [ sortDirection ] ,
64- ) ;
57+ // // setSortedAssets(sorted);
58+ // },
59+ // [sortDirection],
60+ // );
61+
62+ const handleLending = ( reserve : MoneyMarketPoolReserve ) =>
63+ lendRequestStore . getState ( ) . setReserve ( reserve ) ;
6564
6665 return (
6766 < Table className = "w-full border-separate" >
@@ -70,7 +69,7 @@ export const AssetsTable: FC<AssetsTableProps> = ({ assets }) => {
7069 < TableHead >
7170 < div className = "flex items-center gap-2" >
7271 < span > Asset</ span >
73- { assets . some ( ( asset ) => asset . isSortable ) && (
72+ { /* { assets.some((asset) => asset.isSortable) && (
7473 <Button
7574 variant="ghost"
7675 className="p-0 cursor-pointer hover:opacity-80 dark:hover:bg-transparent"
@@ -79,13 +78,13 @@ export const AssetsTable: FC<AssetsTableProps> = ({ assets }) => {
7978 >
8079 <img src={iconSort} alt="Sort Icon" className="w-2 h-2.5" />
8180 </Button>
82- ) }
81+ )} */ }
8382 </ div >
8483 </ TableHead >
8584 < TableHead >
8685 < div className = "flex items-center gap-2" >
8786 < span > Wallet balance</ span >
88- { assets . some ( ( asset ) => asset . isSortable ) && (
87+ { /* { assets.some((asset) => asset.isSortable) && (
8988 <Button
9089 variant="ghost"
9190 className="p-0 cursor-pointer hover:opacity-80 dark:hover:bg-transparent"
@@ -94,7 +93,7 @@ export const AssetsTable: FC<AssetsTableProps> = ({ assets }) => {
9493 >
9594 <img src={iconSort} alt="Sort Icon" className="w-2 h-2.5" />
9695 </Button>
97- ) }
96+ )} */ }
9897 </ div >
9998 </ TableHead >
10099 < TableHead >
@@ -103,7 +102,7 @@ export const AssetsTable: FC<AssetsTableProps> = ({ assets }) => {
103102 APY
104103 < InfoButton content = "APY - The annual percentage yield (APY) is the real rate of return earned on an investment, taking into account the effect of compounding interest." />
105104 </ div >
106- { assets . some ( ( asset ) => asset . isSortable ) && (
105+ { /* { assets.some((asset) => asset.isSortable) && (
107106 <Button
108107 variant="ghost"
109108 className="p-0 cursor-pointer hover:opacity-80 dark:hover:bg-transparent"
@@ -112,7 +111,7 @@ export const AssetsTable: FC<AssetsTableProps> = ({ assets }) => {
112111 >
113112 <img src={iconSort} alt="Sort Icon" className="w-2 h-2.5" />
114113 </Button>
115- ) }
114+ )} */ }
116115 </ div >
117116 </ TableHead >
118117 < TableHead >
@@ -124,32 +123,34 @@ export const AssetsTable: FC<AssetsTableProps> = ({ assets }) => {
124123 </ TableRow >
125124 </ TableHeader >
126125 < TableBody >
127- { sortedAssets . map ( ( asset , index ) => (
128- < Fragment key = { asset . symbol } >
126+ { assets . map ( ( asset , index ) => (
127+ < Fragment key = { asset . id } >
129128 < TableRow className = "hover:bg-transparent" >
130129 < TableCell className = "border-neutral-800 border-y border-l rounded-tl-[1.25rem] rounded-bl-[1.25rem]" >
131130 < div className = "flex items-center min-w-24" >
132131 < img
133- src = { asset . icon }
134- alt = { asset . symbol }
132+ src = { asset . token . logoUrl }
133+ alt = { asset . token . symbol }
135134 className = "w-8 h-8"
136135 />
137136 < div className = "ml-2" >
138- < p className = "text-gray-50 font-medium" > { asset . symbol } </ p >
137+ < p className = "text-gray-50 font-medium" >
138+ { asset . token . symbol }
139+ </ p >
139140 </ div >
140141 </ div >
141142 </ TableCell >
142143 < TableCell className = "border-neutral-800 border-y" >
143- < AmountRenderer value = { asset . balance } />
144+ < AmountRenderer value = { 0 } />
144145 </ TableCell >
145146 < TableCell className = "border-neutral-800 border-y" >
146147 < div className = "flex items-center" >
147- < AmountRenderer value = { asset . apy } suffix = "%" />
148+ < AmountRenderer value = { 0 } suffix = "%" />
148149 </ div >
149150 </ TableCell >
150151 < TableCell className = "border-neutral-800 border-y" >
151152 < div className = "flex items-center" >
152- { asset . canBeCollateral ? (
153+ { asset . usageAsCollateralEnabled ? (
153154 < Check className = "text-emerald-500 w-4 h-4" />
154155 ) : (
155156 < X className = "text-red-500 w-4 h-4" />
@@ -158,7 +159,10 @@ export const AssetsTable: FC<AssetsTableProps> = ({ assets }) => {
158159 </ TableCell >
159160 < TableCell className = "border-neutral-800 border-y border-r rounded-tr-[1.25rem] rounded-br-[1.25rem]" >
160161 < div className = "flex items-center justify-end gap-4" >
161- < Button className = "rounded-full min-w-24 h-10 hover:cursor-pointer" >
162+ < Button
163+ className = "rounded-full min-w-24 h-10 hover:cursor-pointer"
164+ onClick = { ( ) => handleLending ( asset ) }
165+ >
162166 Lend
163167 </ Button >
164168 < Button
@@ -171,14 +175,14 @@ export const AssetsTable: FC<AssetsTableProps> = ({ assets }) => {
171175 </ TableCell >
172176 </ TableRow >
173177
174- { index !== sortedAssets . length - 1 && (
178+ { index !== assets . length - 1 && (
175179 < TableRow className = "h-1 hover:bg-transparent border-none" >
176180 < TableCell className = "p-0.5" colSpan = { 5 } > </ TableCell >
177181 </ TableRow >
178182 ) }
179183 </ Fragment >
180184 ) ) }
181- { sortedAssets . length === 0 && (
185+ { assets . length === 0 && (
182186 < TableRow >
183187 < TableCell colSpan = { 5 } className = "text-center py-4" >
184188 No assets found.
0 commit comments