Skip to content

Commit 6c3a8d3

Browse files
authored
Remove unused account usage API and interface (#7117)
1 parent a31ac0c commit 6c3a8d3

File tree

4 files changed

+9
-68
lines changed

4 files changed

+9
-68
lines changed

apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,6 @@ interface ConfirmEmailInput {
5353
confirmationToken: string;
5454
}
5555

56-
interface UsageStorage {
57-
sumFileSizeBytes: number;
58-
}
59-
60-
export interface UsageBillableByService {
61-
usage: {
62-
storage: UsageStorage;
63-
};
64-
limits: {
65-
storage: number;
66-
};
67-
rateLimits: {
68-
storage: number;
69-
rpc: number;
70-
};
71-
rateLimitedAt: {
72-
storage?: string;
73-
rpc?: string;
74-
};
75-
}
76-
7756
interface BillingProduct {
7857
name: string;
7958
id: string;

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/getAccountUsage.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/overview/components/Usage.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import type { TeamSubscription } from "@/api/team-subscription";
44
import type { RPCUsageDataItem } from "@/api/usage/rpc";
55
import { ThirdwebBarChart } from "@/components/blocks/charts/bar-chart";
66
import { Button } from "@/components/ui/button";
7-
import type {
8-
Account,
9-
UsageBillableByService,
10-
} from "@3rdweb-sdk/react/hooks/useApi";
7+
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
118
import { InAppWalletUsersChartCardUI } from "components/embedded-wallets/Analytics/InAppWalletUsersChartCard";
129
import { subMonths } from "date-fns";
1310
import Link from "next/link";
@@ -18,8 +15,6 @@ import { SponsoredTransactionsTable } from "./SponsoredTransactionsTable";
1815
import { UsageCard } from "./UsageCard";
1916

2017
type UsageProps = {
21-
// TODO - remove when we have all the data available from team
22-
usage: UsageBillableByService;
2318
subscriptions: TeamSubscription[];
2419
account: Account;
2520
team: Team;
@@ -39,7 +34,6 @@ const compactNumberFormatter = new Intl.NumberFormat("en-US", {
3934
});
4035

4136
export const Usage: React.FC<UsageProps> = ({
42-
usage: usageData,
4337
subscriptions,
4438
account,
4539
team,
@@ -48,20 +42,18 @@ export const Usage: React.FC<UsageProps> = ({
4842
rpcUsage,
4943
}) => {
5044
const gatewayMetrics = useMemo(() => {
51-
if (!usageData) {
52-
return {};
53-
}
54-
5545
return {
5646
title: "Unlimited Requests",
5747
total: (
5848
<span className="text-muted-foreground">
59-
{compactNumberFormatter.format(usageData.rateLimits.storage)} Requests
60-
Per Second
49+
{compactNumberFormatter.format(
50+
team.capabilities.storage.upload.rateLimit,
51+
)}{" "}
52+
Requests Per Second
6153
</span>
6254
),
6355
};
64-
}, [usageData]);
56+
}, [team.capabilities.storage.upload.rateLimit]);
6557

6658
const usageSub = subscriptions.find((sub) => sub.type === "USAGE");
6759

@@ -138,7 +130,7 @@ export const Usage: React.FC<UsageProps> = ({
138130
<ThirdwebBarChart
139131
header={{
140132
title: "RPC Requests",
141-
description: `Your plan allows for ${usageData.rateLimits.rpc} requests per second`,
133+
description: `Your plan allows for ${team.capabilities.rpc.rateLimit} requests per second`,
142134
titleClassName: "text-xl mb-0.5",
143135
}}
144136
data={rpcUsageData}

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/page.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { getClientThirdwebClient } from "../../../../../../../@/constants/thirdw
88
import { getValidAccount } from "../../../../../account/settings/getAccount";
99
import { getAuthToken } from "../../../../../api/lib/getAuthToken";
1010
import { loginRedirect } from "../../../../../login/loginRedirect";
11-
import { getAccountUsage } from "./getAccountUsage";
1211
import { Usage } from "./overview/components/Usage";
1312

1413
export default async function Page(props: {
@@ -31,8 +30,7 @@ export default async function Page(props: {
3130
loginRedirect(`/team/${params.team_slug}/~/usage`);
3231
}
3332

34-
const [accountUsage, subscriptions, projects, rpcUsage] = await Promise.all([
35-
getAccountUsage(),
33+
const [subscriptions, projects, rpcUsage] = await Promise.all([
3634
getTeamSubscriptions(team.slug),
3735
getProjects(team.slug),
3836
fetchRPCUsage({
@@ -48,7 +46,7 @@ export default async function Page(props: {
4846
}),
4947
]);
5048

51-
if (!accountUsage || !subscriptions) {
49+
if (!subscriptions) {
5250
return (
5351
<div className="flex min-h-[350px] items-center justify-center rounded-lg border p-4 text-destructive-text">
5452
Something went wrong. Please try again later.
@@ -63,8 +61,6 @@ export default async function Page(props: {
6361

6462
return (
6563
<Usage
66-
// TODO - remove accountUsage when we have all the data available from team
67-
usage={accountUsage}
6864
subscriptions={subscriptions}
6965
account={account}
7066
team={team}

0 commit comments

Comments
 (0)