-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
368a2a7
commit ed0acac
Showing
51 changed files
with
2,651 additions
and
598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Transaction, TransactionType } from '@/features/transactions/models' | ||
import { TransactionsSummary } from '../models' | ||
|
||
export const asTransactionsSummary = (transactions: Pick<Transaction, 'type'>[]): TransactionsSummary => { | ||
return { | ||
count: transactions.length, | ||
countByType: Array.from( | ||
transactions | ||
.reduce((acc, transaction) => { | ||
const count = (acc.get(transaction.type) || 0) + 1 | ||
return new Map([...acc, [transaction.type, count]]) | ||
}, new Map<TransactionType, number>()) | ||
.entries() | ||
), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { TransactionType } from '@/features/transactions/models' | ||
|
||
export type TransactionsSummary = { | ||
count: number | ||
countByType: [TransactionType, number][] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Card, CardContent } from '@/features/common/components/card' | ||
import { Group } from '../models' | ||
import { cn } from '@/features/common/utils' | ||
import { DescriptionList } from '@/features/common/components/description-list' | ||
import { useMemo } from 'react' | ||
import { Badge } from '@/features/common/components/badge' | ||
import { dateFormatter } from '@/utils/format' | ||
import { BlockLink } from '@/features/blocks/components/block-link' | ||
import { GroupVisualTabs } from './group-visual-tabs' | ||
|
||
type Props = { | ||
group: Group | ||
} | ||
|
||
export const groupIdLabel = 'Group ID' | ||
export const blockLabel = 'Block' | ||
export const transactionsLabel = 'Transactions' | ||
export const timestampLabel = 'Timestamp' | ||
|
||
export function GroupDetails({ group }: Props) { | ||
const groupItems = useMemo( | ||
() => [ | ||
{ | ||
dt: groupIdLabel, | ||
dd: group.id, | ||
}, | ||
{ | ||
dt: blockLabel, | ||
dd: <BlockLink round={group.round} />, | ||
}, | ||
{ | ||
dt: transactionsLabel, | ||
dd: ( | ||
<> | ||
{group.transactionsSummary.count} | ||
{group.transactionsSummary.countByType.map(([type, count]) => ( | ||
<Badge key={type} variant="outline"> | ||
{type}={count} | ||
</Badge> | ||
))} | ||
</> | ||
), | ||
}, | ||
{ | ||
dt: timestampLabel, | ||
dd: dateFormatter.asLongDateTime(new Date(group.timestamp)), | ||
}, | ||
], | ||
[group.id, group.round, group.timestamp, group.transactionsSummary.count, group.transactionsSummary.countByType] | ||
) | ||
|
||
return ( | ||
<div className={cn('space-y-6 pt-7')}> | ||
<Card className={cn('p-4')}> | ||
<CardContent className={cn('text-sm space-y-2')}> | ||
<DescriptionList items={groupItems} /> | ||
</CardContent> | ||
</Card> | ||
<Card className={cn('p-4')}> | ||
<CardContent className={cn('text-sm space-y-2')}> | ||
<h1 className={cn('text-2xl text-primary font-bold')}>{transactionsLabel}</h1> | ||
</CardContent> | ||
<GroupVisualTabs group={group} /> | ||
</Card> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Round } from '@/features/blocks/data/types' | ||
import { cn } from '@/features/common/utils' | ||
import { TemplatedNavLink } from '@/features/routing/components/templated-nav-link/templated-nav-link' | ||
import { Urls } from '@/routes/urls' | ||
import { PropsWithChildren } from 'react' | ||
import { GroupId } from '../data/types' | ||
import { ellipseId } from '@/utils/ellipse-id' | ||
|
||
type Props = PropsWithChildren<{ | ||
round: Round | ||
groupId: GroupId | ||
short?: boolean | ||
className?: string | ||
}> | ||
|
||
export function GroupLink({ round, groupId, short = false, className, children }: Props) { | ||
return ( | ||
<TemplatedNavLink | ||
className={cn(!children && 'text-primary underline', className)} | ||
urlTemplate={Urls.Explore.Block.ById.Group.ById} | ||
urlParams={{ round: round.toString(), groupId: encodeURIComponent(groupId) }} | ||
> | ||
{children ? children : short ? ellipseId(groupId) : groupId} | ||
</TemplatedNavLink> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { cn } from '@/features/common/utils' | ||
import { OverflowAutoTabsContent, Tabs, TabsList, TabsTrigger } from '@/features/common/components/tabs' | ||
import { Group } from '../models' | ||
import { TransactionsGraph } from '@/features/transactions/components/transactions-graph' | ||
import { TransactionsTable } from '@/features/transactions/components/transactions-table' | ||
|
||
type Props = { | ||
group: Group | ||
} | ||
|
||
const graphTabId = 'graph' | ||
const tableTabId = 'table' | ||
export const groupVisual = 'View Group' | ||
export const groupVisualGraphLabel = 'Graph' | ||
export const groupVisualTableLabel = 'Table' | ||
|
||
export function GroupVisualTabs({ group }: Props) { | ||
return ( | ||
<Tabs defaultValue={graphTabId}> | ||
<TabsList aria-label={groupVisual}> | ||
<TabsTrigger className={cn('data-[state=active]:border-primary data-[state=active]:border-b-2 w-32')} value={graphTabId}> | ||
{groupVisualGraphLabel} | ||
</TabsTrigger> | ||
<TabsTrigger className={cn('data-[state=active]:border-primary data-[state=active]:border-b-2 w-32')} value={tableTabId}> | ||
{groupVisualTableLabel} | ||
</TabsTrigger> | ||
</TabsList> | ||
<OverflowAutoTabsContent value={graphTabId}> | ||
<TransactionsGraph transactions={group.transactions} /> | ||
</OverflowAutoTabsContent> | ||
<OverflowAutoTabsContent value={tableTabId}> | ||
<TransactionsTable transactions={group.transactions} /> | ||
</OverflowAutoTabsContent> | ||
</Tabs> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { atom } from 'jotai' | ||
import { GroupId, GroupResult } from './types' | ||
|
||
export const groupResultsAtom = atom<Map<GroupId, GroupResult>>(new Map()) |
Oops, something went wrong.