mars-v2-frontend/src/components/Earn/Lend/Table/Columns/useAvailableColumns.tsx
Bob van der Helm ccc4a42354
Full refactor tables (#556)
* 📈 Improve structure generic Table component

* ♻️ Update Borrow Table and overall structure of Table comp

* ♻️ Update Lend table

*  add loading state for lend table

* 🧪 Fix unit tests
2023-10-18 09:38:24 +02:00

41 lines
1.2 KiB
TypeScript

import { ColumnDef } from '@tanstack/react-table'
import { useMemo } from 'react'
import Apr, { APR_META } from 'components/Earn/Lend/Table/Columns/Apr'
import DepositCap, { DEPOSIT_CAP_META } from 'components/Earn/Lend/Table/Columns/DepositCap'
import Manage, { MANAGE_META } from 'components/Earn/Lend/Table/Columns/Manage'
import Name, { NAME_META } from 'components/Earn/Lend/Table/Columns/Name'
interface Props {
isLoading: boolean
}
export default function useAvailableColumns(props: Props) {
return useMemo<ColumnDef<LendingMarketTableData>[]>(() => {
return [
{
...NAME_META,
cell: ({ row }) => <Name asset={row.original.asset} />,
},
{
...APR_META,
cell: ({ row }) => (
<Apr
isLoading={props.isLoading}
borrowEnabled={row.original.borrowEnabled}
marketLiquidityRate={row.original.marketLiquidityRate}
/>
),
},
{
...DEPOSIT_CAP_META,
cell: ({ row }) => <DepositCap isLoading={props.isLoading} data={row.original} />,
},
{
...MANAGE_META,
cell: ({ row }) => <Manage isExpanded={row.getIsExpanded()} />,
},
]
}, [])
}