Skip to content

Commit 2029869

Browse files
[Dashboard] Add status filter to transactions table (#7497)
1 parent 02f6f87 commit 2029869

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/analytics/tx-table/tx-table-ui.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ import type {
4646

4747
// TODO - add Status selector dropdown here
4848
export function TransactionsTableUI(props: {
49-
getData: (params: { page: number }) => Promise<TransactionsResponse>;
49+
getData: (params: {
50+
page: number;
51+
status: TransactionStatus | undefined;
52+
}) => Promise<TransactionsResponse>;
5053
project: Project;
5154
teamSlug: string;
5255
wallets?: Wallet[];
@@ -63,8 +66,8 @@ export function TransactionsTableUI(props: {
6366
const transactionsQuery = useQuery({
6467
enabled: !!props.wallets && props.wallets.length > 0,
6568
placeholderData: keepPreviousData,
66-
queryFn: () => props.getData({ page }),
67-
queryKey: ["transactions", props.project.id, page],
69+
queryFn: () => props.getData({ page, status }),
70+
queryKey: ["transactions", props.project.id, page, status],
6871
refetchInterval: autoUpdate ? 4_000 : false,
6972
});
7073

@@ -222,10 +225,6 @@ export const statusDetails = {
222225
name: "Queued",
223226
type: "warning",
224227
},
225-
REVERTED: {
226-
name: "Reverted",
227-
type: "destructive",
228-
},
229228
SUBMITTED: {
230229
name: "Submitted",
231230
type: "warning",

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/analytics/tx-table/tx-table.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { engineCloudProxy } from "@/actions/proxies";
55
import type { Project } from "@/api/projects";
66
import type { Wallet } from "../../server-wallets/wallet-table/types";
77
import { TransactionsTableUI } from "./tx-table-ui";
8-
import type { TransactionsResponse } from "./types";
8+
import type { TransactionStatus, TransactionsResponse } from "./types";
99

1010
export function TransactionsTable(props: {
1111
project: Project;
@@ -16,10 +16,11 @@ export function TransactionsTable(props: {
1616
return (
1717
<TransactionsTableUI
1818
client={props.client}
19-
getData={async ({ page }) => {
19+
getData={async ({ page, status }) => {
2020
return await getTransactions({
2121
page,
2222
project: props.project,
23+
status,
2324
});
2425
}}
2526
project={props.project}
@@ -32,23 +33,26 @@ export function TransactionsTable(props: {
3233
async function getTransactions({
3334
project,
3435
page,
36+
status,
3537
}: {
3638
project: Project;
3739
page: number;
40+
status: TransactionStatus | undefined;
3841
}) {
3942
const transactions = await engineCloudProxy<{ result: TransactionsResponse }>(
4043
{
41-
body: JSON.stringify({
42-
limit: 20,
43-
page,
44-
}),
4544
headers: {
4645
"Content-Type": "application/json",
4746
"x-client-id": project.publishableKey,
4847
"x-team-id": project.teamId,
4948
},
50-
method: "POST",
51-
pathname: "/v1/transactions/search",
49+
method: "GET",
50+
pathname: `/v1/transactions`,
51+
searchParams: {
52+
limit: "20",
53+
page: page.toString(),
54+
status: status ?? undefined,
55+
},
5256
},
5357
);
5458

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/analytics/tx-table/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ export type Transaction = {
8585
cancelledAt: Date | null;
8686
};
8787

88-
export type TransactionStatus =
89-
| "QUEUED"
90-
| "SUBMITTED"
91-
| "CONFIRMED"
92-
| "REVERTED"
93-
| "FAILED";
88+
export type TransactionStatus = "QUEUED" | "SUBMITTED" | "CONFIRMED" | "FAILED";
9489

9590
type Pagination = {
9691
totalCount: number;

0 commit comments

Comments
 (0)