|
| 1 | +import { cssObj } from '@fuel-ui/css'; |
| 2 | +import type { BaseProps } from '@fuel-ui/react'; |
| 3 | +import { Box, Card, Text } from '@fuel-ui/react'; |
| 4 | +import { bn } from 'fuels'; |
| 5 | +import { fromNow } from '~/systems/Core/utils/dayjs'; |
| 6 | + |
| 7 | +import type { TxItem } from '../../types'; |
| 8 | +import { TxTitle } from '../TxTitle/TxTitle'; |
| 9 | + |
| 10 | +type TxCardProps = BaseProps<{ |
| 11 | + tx: TxItem; |
| 12 | +}>; |
| 13 | + |
| 14 | +export function TxCard({ tx, css, ...props }: TxCardProps) { |
| 15 | + return ( |
| 16 | + <Card {...props} css={{ ...styles.root, ...css }}> |
| 17 | + <TxTitle |
| 18 | + type={tx.type} |
| 19 | + status={tx.status} |
| 20 | + txHash={tx.transaction.id} |
| 21 | + css={styles.title} |
| 22 | + /> |
| 23 | + <Box.VStack css={styles.body}> |
| 24 | + <Box.Flex justify="between"> |
| 25 | + <Text leftIcon="Users">4 accounts</Text> |
| 26 | + </Box.Flex> |
| 27 | + <Box.Flex justify="between" css={styles.row}> |
| 28 | + <Text leftIcon="Transfer">{tx.totalOperations} operations</Text> |
| 29 | + <Text leftIcon="ClockHour1" className="small"> |
| 30 | + {fromNow(tx.timestamp)} |
| 31 | + </Text> |
| 32 | + </Box.Flex> |
| 33 | + <Box.Flex justify="between" css={styles.row}> |
| 34 | + <Text leftIcon="Coins">{tx.totalAssets} assets</Text> |
| 35 | + <Text leftIcon="GasStation" className="small"> |
| 36 | + {bn(tx.gasUsed).format({ units: 3 })} ETH |
| 37 | + </Text> |
| 38 | + </Box.Flex> |
| 39 | + </Box.VStack> |
| 40 | + </Card> |
| 41 | + ); |
| 42 | +} |
| 43 | + |
| 44 | +const styles = { |
| 45 | + root: cssObj({ |
| 46 | + transition: 'all 0.2s ease-out', |
| 47 | + |
| 48 | + '&:hover': { |
| 49 | + borderColor: '$borderHover', |
| 50 | + }, |
| 51 | + }), |
| 52 | + title: cssObj({ |
| 53 | + py: '$4', |
| 54 | + px: '$4', |
| 55 | + }), |
| 56 | + body: cssObj({ |
| 57 | + borderTop: '1px solid $cardBorder', |
| 58 | + py: '$4', |
| 59 | + px: '$4', |
| 60 | + }), |
| 61 | + row: cssObj({ |
| 62 | + '.fuel_Text:first-of-type': { |
| 63 | + flex: 1, |
| 64 | + }, |
| 65 | + '.small, .fuel_Icon': { |
| 66 | + fontSize: '$sm', |
| 67 | + color: '$textMuted', |
| 68 | + }, |
| 69 | + }), |
| 70 | +}; |
0 commit comments