forked from DA0-DA0/dao-dao-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PayEntityDisplay.tsx
61 lines (55 loc) · 1.66 KB
/
PayEntityDisplay.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {
ArrowRightAltRounded,
SubdirectoryArrowRightRounded,
} from '@mui/icons-material'
import clsx from 'clsx'
import { TokenAmountDisplay, useDetectWrap } from '@dao-dao/stateless'
import { PayEntityDisplayProps, PayEntityDisplayRowProps } from '@dao-dao/types'
import { convertMicroDenomToDenomWithDecimals } from '@dao-dao/utils'
export const PayEntityDisplay = ({
tokens,
className,
...props
}: PayEntityDisplayProps) => (
<div className={clsx(className, 'space-y-2')}>
{tokens.map((token) => (
<PayEntityDisplayRow
key={token.token.denomOrAddress}
token={token}
{...props}
/>
))}
</div>
)
const PayEntityDisplayRow = ({
token: { token, balance: amount },
recipient,
EntityDisplay,
}: PayEntityDisplayRowProps) => {
const { containerRef, childRef, wrapped } = useDetectWrap()
const Icon = wrapped ? SubdirectoryArrowRightRounded : ArrowRightAltRounded
return (
<div
className="flex min-w-0 flex-row flex-wrap items-stretch justify-between gap-x-3 gap-y-2"
ref={containerRef}
>
<TokenAmountDisplay
key={token.denomOrAddress}
amount={convertMicroDenomToDenomWithDecimals(amount, token.decimals)}
decimals={token.decimals}
iconUrl={token.imageUrl}
showFullAmount
symbol={token.symbol}
/>
<div
className="flex min-w-0 grow flex-row items-stretch gap-2 sm:gap-3"
ref={childRef}
>
<div className={clsx('flex flex-row items-center', wrapped && 'pl-1')}>
<Icon className="!h-6 !w-6 text-text-secondary" />
</div>
<EntityDisplay address={recipient} />
</div>
</div>
)
}