diff --git a/packages/wallet/frontend/src/pages/transactions.tsx b/packages/wallet/frontend/src/pages/transactions.tsx index 9f88d427e..7d9c0eeb1 100644 --- a/packages/wallet/frontend/src/pages/transactions.tsx +++ b/packages/wallet/frontend/src/pages/transactions.tsx @@ -13,7 +13,11 @@ import { } from '@/lib/hooks/useTransactions' import { Table } from '@/ui/Table' import { Badge, getStatusBadgeIntent } from '@/ui/Badge' -import { formatAmount, formatDate } from '@/utils/helpers' +import { + formatAmount, + formatDateNoTime, + formatDateOnlyTime +} from '@/utils/helpers' import { useRedirect } from '@/lib/hooks/useRedirect' import { Button } from '@/ui/Button' import { cx } from 'class-variance-authority' @@ -26,6 +30,7 @@ import { TooltipProvider, TooltipTrigger } from '@/ui/Tooltip' +import { Card } from '@/components/icons/CardButtons' type WalletAddressSelectOption = SelectOption & { accountId: string @@ -124,6 +129,8 @@ const TransactionsPage: NextPageWithLayout = ({ ) + let groupByDate = '' + return (
@@ -258,12 +265,11 @@ const TransactionsPage: NextPageWithLayout = ({ = ({ /> {transactions.results.length ? ( - transactions.results.map((trx) => ( - - {trx.accountName} - - {trx.walletAddressUrl && trx.walletAddressPublicName ? ( - - - - {trx.walletAddressPublicName} - - e.preventDefault()} - > - {trx.walletAddressUrl} - - - - ) : ( - <>{trx.walletAddressUrl ?? ''} - )} - - - {trx.description ? ( - trx.description - ) : ( -

No description

- )} -
- - {trx.type === 'INCOMING' ? '+' : '-'} - { - formatAmount({ - value: String(trx.value) || '0', - assetCode: trx.assetCode, - assetScale: trx.assetScale - }).amount - } - - - - - - {formatDate({ date: trx.createdAt.toString() })} - -
- )) + transactions.results.map((trx) => { + let showDateHeader = false + if ( + groupByDate !== + formatDateNoTime({ date: trx.createdAt.toString() }) + ) { + groupByDate = formatDateNoTime({ + date: trx.createdAt.toString() + }) + showDateHeader = true + } + + return ( + <> + {showDateHeader ? ( + + + {groupByDate} + +   +   +   +   + + ) : null} + + + at{' '} + {formatDateOnlyTime({ date: trx.createdAt.toString() })} + + + +
+ {trx.isCard ? ( +
+ +
+ ) : null} +
+ {trx.secondParty ? ( + {trx.secondParty} + ) : null} + + {trx.description ? ( + trx.description + ) : ( +

+ No description +

+ )} +
+
+
+
+ + {trx.type === 'INCOMING' ? '+' : '-'} + { + formatAmount({ + value: String(trx.value) || '0', + assetCode: trx.assetCode, + assetScale: trx.assetScale + }).amount + } + + + + + +
+ + {trx.walletAddressUrl && + trx.walletAddressPublicName ? ( + + + + {trx.walletAddressPublicName} + + + e.preventDefault() + } + > + {trx.walletAddressUrl} + + + + ) : ( + <>{trx.walletAddressUrl ?? ''} + )} + + {trx.accountName} +
+
+
+ + ) + }) ) : ( diff --git a/packages/wallet/frontend/src/ui/Table.tsx b/packages/wallet/frontend/src/ui/Table.tsx index 25cfbf4d3..ab80d771b 100644 --- a/packages/wallet/frontend/src/ui/Table.tsx +++ b/packages/wallet/frontend/src/ui/Table.tsx @@ -104,7 +104,7 @@ type TCellProps = ComponentProps<'td'> & { const TCell = ({ children, className, ...props }: TCellProps) => { return ( -
) diff --git a/packages/wallet/frontend/src/utils/helpers.ts b/packages/wallet/frontend/src/utils/helpers.ts index c9afa425a..be609deaa 100644 --- a/packages/wallet/frontend/src/utils/helpers.ts +++ b/packages/wallet/frontend/src/utils/helpers.ts @@ -80,6 +80,26 @@ export const formatDate = ({ }) } +export const formatDateNoTime = ({ + date, + month = 'short' +}: FormatDateArgs): string => { + return new Date(date).toLocaleDateString('default', { + day: '2-digit', + month, + year: 'numeric' + }) +} + +export const formatDateOnlyTime = ({ + date, + time = true +}: FormatDateArgs): string => { + return new Date(date).toLocaleTimeString('default', { + ...(time && { hour: '2-digit', minute: '2-digit' }) + }) +} + export const getFee = (quote: QuoteResponse): FormattedAmount => { if (quote.fee) { return formatAmount({ diff --git a/packages/wallet/shared/src/types/transaction.ts b/packages/wallet/shared/src/types/transaction.ts index ae5b36eab..dc6edee2a 100644 --- a/packages/wallet/shared/src/types/transaction.ts +++ b/packages/wallet/shared/src/types/transaction.ts @@ -26,6 +26,7 @@ export interface TransactionResponse { secondParty?: string createdAt: Date updatedAt: Date + isCard?: boolean } interface TransactionListResponse extends TransactionResponse { assetScale: number
+ {children}