Skip to content

Commit 0caed08

Browse files
feat(frontend): account analytics api integration (#1312)
* feat(frontend): account analytics api integration * fix
1 parent 48bacf3 commit 0caed08

File tree

48 files changed

+1273
-1343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1273
-1343
lines changed

apps/api/src/services/v3/accounts/stats.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
import dayjs from 'dayjs';
2-
3-
import type {} from 'nb-schemas';
4-
import {
1+
import type {
2+
AccountBalanceStats,
53
AccountBalanceStatsReq,
4+
AccountFTStats,
65
AccountFTStatsReq,
6+
AccountNearStats,
77
AccountNearStatsReq,
8+
AccountStatsOverview,
89
AccountStatsOverviewReq,
910
AccountTxnsHeatmapReq,
10-
AccountTxnStatsReq,
11-
} from 'nb-schemas/dist/accounts/stats/request.js';
12-
import response, {
13-
AccountBalanceStats,
14-
AccountFTStats,
15-
AccountNearStats,
16-
AccountStatsOverview,
1711
AccountTxnStats,
18-
} from 'nb-schemas/dist/accounts/stats/response.js';
12+
AccountTxnStatsReq,
13+
} from 'nb-schemas';
14+
import response from 'nb-schemas/dist/accounts/stats/response.js';
1915

16+
import dayjs from '#libs/dayjs';
2017
import { dbBalance, dbBase, dbEvents } from '#libs/pgp';
2118
import { msToNsTime } from '#libs/utils';
2219
import { responseHandler } from '#middlewares/response';

apps/frontend/src/app/[lang]/address/[address]/[tab]/page.tsx

Lines changed: 0 additions & 96 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { BalanceChart } from '@/components/address/analytics/balance';
2+
import { ErrorSuspense } from '@/components/error-suspense';
3+
import { fetchBalanceStats } from '@/data/address/analytics';
4+
5+
type Props = PageProps<'/[lang]/address/[address]/analytics/balance'>;
6+
7+
const BalancePage = async ({ params }: Props) => {
8+
const { address } = await params;
9+
const balancePromise = fetchBalanceStats(address);
10+
11+
return (
12+
<ErrorSuspense fallback={<BalanceChart loading={true} />}>
13+
<BalanceChart balancePromise={balancePromise} />
14+
</ErrorSuspense>
15+
);
16+
};
17+
18+
export default BalancePage;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { ActiveLink } from '@/components/link';
2+
import { TabLink } from '@/components/tab-links';
3+
import { TabLinks } from '@/components/tab-links';
4+
import { Card, CardContent } from '@/ui/card';
5+
import { ScrollArea, ScrollBar } from '@/ui/scroll-area';
6+
7+
type Props = LayoutProps<'/[lang]/address/[address]/analytics'>;
8+
9+
const AnalyticsLayout = async ({ children, params }: Props) => {
10+
const { address } = await params;
11+
12+
return (
13+
<Card>
14+
<CardContent className="text-body-sm p-3">
15+
<ScrollArea className="mb-2 w-full whitespace-nowrap">
16+
<TabLinks>
17+
<TabLink asChild>
18+
<ActiveLink href={`/address/${address}/analytics`}>
19+
Overview
20+
</ActiveLink>
21+
</TabLink>
22+
<TabLink asChild>
23+
<ActiveLink href={`/address/${address}/analytics/balance`}>
24+
Balance
25+
</ActiveLink>
26+
</TabLink>
27+
<TabLink asChild>
28+
<ActiveLink href={`/address/${address}/analytics/txns`}>
29+
Transactions
30+
</ActiveLink>
31+
</TabLink>
32+
<TabLink asChild>
33+
<ActiveLink href={`/address/${address}/analytics/near`}>
34+
Near Transfers
35+
</ActiveLink>
36+
</TabLink>
37+
<TabLink asChild>
38+
<ActiveLink href={`/address/${address}/analytics/tokens`}>
39+
Token Transfers
40+
</ActiveLink>
41+
</TabLink>
42+
</TabLinks>
43+
<ScrollBar orientation="horizontal" />
44+
</ScrollArea>
45+
{children}
46+
</CardContent>
47+
</Card>
48+
);
49+
};
50+
51+
export default AnalyticsLayout;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { NearChart } from '@/components/address/analytics/near';
2+
import { ErrorSuspense } from '@/components/error-suspense';
3+
import { fetchNearStats } from '@/data/address/analytics';
4+
5+
type Props = PageProps<'/[lang]/address/[address]/analytics/near'>;
6+
7+
const NearPage = async ({ params }: Props) => {
8+
const { address } = await params;
9+
const nearPromise = fetchNearStats(address);
10+
11+
return (
12+
<ErrorSuspense fallback={<NearChart loading={true} />}>
13+
<NearChart nearPromise={nearPromise} />
14+
</ErrorSuspense>
15+
);
16+
};
17+
18+
export default NearPage;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Overview from '@/components/address/analytics/overview';
2+
import { ErrorSuspense } from '@/components/error-suspense';
3+
import { fetchStatsOverview, fetchTxnsHeatmap } from '@/data/address/analytics';
4+
5+
type Props = PageProps<'/[lang]/address/[address]/analytics'>;
6+
7+
const AnalyticsPage = async ({ params }: Props) => {
8+
const { address } = await params;
9+
const overviewPromise = fetchStatsOverview(address);
10+
const heatmapPromise = fetchTxnsHeatmap(address);
11+
12+
return (
13+
<ErrorSuspense fallback={<Overview loading />}>
14+
<Overview
15+
heatmapPromise={heatmapPromise}
16+
overviewPromise={overviewPromise}
17+
/>
18+
</ErrorSuspense>
19+
);
20+
};
21+
22+
export default AnalyticsPage;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { FTsChart } from '@/components/address/analytics/fts';
2+
import { ErrorSuspense } from '@/components/error-suspense';
3+
import { fetchFTStats } from '@/data/address/analytics';
4+
5+
type Props = PageProps<'/[lang]/address/[address]/analytics/tokens'>;
6+
7+
const FTsPage = async ({ params }: Props) => {
8+
const { address } = await params;
9+
const ftsPromise = fetchFTStats(address);
10+
11+
return (
12+
<ErrorSuspense fallback={<FTsChart loading={true} />}>
13+
<FTsChart ftsPromise={ftsPromise} />
14+
</ErrorSuspense>
15+
);
16+
};
17+
18+
export default FTsPage;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { TxnsChart } from '@/components/address/analytics/txns';
2+
import { ErrorSuspense } from '@/components/error-suspense';
3+
import { fetchTxnStats } from '@/data/address/analytics';
4+
5+
type Props = PageProps<'/[lang]/address/[address]/analytics/txns'>;
6+
7+
const TxnsPage = async ({ params }: Props) => {
8+
const { address } = await params;
9+
const txnsPromise = fetchTxnStats(address);
10+
11+
return (
12+
<ErrorSuspense fallback={<TxnsChart loading={true} />}>
13+
<TxnsChart txnsPromise={txnsPromise} />
14+
</ErrorSuspense>
15+
);
16+
};
17+
18+
export default TxnsPage;

apps/frontend/src/app/[lang]/address/[address]/assets/page.tsx

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { AccessKeys } from '@/components/address/keys';
2+
import { ErrorSuspense } from '@/components/error-suspense';
3+
import { fetchKeyCount, fetchKeys } from '@/data/address/keys';
4+
5+
type Props = PageProps<'/[lang]/address/[address]/keys'>;
6+
7+
const KeysPage = async ({ params, searchParams }: Props) => {
8+
const [{ address }, filters] = await Promise.all([params, searchParams]);
9+
const keysPromise = fetchKeys(address, filters);
10+
const keyCountPromise = fetchKeyCount(address);
11+
12+
return (
13+
<ErrorSuspense fallback={<AccessKeys loading />}>
14+
<AccessKeys keyCountPromise={keyCountPromise} keysPromise={keysPromise} />
15+
</ErrorSuspense>
16+
);
17+
};
18+
19+
export default KeysPage;

0 commit comments

Comments
 (0)