"use client"; import { useState, useRef } from "react"; import { CreditCard, Building2, ScrollText, Crown, Sparkles } from "lucide-react"; import { SectionHeading } from "@/components/ui/SectionHeading"; import { Reveal } from "@/components/ui/Reveal"; import type { SiteContent } from "@/types/content"; type Tab = "prices" | "rental" | "rules"; interface PricingProps { data: SiteContent["pricing"]; } export function Pricing({ data: pricing }: PricingProps) { if (!pricing?.items) return null; const [activeTab, setActiveTab] = useState("prices"); const tabRefs = useRef<(HTMLButtonElement | null)[]>([]); const tabs: { id: Tab; label: string; icon: React.ReactNode }[] = [ { id: "prices", label: "Абонементы", icon: }, { id: "rental", label: "Аренда зала", icon: }, { id: "rules", label: "Правила", icon: }, ]; function handleTabKeyDown(e: React.KeyboardEvent, index: number) { let nextIndex: number | null = null; if (e.key === "ArrowRight") { nextIndex = (index + 1) % tabs.length; } else if (e.key === "ArrowLeft") { nextIndex = (index - 1 + tabs.length) % tabs.length; } if (nextIndex !== null) { e.preventDefault(); setActiveTab(tabs[nextIndex].id); tabRefs.current[nextIndex]?.focus(); } } // Split items: featured (big card) vs regular const featuredItem = pricing.items.find((item) => item.featured); const regularItems = pricing.items.filter((item) => !item.featured); return (
{pricing.title} {/* Tabs */}
{tabs.map((tab, index) => ( ))}
{/* Prices tab */}

{pricing.subtitle}

{/* Cards grid */}
{regularItems.map((item, i) => { const isPopular = item.popular ?? false; return (
{/* Popular badge */} {isPopular && (
Популярный
)}
{/* Name */}

{item.name}

{/* Note */} {item.note && (

{item.note}

)} {/* Price */}

{item.price}

); })}
{/* Featured — big card */} {featuredItem && (

{featuredItem.name}

{featuredItem.note && (

{featuredItem.note}

)}

{featuredItem.price}

)}
{/* Rental tab */}
{pricing.rentalSubtitle && (

{pricing.rentalSubtitle}

)}
{pricing.rentalItems.map((item, i) => (

{item.name}

{item.note && (

{item.note}

)}
{item.price}
))}
{/* Rules tab */}
{pricing.rules.map((rule, i) => (
{i + 1}

{rule}

))}
); }