|
1 | | -import { ResponsiveSearchParamsProvider } from "responsive-rsc"; |
| 1 | +"use client"; |
| 2 | +import { useQuery } from "@tanstack/react-query"; |
| 3 | +import { Spinner } from "@workspace/ui/components/spinner"; |
2 | 4 | import type { ThirdwebClient } from "thirdweb"; |
3 | 5 | import type { Project } from "@/api/project/projects"; |
4 | 6 | import { UnifiedTransactionsTable } from "../components/transactions-table.client"; |
| 7 | +import { getTransactionAnalyticsSummary } from "../lib/analytics-summary.client"; |
5 | 8 | import type { Wallet } from "../server-wallets/wallet-table/types"; |
6 | | -import { TransactionAnalyticsFilter } from "./filter"; |
7 | | -import { TransactionsChartCard } from "./tx-chart/tx-chart"; |
| 9 | +import type { SolanaWallet } from "../solana-wallets/wallet-table/types"; |
| 10 | +import { EngineChecklist } from "./ftux.client"; |
| 11 | +import { TransactionAnalyticsSummary } from "./summary"; |
| 12 | +import { TransactionsAnalytics } from "./tx-chart/tx-chart"; |
8 | 13 |
|
9 | 14 | export function TransactionsAnalyticsPageContent(props: { |
10 | | - searchParams: { |
11 | | - from?: string | undefined | string[]; |
12 | | - to?: string | undefined | string[]; |
13 | | - interval?: string | undefined | string[]; |
14 | | - }; |
15 | 15 | project: Project; |
16 | 16 | showAnalytics: boolean; |
17 | | - wallets?: Wallet[]; |
| 17 | + wallets: Wallet[]; |
18 | 18 | teamSlug: string; |
19 | 19 | client: ThirdwebClient; |
| 20 | + authToken: string; |
| 21 | + teamId: string; |
| 22 | + isManagedVault: boolean; |
| 23 | + testTxWithWallet: string | undefined; |
| 24 | + testSolanaTxWithWallet: string | undefined; |
| 25 | + solanaWallets: SolanaWallet[]; |
20 | 26 | }) { |
21 | | - return ( |
22 | | - <ResponsiveSearchParamsProvider value={props.searchParams}> |
23 | | - <div className="flex grow flex-col gap-6"> |
24 | | - {props.showAnalytics && ( |
25 | | - <> |
26 | | - <div className="flex justify-end"> |
27 | | - <TransactionAnalyticsFilter /> |
28 | | - </div> |
29 | | - <TransactionsChartCard |
30 | | - project={props.project} |
31 | | - searchParams={props.searchParams} |
32 | | - teamSlug={props.teamSlug} |
33 | | - wallets={props.wallets ?? []} |
34 | | - /> |
35 | | - </> |
36 | | - )} |
37 | | - <UnifiedTransactionsTable |
38 | | - client={props.client} |
39 | | - project={props.project} |
40 | | - teamSlug={props.teamSlug} |
41 | | - /> |
| 27 | + const engineTxSummaryQuery = useQuery({ |
| 28 | + queryKey: [ |
| 29 | + "engine-tx-analytics-summary", |
| 30 | + props.teamId, |
| 31 | + props.project.publishableKey, |
| 32 | + props.authToken, |
| 33 | + ], |
| 34 | + queryFn: async () => { |
| 35 | + const data = await getTransactionAnalyticsSummary({ |
| 36 | + clientId: props.project.publishableKey, |
| 37 | + teamId: props.teamId, |
| 38 | + authToken: props.authToken, |
| 39 | + }); |
| 40 | + return data; |
| 41 | + }, |
| 42 | + refetchOnWindowFocus: false, |
| 43 | + refetchOnMount: false, |
| 44 | + }); |
| 45 | + |
| 46 | + if (engineTxSummaryQuery.isPending) { |
| 47 | + return ( |
| 48 | + <div className="flex h-[642px] grow items-center justify-center bg-card rounded-xl border"> |
| 49 | + <Spinner className="size-10" /> |
42 | 50 | </div> |
43 | | - </ResponsiveSearchParamsProvider> |
| 51 | + ); |
| 52 | + } |
| 53 | + |
| 54 | + const hasTransactions = engineTxSummaryQuery.data |
| 55 | + ? engineTxSummaryQuery.data.totalCount > 0 |
| 56 | + : false; |
| 57 | + |
| 58 | + return ( |
| 59 | + <div className="flex grow flex-col gap-10"> |
| 60 | + <EngineChecklist |
| 61 | + isManagedVault={props.isManagedVault} |
| 62 | + client={props.client} |
| 63 | + hasTransactions={hasTransactions} |
| 64 | + project={props.project} |
| 65 | + teamSlug={props.teamSlug} |
| 66 | + testTxWithWallet={props.testTxWithWallet} |
| 67 | + testSolanaTxWithWallet={props.testSolanaTxWithWallet} |
| 68 | + wallets={props.wallets} |
| 69 | + solanaWallets={props.solanaWallets} |
| 70 | + /> |
| 71 | + |
| 72 | + {props.showAnalytics && hasTransactions && ( |
| 73 | + <div className="flex flex-col gap-6"> |
| 74 | + <TransactionAnalyticsSummary |
| 75 | + clientId={props.project.publishableKey} |
| 76 | + teamId={props.project.teamId} |
| 77 | + initialData={engineTxSummaryQuery.data} |
| 78 | + /> |
| 79 | + <TransactionsAnalytics |
| 80 | + project={props.project} |
| 81 | + authToken={props.authToken} |
| 82 | + teamSlug={props.teamSlug} |
| 83 | + wallets={props.wallets ?? []} |
| 84 | + /> |
| 85 | + </div> |
| 86 | + )} |
| 87 | + |
| 88 | + <UnifiedTransactionsTable |
| 89 | + client={props.client} |
| 90 | + project={props.project} |
| 91 | + teamSlug={props.teamSlug} |
| 92 | + /> |
| 93 | + </div> |
44 | 94 | ); |
45 | 95 | } |
0 commit comments