Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix ts error

Steven Tey3abbdec7aceb
diff --git a/apps/web/lib/swr/use-project.ts b/apps/web/lib/swr/use-project.ts
index 451811e1c1..72c81d8060 100644
--- a/apps/web/lib/swr/use-project.ts
+++ b/apps/web/lib/swr/use-project.ts
@@ -1,5 +1,5 @@
import { ProjectProps } from "@/lib/types";
-import { fetcher, getNextPlan } from "@dub/utils";
+import { PRO_PLAN, fetcher, getNextPlan } from "@dub/utils";
import { useParams } from "next/navigation";
import useSWR from "swr";
@@ -16,7 +16,7 @@ export default function useProject() {
return {
...project,
- nextPlan: getNextPlan(project?.plan),
+ nextPlan: project?.plan ? getNextPlan(project.plan) : PRO_PLAN,
defaultDomains: project?.metadata?.defaultDomains || [],
isOwner: project?.users && project.users[0].role === "owner",
exceededClicks: project && project.usage >= project.usageLimit,
diff --git a/packages/utils/src/constants/pricing.tsx b/packages/utils/src/constants/pricing.tsx
index b61a591585..3fcefb588c 100644
--- a/packages/utils/src/constants/pricing.tsx
+++ b/packages/utils/src/constants/pricing.tsx
@@ -273,6 +273,7 @@ export const PLANS = [
];
export const FREE_PLAN = PLANS.find((plan) => plan.name === "Free")!;
+export const PRO_PLAN = PLANS.find((plan) => plan.name === "Pro")!;
export const SELF_SERVE_PAID_PLANS = PLANS.filter(
(p) => p.name !== "Free" && p.name !== "Enterprise",
@@ -290,10 +291,8 @@ export const getPlanDetails = (plan: string) => {
)!;
};
-export const getNextPlan = (plan: any) => {
- return (
- PLANS[
- PLANS.findIndex((p) => p.name.toLowerCase() === plan.toLowerCase()) + 1
- ] || PLANS[1]
- );
+export const getNextPlan = (plan: string) => {
+ return PLANS[
+ PLANS.findIndex((p) => p.name.toLowerCase() === plan.toLowerCase()) + 1
+ ];
};