Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 377f46c

Browse files
authored
cleanup unused (thirdweb-dev#5476)
1 parent b52049c commit 377f46c

File tree

8 files changed

+30
-84
lines changed

8 files changed

+30
-84
lines changed

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export const accountPlan = {
2929
enterprise: "enterprise",
3030
} as const;
3131

32-
type AccountStatus = (typeof accountStatus)[keyof typeof accountStatus];
33-
type AccountPlan = (typeof accountPlan)[keyof typeof accountPlan];
34-
3532
export type AuthorizedWallet = {
3633
id: string;
3734
accountId: string;
@@ -47,30 +44,17 @@ export type Account = {
4744
id: string;
4845
isStaff: boolean;
4946
creatorWalletAddress: string;
50-
status: AccountStatus;
51-
plan: AccountPlan;
5247
name?: string;
5348
email?: string;
5449
advancedEnabled: boolean;
55-
currentBillingPeriodStartsAt: string;
56-
currentBillingPeriodEndsAt: string;
5750
emailConfirmedAt?: string;
5851
unconfirmedEmail?: string;
59-
trialPeriodEndedAt?: string;
6052
emailConfirmationWalletAddress?: string;
61-
stripePaymentActionUrl?: string;
6253
onboardSkipped?: boolean;
63-
paymentAttemptCount?: number;
6454
notificationPreferences?: {
6555
billing: "email" | "none";
6656
updates: "email" | "none";
6757
};
68-
recurringPaymentFailures: {
69-
subscriptionId: string;
70-
subscriptionDescription: string;
71-
paymentFailureCode: string;
72-
serviceCutoffDate: string;
73-
}[];
7458
// TODO - add image URL
7559
};
7660

@@ -194,33 +178,16 @@ export interface UpdateKeyInput {
194178
redirectUrls: string[];
195179
}
196180

197-
interface UsageBundler {
198-
chainId: number;
199-
sumTransactionFee: string;
200-
}
201-
202181
interface UsageStorage {
203182
sumFileSizeBytes: number;
204183
}
205184

206-
interface UsageEmbeddedWallets {
207-
countWalletAddresses: number;
208-
}
209-
210185
export interface UsageBillableByService {
211186
usage: {
212-
bundler: UsageBundler[];
213187
storage: UsageStorage;
214-
embeddedWallets: UsageEmbeddedWallets;
215-
};
216-
billableUsd: {
217-
bundler: number;
218-
storage: number;
219-
embeddedWallets: number;
220188
};
221189
limits: {
222190
storage: number;
223-
embeddedWallets: number;
224191
};
225192
rateLimits: {
226193
storage: number;

apps/dashboard/src/app/api/testnet-faucet/claim/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const POST = async (req: NextRequest) => {
7474
const account: { data: Account } = await accountRes.json();
7575

7676
// Make sure the logged-in account has verified its email
77-
if (account.data.status === "noCustomer") {
77+
if (!account.data.email) {
7878
return NextResponse.json(
7979
{
8080
error: "Account owner hasn't verified email",

apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/create/components/client/create-ecosystem-form.client.tsx

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import {
1414
import { ImageUpload } from "@/components/ui/image-upload";
1515
import { Input } from "@/components/ui/input";
1616
import { RadioGroup, RadioGroupItemButton } from "@/components/ui/radio-group";
17-
import { ToolTipLabel } from "@/components/ui/tooltip";
1817
import { useDashboardRouter } from "@/lib/DashboardRouter";
19-
import { accountStatus, useAccount } from "@3rdweb-sdk/react/hooks/useApi";
2018
import { zodResolver } from "@hookform/resolvers/zod";
2119
import { Loader2 } from "lucide-react";
2220
import Link from "next/link";
@@ -49,7 +47,6 @@ export function CreateEcosystemForm(props: {
4947
const [formDataToBeConfirmed, setFormDataToBeConfirmed] = useState<
5048
z.infer<typeof formSchema> | undefined
5149
>();
52-
const { data: billingAccountInfo } = useAccount();
5350

5451
const router = useDashboardRouter();
5552
const form = useForm<z.infer<typeof formSchema>>({
@@ -164,31 +161,16 @@ export function CreateEcosystemForm(props: {
164161
)}
165162
/>
166163
</div>
167-
{billingAccountInfo?.status !== accountStatus.validPayment ? (
168-
<ToolTipLabel label="Please update your payment method to create an ecosystem">
169-
{/* Allows the button to be disabled but the tooltip still works */}
170-
<div className="w-full">
171-
<Button
172-
type="submit"
173-
disabled={true}
174-
variant="primary"
175-
className="w-full opacity-50"
176-
>
177-
Create
178-
</Button>
179-
</div>
180-
</ToolTipLabel>
181-
) : (
182-
<Button
183-
type="submit"
184-
variant="primary"
185-
className="w-full"
186-
disabled={isPending}
187-
>
188-
{isPending && <Loader2 className="mr-1 h-4 w-4 animate-spin" />}
189-
Create
190-
</Button>
191-
)}
164+
165+
<Button
166+
type="submit"
167+
variant="primary"
168+
className="w-full"
169+
disabled={isPending}
170+
>
171+
{isPending && <Loader2 className="mr-1 h-4 w-4 animate-spin" />}
172+
Create
173+
</Button>
192174
</form>
193175
</Form>
194176
<ConfirmationDialog

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ export const Usage: React.FC<UsageProps> = ({
4141
return {
4242
total: `${toSize(Math.min(consumedBytes, limitBytes), "MB")} of ${toSize(limitBytes)} included storage used`,
4343
progress: percent,
44-
...(usageData.billableUsd.storage > 0
45-
? {
46-
overage: usageData.billableUsd.storage,
47-
}
48-
: {}),
4944
totalUsage: `Total Usage: ${toSize(consumedBytes, "MB")}`,
5045
};
5146
}, [usageData]);

apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/account-abstraction/AccountAbstractionPage.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"use client";
2-
32
import { Spinner } from "@/components/ui/Spinner/Spinner";
43
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
54
import { TrackedLinkTW } from "@/components/ui/tracked-link";
65
import {
76
type ApiKeyService,
87
accountStatus,
9-
useAccount,
108
} from "@3rdweb-sdk/react/hooks/useApi";
119
import { useLoggedInUser } from "@3rdweb-sdk/react/hooks/useLoggedInUser";
1210
import { SmartWalletsBillingAlert } from "components/settings/ApiKeys/Alerts";
@@ -26,24 +24,20 @@ export function AccountAbstractionPage(props: {
2624
teamSlug: string;
2725
projectKey: string;
2826
apiKeyServices: ApiKeyService[];
27+
billingStatus: "validPayment" | (string & {}) | null;
2928
tab?: string;
3029
}) {
3130
const { apiKeyServices } = props;
3231
const looggedInUserQuery = useLoggedInUser();
33-
const accountQuery = useAccount();
3432
const chain = useActiveWalletChain();
3533

3634
const hasSmartWalletsWithoutBilling = useMemo(() => {
37-
if (!accountQuery.data) {
38-
return;
39-
}
40-
4135
return apiKeyServices.find(
4236
(s) =>
43-
accountQuery.data.status !== accountStatus.validPayment &&
37+
props.billingStatus !== accountStatus.validPayment &&
4438
s.name === "bundler",
4539
);
46-
}, [apiKeyServices, accountQuery.data]);
40+
}, [apiKeyServices, props.billingStatus]);
4741

4842
const isOpChain = chain?.id ? isOpChainId(chain.id) : false;
4943

apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/account-abstraction/page.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { getProject } from "@/api/projects";
22
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
33
import type { Metadata } from "next";
4-
import { notFound } from "next/navigation";
4+
import { notFound, redirect } from "next/navigation";
5+
import { getTeamBySlug } from "../../../../../../@/api/team";
56
import { getAbsoluteUrl } from "../../../../../../lib/vercel-utils";
67
import { getAPIKeyForProjectId } from "../../../../../api/lib/getAPIKeys";
78
import { AccountAbstractionPage } from "./AccountAbstractionPage";
@@ -11,7 +12,15 @@ export default async function Page(props: {
1112
searchParams: Promise<{ tab?: string }>;
1213
}) {
1314
const { team_slug, project_slug } = await props.params;
14-
const project = await getProject(team_slug, project_slug);
15+
16+
const [team, project] = await Promise.all([
17+
getTeamBySlug(team_slug),
18+
getProject(team_slug, project_slug),
19+
]);
20+
21+
if (!team) {
22+
redirect("/team");
23+
}
1524

1625
if (!project) {
1726
notFound();
@@ -28,6 +37,7 @@ export default async function Page(props: {
2837
<AccountAbstractionPage
2938
projectSlug={project.slug}
3039
teamSlug={team_slug}
40+
billingStatus={team.billingStatus}
3141
projectKey={project.publishableKey}
3242
apiKeyServices={apiKey.services || []}
3343
tab={(await props.searchParams).tab}

apps/dashboard/src/components/onboarding/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const Onboarding: React.FC<{
6767
);
6868
}
6969
// skip when going thru claiming trial growth
70-
else if (account?.trialPeriodEndedAt) {
70+
else if (account?.onboardSkipped) {
7171
setState("skipped");
7272
}
7373
// user hasn't skipped onboarding, has valid email and no valid payment yet

apps/dashboard/src/components/onboarding/on-boarding-ui.client.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ function OnboardingUI(props: {
4242
break;
4343
case "confirming":
4444
// after confirming, only show plan if user has not skipped onboarding earlier or trial period has ended
45-
nextStep =
46-
account.onboardSkipped || account?.trialPeriodEndedAt
47-
? "skipped"
48-
: "plan";
45+
nextStep = account.onboardSkipped ? "skipped" : "plan";
4946
break;
5047
case "confirmLinking":
5148
nextStep = "skipped";
@@ -145,7 +142,8 @@ function OnboardingUI(props: {
145142
setState("skipped");
146143
skipOnboarding();
147144
}}
148-
canTrialGrowth={!account.trialPeriodEndedAt}
145+
// TODO: what can we do here? assume true for the moment
146+
canTrialGrowth={true}
149147
/>
150148
</Suspense>
151149
)}

0 commit comments

Comments
 (0)