"use client"; import { Check } from "lucide-react"; import { KeyboardEvent } from "react"; import { Badge, Button, Card, CardContent, CardFooter, CardHeader } from "../../../../../shadcnui"; import { formatCurrency, formatInterval } from "../../../components/utils"; import { StripePriceInterface } from "../../../stripe-price/data/stripe-price.interface"; import { cn } from "../../../../../utils/cn"; export type PricingCardProps = { price: StripePriceInterface; isCurrentPlan?: boolean; isSelected?: boolean; isDisabled?: boolean; isLoading?: boolean; onSelect: (price: StripePriceInterface) => void; }; export function PricingCard({ price, isCurrentPlan = false, isSelected = false, isDisabled = false, isLoading = false, onSelect, }: PricingCardProps) { const description = price.description || price.nickname || "Standard"; const features = price.features || []; const formattedPrice = formatCurrency(price.unitAmount, price.currency); const interval = formatInterval(price); const handleKeyDown = (e: KeyboardEvent) => { if ((e.key === "Enter" || e.key === " ") && !isDisabled && !isCurrentPlan) { e.preventDefault(); onSelect(price); } }; const handleClick = () => { if (!isDisabled && !isCurrentPlan && !isLoading) { onSelect(price); } }; return ( {isCurrentPlan && ( Current )}

{description}

{formattedPrice} {interval}
{features.length > 0 && (
    {features.map((feature, index) => (
  • {feature}
  • ))}
)}
); }