"use client"; import { Check, ChevronsUpDown, X } from "lucide-react"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { cn } from "@/lib/utils"; interface Feature { name: string; values: (boolean | null | string)[]; } interface FeatureSection { category: string; features: Feature[]; } interface Plan { name: string; ctaText: string; ctaHref?: string; ctaVariant?: "default" | "outline" | "secondary"; } interface Pricing42Props { plans?: Plan[]; featureSections?: FeatureSection[]; className?: string; } const CATEGORY_LABELS: Record = { Usage: "میزان استفاده", Features: "امکانات", Support: "پشتیبانی", }; const Pricing42 = ({ plans = [ { name: "رایگان", ctaText: "شروع رایگان", ctaHref: "#", ctaVariant: "outline", }, { name: "استارتاپ", ctaText: "شروع رایگان", ctaHref: "#", ctaVariant: "outline", }, { name: "سازمانی", ctaText: "درخواست دمو", ctaHref: "#", ctaVariant: "outline", }, ], featureSections = [ { category: "Usage", features: [ { name: "اعضا", values: ["نامحدود", "نامحدود", "نامحدود"], }, { name: "تراکنش‌ها", values: ["۲۵۰", "نامحدود", "نامحدود"], }, { name: "تیم‌ها", values: ["۲", "نامحدود", "نامحدود"] }, ], }, { category: "Features", features: [ { name: "گزارش‌دهی", values: [true, true, true] }, { name: "تحلیل‌ها", values: [true, true, true] }, { name: "ورود و خروج داده", values: [true, true, true] }, { name: "یکپارچه‌سازی‌ها", values: [true, true, true] }, { name: "دستیار هوش مصنوعی", values: [null, true, true] }, { name: "نقش‌های مدیریتی", values: [null, null, true] }, { name: "گزارش ممیزی", values: [null, null, true] }, ], }, { category: "Support", features: [ { name: "پشتیبانی اولویت‌دار", values: [true, true, true] }, { name: "مدیر حساب", values: [null, null, true] }, { name: "SLA آپتایم", values: [null, null, true] }, ], }, ], className, }: Pricing42Props) => { const [selectedPlan, setSelectedPlan] = useState(1); const renderFeatureValue = (value: boolean | null | string) => { if (value === true) { return ; } if (value === false) { return ; } if (value === null) { return null; } return (
{value}
); }; return (
{/* Plan Headers */}
{/* Mobile View */}
<>

{plans[selectedPlan].name}

{plans.map( (plan, index) => index !== selectedPlan && ( ), )}
{/* Desktop View */}
{plans.map((plan, index) => (

{plan.name}

))}
{/* Feature Sections */} {featureSections.map((section, sectionIndex) => (

{CATEGORY_LABELS[section.category] ?? section.category}

{section.features.map((feature, featureIndex) => (
{feature.name} {/* Mobile View - Only Selected Plan */}
{renderFeatureValue(feature.values[selectedPlan])}
{/* Desktop View - All Plans */}
{feature.values.map((value, i) => (
{renderFeatureValue(value)}
))}
))}
))}
); }; export { Pricing42 };