From ff49963555e0141cfabfdd904268ab351abedf7d Mon Sep 17 00:00:00 2001 From: Tymmmy <117268143+Tymmmy@users.noreply.github.com> Date: Wed, 11 Dec 2024 09:39:17 +0200 Subject: [PATCH 1/2] Add user name to transactions list and redesign list --- .../frontend/src/pages/transactions.tsx | 194 ++++++++++++------ packages/wallet/frontend/src/ui/Table.tsx | 2 +- packages/wallet/frontend/src/utils/helpers.ts | 20 ++ .../wallet/shared/src/types/transaction.ts | 1 + 4 files changed, 151 insertions(+), 66 deletions(-) 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 From f4d2062f9a7cf2f4846dd07e7fe7b6009c9cd21a Mon Sep 17 00:00:00 2001 From: Tymmmy <117268143+Tymmmy@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:32:22 +0200 Subject: [PATCH 2/2] redesign transactions --- .../wallet/frontend/src/components/Menu.tsx | 2 +- .../dialogs/TransactionDetailsDialog.tsx | 134 ++++++++++++++++++ .../frontend/src/pages/transactions.tsx | 36 +++-- packages/wallet/frontend/src/ui/Table.tsx | 4 + .../wallet/shared/src/types/transaction.ts | 2 +- 5 files changed, 168 insertions(+), 10 deletions(-) create mode 100644 packages/wallet/frontend/src/components/dialogs/TransactionDetailsDialog.tsx diff --git a/packages/wallet/frontend/src/components/Menu.tsx b/packages/wallet/frontend/src/components/Menu.tsx index 8a7e538eb..84de34f4b 100644 --- a/packages/wallet/frontend/src/components/Menu.tsx +++ b/packages/wallet/frontend/src/components/Menu.tsx @@ -206,7 +206,7 @@ export const Menu = () => { leaveFrom="translate-x-0" leaveTo="translate-x-full" > - +
+ {children}
+
= ({ } } ]} + hideForMobile={['Status', 'Payment Pointer name']} /> {transactions.results.length ? ( @@ -308,19 +314,33 @@ const TransactionsPage: NextPageWithLayout = ({     -   -   + +   + + +   + ) : null} - + { + openDialog( + + ) + }} + > at{' '} {formatDateOnlyTime({ date: trx.createdAt.toString() })} -
- {trx.isCard ? ( + {trx.isCard && FEATURES_ENABLED ? (
@@ -366,14 +386,14 @@ const TransactionsPage: NextPageWithLayout = ({ }).amount } - + - +
{trx.walletAddressUrl && diff --git a/packages/wallet/frontend/src/ui/Table.tsx b/packages/wallet/frontend/src/ui/Table.tsx index ab80d771b..b8e0085a6 100644 --- a/packages/wallet/frontend/src/ui/Table.tsx +++ b/packages/wallet/frontend/src/ui/Table.tsx @@ -26,6 +26,7 @@ type THeadProps = ComponentProps<'thead'> & { thProps?: ComponentProps<'th'> trProps?: ComponentProps<'tr'> sort?: SortHeader[] + hideForMobile?: string[] } const THead = ({ @@ -33,6 +34,7 @@ const THead = ({ thProps, trProps, sort, + hideForMobile, className, ...props }: THeadProps) => { @@ -44,6 +46,8 @@ const THead = ({ key={col} className={cx( 'border-b border-green dark:border-pink-neon p-4 text-left font-bold', + hideForMobile?.find((item) => item === col) !== undefined && + 'hidden sm:table-cell', sort?.find((item) => item.header === col) !== undefined && 'cursor-pointer' )} diff --git a/packages/wallet/shared/src/types/transaction.ts b/packages/wallet/shared/src/types/transaction.ts index dc6edee2a..f49d2834f 100644 --- a/packages/wallet/shared/src/types/transaction.ts +++ b/packages/wallet/shared/src/types/transaction.ts @@ -28,7 +28,7 @@ export interface TransactionResponse { updatedAt: Date isCard?: boolean } -interface TransactionListResponse extends TransactionResponse { +export interface TransactionListResponse extends TransactionResponse { assetScale: number accountName: string walletAddressPublicName?: string