Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Remove PlanFeaturesCard component and related logic from subscription plans

Bill Yang6b93d81bee15
diff --git a/client/src/app/settings/subscription/components/PlanFeaturesCard.tsx b/client/src/app/settings/subscription/components/PlanFeaturesCard.tsx
deleted file mode 100644
index dd4786d01..000000000
--- a/client/src/app/settings/subscription/components/PlanFeaturesCard.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
-import { Check } from "lucide-react";
-import { PlanTemplate } from "../utils/planUtils";
-import { Badge } from "@/components/ui/badge";
-
-interface PlanFeaturesCardProps {
- currentPlan: PlanTemplate | null;
-}
-
-export function PlanFeaturesCard({ currentPlan }: PlanFeaturesCardProps) {
- // Check if this is an annual plan
- const isAnnualPlan = currentPlan?.interval === "year";
-
- return (
- <Card>
- <CardHeader>
- <div className="flex items-center justify-between">
- <div>
- <CardTitle>Plan Features</CardTitle>
- <CardDescription>
- What's included in your {currentPlan?.name} plan
- {isAnnualPlan && <span className="ml-1">(Annual)</span>}
- </CardDescription>
- </div>
- {isAnnualPlan && (
- <Badge className="bg-emerald-500 text-white font-semibold">
- Annual Plan
- </Badge>
- )}
- </div>
- </CardHeader>
- <CardContent>
- <ul className="space-y-2">
- {currentPlan?.features?.map((feature, i) => (
- <li key={i} className="flex items-start">
- <Check className="mr-2 h-5 w-5 text-green-500 shrink-0" />
- <span>{feature}</span>
- </li>
- ))}
- </ul>
- </CardContent>
- </Card>
- );
-}
diff --git a/client/src/app/settings/subscription/components/ProPlan.tsx b/client/src/app/settings/subscription/components/ProPlan.tsx
index 971364e44..8128c9edb 100644
--- a/client/src/app/settings/subscription/components/ProPlan.tsx
+++ b/client/src/app/settings/subscription/components/ProPlan.tsx
@@ -1,13 +1,14 @@
+import { Shield } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
+import { Alert } from "../../../../components/ui/alert";
import { Button } from "../../../../components/ui/button";
import { Card, CardContent } from "../../../../components/ui/card";
import { Progress } from "../../../../components/ui/progress";
-import { formatDate, getPlanDetails, PlanTemplate } from "../utils/planUtils";
-import { useStripeSubscription } from "../utils/useStripeSubscription";
-import { PlanFeaturesCard } from "./PlanFeaturesCard";
-import { Alert } from "../../../../components/ui/alert";
import { BACKEND_URL } from "../../../../lib/const";
+import { STRIPE_PRICES } from "../../../../lib/stripe";
+import { formatDate } from "../utils/planUtils";
+import { useStripeSubscription } from "../utils/useStripeSubscription";
export function ProPlan() {
const {
@@ -26,8 +27,22 @@ export function ProPlan() {
eventLimit > 0 ? Math.min((currentUsage / eventLimit) * 100, 100) : 0;
const isAnnualPlan = activeSubscription?.interval === "year";
- const currentPlanDetails: PlanTemplate | null = activeSubscription
- ? getPlanDetails(activeSubscription.planName)
+ const stripePlan = STRIPE_PRICES.find(
+ (p) => p.name === activeSubscription?.planName
+ );
+
+ const currentPlanDetails = activeSubscription
+ ? {
+ id: "pro",
+ name: "Pro",
+ price: `$${stripePlan?.price}`,
+ interval: stripePlan?.interval,
+ description: "Advanced analytics for growing projects",
+ features: ["5 year data retention", "Priority support"],
+ color:
+ "bg-gradient-to-br from-green-50 to-emerald-100 dark:from-green-800 dark:to-emerald-800",
+ icon: <Shield className="h-5 w-5" />,
+ }
: null;
const handleManageSubscription = async () => {
@@ -99,7 +114,7 @@ export function ProPlan() {
{actionError && <Alert variant="destructive">{actionError}</Alert>}
<Card>
<CardContent>
- <div className="space-y-6 mt-3">
+ <div className="space-y-6 mt-3 p-2">
<div className="flex justify-between items-start">
<div className="space-y-1">
<p className="text-3xl font-bold">
@@ -153,11 +168,6 @@ export function ProPlan() {
</div>
</CardContent>
</Card>
-
- {/* Conditionally render PlanFeaturesCard only when details are available */}
- {!isLoading && currentPlanDetails && (
- <PlanFeaturesCard currentPlan={currentPlanDetails as any} />
- )}
</div>
);
}
diff --git a/client/src/app/settings/subscription/components/TrialPlan.tsx b/client/src/app/settings/subscription/components/TrialPlan.tsx
index f659146fb..f706d21e6 100644
--- a/client/src/app/settings/subscription/components/TrialPlan.tsx
+++ b/client/src/app/settings/subscription/components/TrialPlan.tsx
@@ -1,4 +1,10 @@
import { ArrowRight, Clock } from "lucide-react";
+import { useRouter } from "next/navigation";
+import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
+} from "../../../../components/ui/alert";
import { Button } from "../../../../components/ui/button";
import {
Card,
@@ -10,15 +16,8 @@ import {
} from "../../../../components/ui/card";
import { Progress } from "../../../../components/ui/progress";
import { TRIAL_EVENT_LIMIT } from "../utils/constants";
-import { formatDate, getPlanDetails } from "../utils/planUtils";
+import { formatDate } from "../utils/planUtils";
import { useStripeSubscription } from "../utils/useStripeSubscription";
-import { useRouter } from "next/navigation";
-import {
- Alert,
- AlertDescription,
- AlertTitle,
-} from "../../../../components/ui/alert";
-import { PlanFeaturesCard } from "./PlanFeaturesCard";
export function TrialPlan() {
const {
@@ -37,8 +36,6 @@ export function TrialPlan() {
? new Date(activeSubscription.currentPeriodEnd)
: null;
- const trialPlanDetails = getPlanDetails("trial");
-
return (
<div className="space-y-6">
<Card>
@@ -51,7 +48,7 @@ export function TrialPlan() {
</CardDescription>
</CardHeader>
<CardContent>
- <div className="space-y-6">
+ <div className="space-y-6 p-2">
<Alert className="bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800">
<Clock className="h-4 w-4 text-blue-500 dark:text-blue-400" />
<AlertTitle>Trial Status</AlertTitle>
@@ -98,8 +95,6 @@ export function TrialPlan() {
</Button>
</CardFooter>
</Card>
-
- {trialPlanDetails && <PlanFeaturesCard currentPlan={trialPlanDetails} />}
</div>
);
}
diff --git a/client/src/app/settings/subscription/utils/constants.ts b/client/src/app/settings/subscription/utils/constants.ts
index 6906bbf81..19d1cc86c 100644
--- a/client/src/app/settings/subscription/utils/constants.ts
+++ b/client/src/app/settings/subscription/utils/constants.ts
@@ -1,4 +1,2 @@
-// Default event limit if not specified in subscription
-export const DEFAULT_EVENT_LIMIT = 20000;
export const TRIAL_EVENT_LIMIT = 100000;
export const TRIAL_DURATION_DAYS = 14;
diff --git a/client/src/app/settings/subscription/utils/planUtils.tsx b/client/src/app/settings/subscription/utils/planUtils.tsx
index d30509296..71000faff 100644
--- a/client/src/app/settings/subscription/utils/planUtils.tsx
+++ b/client/src/app/settings/subscription/utils/planUtils.tsx
@@ -1,91 +1,3 @@
-import { Clock, Shield, Zap } from "lucide-react";
-import { STRIPE_PRICES } from "@/lib/stripe";
-import { DEFAULT_EVENT_LIMIT, TRIAL_EVENT_LIMIT } from "./constants";
-
-// Define interfaces for plan data
-export interface PlanTemplate {
- id: string;
- name: string;
- price: string;
- interval: string;
- description: string;
- features: string[];
- color: string;
- icon: React.ReactNode;
-}
-
-// Helper to get the appropriate plan details based on subscription plan name
-export const getPlanDetails = (
- planName: string | undefined
-): PlanTemplate | null => {
- if (!planName) return null;
-
- // Handle the case for trial separately
- if (planName === "trial") {
- return {
- id: "trial",
- name: "Trial",
- price: "$0",
- interval: "trial",
- description: "Try all Pro features free for 14 days",
- features: [
- `${TRIAL_EVENT_LIMIT.toLocaleString()} events during trial`,
- "All Pro features included",
- "No credit card required",
- ],
- color:
- "bg-gradient-to-br from-blue-50 to-indigo-100 dark:from-blue-900 dark:to-indigo-900",
- icon: <Zap className="h-5 w-5 text-blue-500" />,
- };
- }
-
- const tier = planName.startsWith("pro") ? "pro" : "free";
- const stripePlan = STRIPE_PRICES.find((p) => p.name === planName);
-
- const planTemplates: Record<string, PlanTemplate> = {
- free: {
- id: "free",
- name: "Free",
- price: "$0",
- interval: "month",
- description: "Get started with basic analytics",
- features: [
- `${DEFAULT_EVENT_LIMIT.toLocaleString()} events per month`,
- "6 month data retention",
- ],
- color:
- "bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-800 dark:to-gray-900",
- icon: <Clock className="h-5 w-5" />,
- },
- pro: {
- id: "pro",
- name: "Pro",
- price: "$19+",
- interval: "month",
- description: "Advanced analytics for growing projects",
- features: ["5 year data retention", "Priority support"],
- color:
- "bg-gradient-to-br from-green-50 to-emerald-100 dark:from-green-800 dark:to-emerald-800",
- icon: <Shield className="h-5 w-5" />,
- },
- };
-
- const plan = { ...planTemplates[tier] };
-
- if (stripePlan) {
- plan.price = `$${stripePlan.price}`;
- plan.interval = stripePlan.interval;
-
- // Add event limit as first feature
- plan.features = [
- `${stripePlan.limits.events.toLocaleString()} events per month`,
- ...plan.features,
- ];
- }
-
- return plan;
-};
-
// Helper function to format dates
export const formatDate = (dateString: string | Date | null | undefined) => {
if (!dateString) return "N/A";