"use client"; import { useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { cn } from "@/lib/utils"; const formatPrice = (value: string | number) => `${(typeof value === "string" ? Number(value) : value).toLocaleString("fa-IR")} ریال`; interface Pricing35Props { className?: string; } const Pricing35 = ({ className }: Pricing35Props) => { const pricingPlans = [ { id: "standard", type: "standard", prices: { quarterly: 150000, yearly: 12, }, isCustom: false, isDark: false, hasToggle: true, badge: null, ctaText: "شروع با طرح استاندارد", description: "مناسب افراد یا فریلنسرهایی که تازه شروع کرده‌اند. نیازی به کارت اعتباری نیست.", }, { id: "premium", type: "premium", prices: { quarterly: null, yearly: null, }, isCustom: true, isDark: true, hasToggle: false, badge: "۱۰ از ۳۰۰ جایگاه باقی مانده", ctaText: "عضویت VIP", description: "مناسب افراد یا فریلنسرهایی که تازه شروع کرده‌اند. نیازی به کارت اعتباری نیست.", }, ]; const [billingPeriods, setBillingPeriods] = useState({ standard: "quarterly", premium: "quarterly", }); const updateBillingPeriod = ( planId: string, period: "quarterly" | "yearly", ) => { setBillingPeriods((prev) => ({ ...prev, [planId]: period, })); }; const formatDisplayPrice = ( price: number | null, isCustom: boolean, ) => { if (isCustom || price === null) { return "سفارشی"; } return `${formatPrice(price)} در ماه`; }; return (

طرح‌های تعرفه انعطاف‌پذیر

طرحی را انتخاب کنید که با نیازها و بودجه شما هماهنگ باشد.

{pricingPlans.map((plan) => { const currentPeriod = billingPeriods[ plan.id as keyof typeof billingPeriods ] as "quarterly" | "yearly"; return (
{formatDisplayPrice( plan.prices[currentPeriod], plan.isCustom, )}
{!plan.isCustom && currentPeriod === "quarterly" ? "صورتحساب سه‌ماهه" : !plan.isCustom && currentPeriod === "yearly" ? "صورتحساب سالانه" : "صورتحساب انعطاف‌پذیر"}
{plan.hasToggle ? ( { if (value) updateBillingPeriod( plan.id, value as "quarterly" | "yearly", ); }} className="rounded-xl bg-muted p-1" > سه‌ماهه سالانه ) : plan.badge ? ( {plan.badge} ) : null}
{currentPeriod === "yearly" ? "با صورتحساب سالانه ۲۰٪ صرفه‌جویی می‌کنید" : "با طرح سالانه ۲۰٪ تخفیف بگیرید"}

{plan.description}

); })}
); }; export { Pricing35 };