show no plan as free plan

This commit is contained in:
Adam Cohen Hillel 2025-04-14 01:47:15 +01:00
parent 338a2da546
commit 5456ac042f
2 changed files with 10 additions and 4 deletions

View File

@ -3,7 +3,7 @@ import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
import { createClient } from "@/lib/supabase/server"; import { createClient } from "@/lib/supabase/server";
import { SubmitButton } from "../ui/submit-button"; import { SubmitButton } from "../ui/submit-button";
import { manageSubscription } from "@/lib/actions/billing"; import { manageSubscription } from "@/lib/actions/billing";
import { PlanComparison } from "../billing/PlanComparison"; import { PlanComparison, SUBSCRIPTION_PLANS } from "../billing/PlanComparison";
type Props = { type Props = {
accountId: string; accountId: string;
@ -80,7 +80,9 @@ export default async function AccountBillingStatus({ accountId, returnUrl }: Pro
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">
<span className="text-sm font-medium text-foreground/90">Status</span> <span className="text-sm font-medium text-foreground/90">Status</span>
<span className="text-sm font-medium text-card-title">{billingData.status === 'active' ? 'Active' : 'Inactive'}</span> <span className="text-sm font-medium text-card-title">
{(!currentPlanId || currentPlanId === SUBSCRIPTION_PLANS.FREE) ? 'Active (Free)' : billingData.status === 'active' ? 'Active' : 'Inactive'}
</span>
</div> </div>
{billingData.plan_name && ( {billingData.plan_name && (
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">

View File

@ -7,7 +7,7 @@ import { setupNewSubscription } from "@/lib/actions/billing";
import { createClient } from "@/lib/supabase/client"; import { createClient } from "@/lib/supabase/client";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
const SUBSCRIPTION_PLANS = { export const SUBSCRIPTION_PLANS = {
FREE: 'price_1RDQbOG6l1KZGqIrgrYzMbnL', FREE: 'price_1RDQbOG6l1KZGqIrgrYzMbnL',
BASIC: 'price_1RC2PYG6l1KZGqIrpbzFB9Lp', // Example price ID BASIC: 'price_1RC2PYG6l1KZGqIrpbzFB9Lp', // Example price ID
PRO: 'price_1RDQWqG6l1KZGqIrChli4Ys4' PRO: 'price_1RDQWqG6l1KZGqIrChli4Ys4'
@ -60,7 +60,11 @@ export function PlanComparison({
.eq('status', 'active') .eq('status', 'active')
.single(); .single();
setCurrentPlanId(data?.price_id); // Set to FREE plan if no active subscription found, otherwise use the subscription's plan
setCurrentPlanId(data?.price_id || SUBSCRIPTION_PLANS.FREE);
} else {
// Default to FREE plan if no accountId
setCurrentPlanId(SUBSCRIPTION_PLANS.FREE);
} }
} }