diff --git a/src/features/transactions/pages/group-page.tsx b/src/features/transactions/pages/group-page.tsx
index f283d50c3..998ae6899 100644
--- a/src/features/transactions/pages/group-page.tsx
+++ b/src/features/transactions/pages/group-page.tsx
@@ -5,12 +5,118 @@ import { cn } from '@/features/common/utils'
import { isDefined } from '@/utils/is-defined'
import { useMemo } from 'react'
-type TransactionArrow = {
+type Arrow = {
from: number
to: number
direction: 'leftToRight' | 'rightToLeft' | 'toSelf'
}
+function VerticalBars({ verticalBars }: { verticalBars: (number | undefined)[] }) {
+ // The side vertical bars when there are nested items
+ return (verticalBars ?? [])
+ .filter(isDefined)
+ .map((b, i) => (
+
+ ))
+}
+
+function ConnectionToParent() {
+ // The connection between this transaction and the parent
+ return (
+
+ )
+}
+
+function TransactionName({ hasParent, name }: { hasParent: boolean; name: string }) {
+ return (
+
+ {name}
+
+ )
+}
+
+function ConnectionToSibbling() {
+ // The connection between this transaction and the next sibbling
+ return (
+
+ )
+}
+
+function ConnectionToChildren({ indentLevel }: { indentLevel: number | undefined }) {
+ // The connection between this transaction and the children
+ return (
+
+ )
+}
+
+function DisplayArrow({ arrow: transactionArrow }: { arrow: Arrow }) {
+ return (
+
+
+
+ {transactionArrow.direction === 'rightToLeft' &&
}
+
+ {transactionArrow.direction === 'leftToRight' &&
}
+
+
+
+ )
+}
+
+function DisplaySelfTransaction() {
+ return (
+
+
+
+ )
+}
+
type TransactionRowProps = {
transaction: Transaction
hasParent?: boolean
@@ -29,104 +135,26 @@ function TransactionRow({
indentLevel,
verticalBars,
}: TransactionRowProps) {
- const transactionArrow = useMemo(() => calcTransactionArrow(transaction, accounts), [accounts, transaction])
+ const arrow = useMemo(() => calcArrow(transaction, accounts), [accounts, transaction])
return (
<>
- {
- // The side vertical bars when there are nested items
- (verticalBars ?? []).filter(isDefined).map((b, i) => (
-
- ))
- }
+
- {
- // The connection between this transaction and the parent
- hasParent && (
-
- )
- }
-
- {transaction.name}
-
- {
- // The connection between this transaction and the next sibbling
- hasParent && hasNextSibbling && (
-
- )
- }
- {
- // The connection between this transaction and the children
- hasChildren && (
-
- )
- }
+ {hasParent &&
}
+
+ {hasParent && hasNextSibbling &&
}
+ {hasChildren &&
}
{accounts.map((_, index) => {
- if (index < transactionArrow.from || index > transactionArrow.to) return
- if (index === transactionArrow.from)
- return (
-
-
-
- {transactionArrow.direction === 'rightToLeft' &&
}
-
- {transactionArrow.direction === 'leftToRight' &&
}
-
-
-
- )
+ if (index < arrow.from || index > arrow.to) return
+ if (index === arrow.from && index === arrow.to) return
+ if (index === arrow.from) return
else return null
})}
@@ -214,7 +242,7 @@ export function GroupPage() {
return (
transaction.sender === a)
const toAccount = accounts.findIndex((a) => transaction.receiver === a)
const direction = fromAccount < toAccount ? 'leftToRight' : fromAccount > toAccount ? 'rightToLeft' : 'toSelf'