1import { useMemo } from 'react';
2import cn from 'classnames';
3import { Box, Icon, Row } from '@tlon/indigo-react';
4import { RollerTransaction } from '@urbit/roller-api';
5import { format, fromUnixTime } from 'date-fns';
7import { useTimerStore } from 'store/timerStore';
9 TRANSACTION_STATUS_ICONS,
10 TRANSACTION_TYPE_ICONS,
11 TRANSACTION_TYPE_TITLES,
12} from 'lib/constants';
13import { abbreviateAddress } from 'lib/utils/address';
14import { titleize } from 'form/formatters';
15import LayerIndicator from 'components/L2/LayerIndicator';
16import { useExploreTxUrl } from 'lib/explorer';
18interface TransactionRowProps extends RollerTransaction {
23export const TransactionRow = ({
31}: TransactionRowProps) => {
32 const { nextRoll } = useTimerStore();
34 const label = useMemo(() => {
35 return TRANSACTION_TYPE_TITLES[type] || type;
38 const icon = useMemo(() => {
39 return <Icon icon={TRANSACTION_TYPE_ICONS[type] || 'Bug'} />;
42 const shortHash = useMemo(() => {
43 return hash ? abbreviateAddress(hash) : '';
46 const parsedDate = useMemo(() => {
51 return fromUnixTime(time / 1000);
54 const shortDate = useMemo(() => {
59 return format(parsedDate, 'MMMM dd');
62 const longDate = useMemo(() => {
67 return parsedDate.toISOString();
70 const statusBadge = useMemo(() => {
72 <div className={cn(['badge', status])}>
73 <span className={'icon-wrapper'}>
74 <Icon icon={TRANSACTION_STATUS_ICONS[status] || 'Bug'} />
77 {status === 'pending' && layer === 2 ? nextRoll : titleize(status)}
81 }, [nextRoll, status, layer]);
83 const txHash = useExploreTxUrl(hash);
86 <Box className={`transaction-row ${className}`}>
87 <Box className="icon">{icon}</Box>
88 <Box className="info">
89 <Row className="title-row">
90 <Box className="title">{label}</Box>
91 <Box className="status">{statusBadge}</Box>
93 <Row className="info-row">
94 <Box className="hash-container">
102 <Icon className="arrow" icon="ArrowEast" />
105 !!hash && <Box className="hash">{shortHash}</Box>
107 <LayerIndicator layer={layer} size={'sm'} />
109 <Box className="date" title={longDate}>
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list