"use client";
import { useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { vipnagorgialla } from "@/components/Vipnagorgialla";
interface TicketData {
title: string;
subtitle: string;
price: string;
features: string[];
}
interface SwitchableTicketCardProps {
optionA: TicketData;
optionB: TicketData;
buttonText: string;
buttonHref: string;
backgroundImage?: string;
backgroundImageB?: string;
backgroundOpacity?: number;
backgroundOpacityA?: number;
backgroundOpacityB?: number;
className?: string;
}
export default function SwitchableTicketCard({
optionA,
optionB,
buttonText,
buttonHref,
backgroundImage,
backgroundImageB,
backgroundOpacity = 40,
backgroundOpacityA,
backgroundOpacityB,
className = "",
}: SwitchableTicketCardProps) {
const [isA, setIsA] = useState(true);
const titleOnRight = !isA;
function renderPrice(price: string) {
return Array.from(price).map((char, index) => (
{char}
));
}
function renderFeatures(features: string[]) {
return (
{features.map((feature, index) => (
-
{feature}
))}
);
}
function renderMobileFeatures(features: string[]) {
return (
{features.map((feature, index) => (
-
{feature}
))}
);
}
return (
{backgroundImage && (
)}
{backgroundImageB && (
)}
{/* Mobile: Simple slide transition at sm: breakpoint (640px) */}
{optionA.title}
{optionA.subtitle}
{renderPrice(optionA.price)}
{renderMobileFeatures(optionA.features)}
{optionB.title}
{optionB.subtitle}
{renderPrice(optionB.price)}
{renderMobileFeatures(optionB.features)}
{/* Desktop: Original transition behavior */}
{/* Title + subtitle + price with position shift */}
{optionA.title}
{optionA.subtitle}
{renderPrice(optionA.price)}
{optionB.title}
{optionB.subtitle}
{renderPrice(optionB.price)}
{renderFeatures(optionA.features)}
{renderFeatures(optionB.features)}
{/* Chevron buttons on left/right sides */}
);
}