"use client"; import { usePlanData } from "@saas/payments/hooks/plan-data"; import { usePurchases } from "@saas/payments/hooks/purchases"; import { SettingsItem } from "@saas/shared/components/SettingsItem"; import {} from "@ui/components/table"; import { BadgeCheckIcon, CheckIcon } from "lucide-react"; import { useTranslations } from "next-intl"; import { CustomerPortalButton } from "../../settings/components/CustomerPortalButton"; import { SubscriptionStatusBadge } from "../../settings/components/SubscriptionStatusBadge"; export function ActivePlan({ organizationId, }: { organizationId?: string; seats?: number; }) { const t = useTranslations(); const { planData } = usePlanData(); const { activePlan } = usePurchases(organizationId); if (!activePlan) { return null; } const activePlanData = planData[activePlan.id as keyof typeof planData]; if (!activePlanData) { return null; } const price = "price" in activePlan ? activePlan.price : null; return (

{activePlanData.title}

{activePlan.status && ( )}
{!!activePlanData.features?.length && (
    {activePlanData.features.map((feature, key) => (
  • {feature}
  • ))}
)} {price && ( {Intl.NumberFormat("en-US", { style: "currency", currency: price.currency, minimumFractionDigits: 0, }).format(price.amount)} {"interval" in price && ( {" / "} {price.interval === "month" ? t("pricing.month", { count: price.intervalCount ?? 1, }) : t("pricing.year", { count: price.intervalCount ?? 1, })} )} {organizationId && "seatBased" in price && price.seatBased && ( {" / "} {t("pricing.perSeat")} )} )}
{"purchaseId" in activePlan && activePlan.purchaseId && (
)}
); }