-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from HausDAO/feat/safe-token-balances
Add token balances on Safe cards
- Loading branch information
Showing
4 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
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
71 changes: 71 additions & 0 deletions
71
libs/moloch-v3-macro-ui/src/components/SafeCard/SafeBalancesTable.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,71 @@ | ||
import { useMemo } from 'react'; | ||
import { Column, Row } from 'react-table'; | ||
|
||
import { DaoTable } from '../DaohausTable'; | ||
import { Avatar } from '@daohaus/ui'; | ||
import { SafeToken } from './SafeCard.styles'; | ||
|
||
type TokenBalanceType = { | ||
tokenLogo?: string | null; | ||
tokenName: string; | ||
tokenSymbol: string; | ||
balance: number; | ||
}; | ||
|
||
type SafeBalancesTableProps = { | ||
balances: Array<TokenBalanceType>; | ||
}; | ||
|
||
export const SafeBalancesTable = ({ balances }: SafeBalancesTableProps) => { | ||
const columns = useMemo<Column<TokenBalanceType>[]>( | ||
() => [ | ||
{ | ||
Header: 'Asset', | ||
accessor: 'tokenName', | ||
Cell: ({ | ||
value, | ||
row, | ||
}: { | ||
value: string; | ||
row: Row<TokenBalanceType>; | ||
}) => { | ||
return ( | ||
<SafeToken> | ||
<div style={{ fontSize: '1rem' }}> | ||
<Avatar | ||
alt={value} | ||
size="md" | ||
src={row.original.tokenLogo || ''} | ||
fallback={row.original.tokenSymbol} | ||
/> | ||
</div> | ||
<span>{value}</span> | ||
</SafeToken> | ||
); | ||
}, | ||
}, | ||
{ | ||
Header: 'Balance', | ||
accessor: 'balance', | ||
Cell: ({ | ||
value, | ||
row, | ||
}: { | ||
value: number; | ||
row: Row<TokenBalanceType>; | ||
}) => { | ||
return <div>{`${value} ${row.original.tokenSymbol}`}</div>; | ||
}, | ||
}, | ||
], | ||
[balances] | ||
); | ||
|
||
return ( | ||
<DaoTable<TokenBalanceType> | ||
tableData={balances} | ||
columns={columns} | ||
sortableColumns={[]} | ||
/> | ||
); | ||
}; |
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