Skip to content

Commit 9761756

Browse files
committed
chore: wip - display group
1 parent 769c3ce commit 9761756

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

src/App.routes.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Urls } from './routes/urls'
44
import { evalTemplates } from './routes/templated-route'
55
import { TransactionPage } from './features/transactions/pages/transaction-page'
66
import { ExplorePage } from './features/explore/pages/explore-page'
7+
import { GroupPage } from './features/transactions/pages/group-page'
78

89
export const routes = evalTemplates([
910
{
@@ -33,6 +34,10 @@ export const routes = evalTemplates([
3334
template: Urls.Explore.Transaction.ById,
3435
element: <TransactionPage />,
3536
},
37+
{
38+
template: Urls.Explore.Group.ById,
39+
element: <GroupPage />,
40+
},
3641
],
3742
},
3843
{
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import { cn } from '@/features/common/utils'
12
import { TemplatedNavLink } from '@/features/routing/components/templated-nav-link/templated-nav-link'
23
import { Urls } from '@/routes/urls'
34

45
export function ExplorePage() {
56
return (
6-
<div>
7+
<div className={cn('grid')}>
78
<TemplatedNavLink
89
urlTemplate={Urls.Explore.Transaction.ById}
910
urlParams={{ transactionId: 'QOOBRVQMX4HW5QZ2EGLQDQCQTKRF3UP3JKDGKYPCXMI6AVV35KQA' }}
1011
>
1112
View sample transaction
1213
</TemplatedNavLink>
14+
<TemplatedNavLink urlTemplate={Urls.Explore.Group.ById} urlParams={{ groupId: 'foo' }}>
15+
View sample group
16+
</TemplatedNavLink>
1317
</div>
1418
)
1519
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { cn } from '@/features/common/utils'
2+
3+
type TransactionTrProps = {
4+
transaction: Transaction
5+
cellHeight?: number
6+
lineWidth?: number
7+
hasParent?: boolean
8+
hasNextSibbling?: boolean
9+
hasChildren?: boolean
10+
}
11+
function TransactionTr({ transaction, hasParent = false, hasNextSibbling = false, hasChildren = false }: TransactionTrProps) {
12+
return (
13+
<tr>
14+
<td className="p-0">
15+
<div className={cn(`relative h-10 p-0 flex items-center`, 'px-0')}>
16+
{hasParent && (
17+
<div className={cn('w-8', `border-primary border-l-2 border-b-2 rounded-bl-lg`, `h-[50%]`, `absolute top-0 left-0`)}></div>
18+
)}
19+
<div className={cn('inline ml-8')}>{transaction.name}</div>
20+
{hasParent && hasNextSibbling && (
21+
<div className={cn('w-8', 'border-primary border-l-2', 'h-[22px]', 'absolute top-[18px] left-0')}></div>
22+
)}
23+
{hasChildren && !hasParent && (
24+
<div
25+
className={cn(
26+
'w-8',
27+
`border-primary border-l-2 border-t-2 rounded-tl-lg`,
28+
`h-[calc(50%+2px)]`,
29+
`absolute top-[calc(50%-2px)] left-0`
30+
)}
31+
></div>
32+
)}
33+
{hasChildren && hasParent && (
34+
<div
35+
className={cn('w-2 ml-4', 'border-primary border-l-2 border-t-2 rounded-tl-lg', 'h-[22px]', 'absolute top-[18px] left-0')}
36+
></div>
37+
)}
38+
</div>
39+
{hasChildren && (
40+
<div className={cn('relative', hasParent ? 'pl-4' : '')}>
41+
{hasNextSibbling && <div className={cn(`border-primary border-l-2`, `h-full`, 'absolute top-0 left-0')}></div>}
42+
<table>
43+
{transaction.transactions?.map((childTransaction, index, arr) => (
44+
<TransactionTr
45+
transaction={childTransaction}
46+
hasChildren={childTransaction.transactions && childTransaction.transactions.length > 0}
47+
hasParent={true}
48+
hasNextSibbling={index < arr.length - 1}
49+
/>
50+
))}
51+
</table>
52+
</div>
53+
)}
54+
</td>
55+
<td></td>
56+
</tr>
57+
)
58+
}
59+
60+
export function GroupPage() {
61+
const group: Transaction = {
62+
name: '',
63+
transactions: [
64+
{ name: '7VSN...' },
65+
{
66+
name: 'NDQX...',
67+
transactions: [
68+
{ name: 'Inner 1' },
69+
{ name: 'Inner 2', transactions: [{ name: 'Inner 3' }, { name: 'Inner 5' }] },
70+
{ name: 'Inner 9' },
71+
{ name: 'Inner 4', transactions: [{ name: 'Inner 6' }, { name: 'Inner 7' }] },
72+
{ name: 'Inner 8' },
73+
],
74+
},
75+
],
76+
}
77+
78+
return (
79+
<table>
80+
{group.transactions?.map((transaction, index, arr) => (
81+
<TransactionTr
82+
transaction={transaction}
83+
hasChildren={transaction.transactions && transaction.transactions.length > 0}
84+
hasParent={false}
85+
hasNextSibbling={index < arr.length - 1}
86+
/>
87+
))}
88+
</table>
89+
)
90+
}
91+
92+
export type Transaction = {
93+
name: string
94+
transactions?: Transaction[]
95+
}

src/routes/urls.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type UrlParameterValue = `${string}:${string}`
44

55
export const UrlParams = {
66
TransactionId: 'transactionId:string',
7+
GroupId: 'groupId:string',
78
} as const satisfies Record<string, UrlParameterValue>
89

910
export const Urls = {
@@ -12,6 +13,9 @@ export const Urls = {
1213
Transaction: UrlTemplate`/transaction`.extend({
1314
ById: UrlTemplate`/${UrlParams.TransactionId}`,
1415
}),
16+
Group: UrlTemplate`/group`.extend({
17+
ById: UrlTemplate`/${UrlParams.GroupId}`,
18+
}),
1519
}),
1620
AppStudio: UrlTemplate`/app-studio`,
1721
}

0 commit comments

Comments
 (0)