import { clsx } from 'clsx'; import { Button } from '@/components/shared/ui/button'; import Link from 'next/link'; import { Children, cloneElement, ReactElement } from 'react'; import { LandingPriceComparisonItem } from '@/components/landing/pricing-comparison/LandingPriceComparisonItem'; type Child = ReactElement; // eslint-disable-line @typescript-eslint/no-explicit-any /** * A component meant to be used to show a comparison column in the landing page, * typically used with LandingPriceComparisonSection. */ export const LandingPriceComparisonColumn = ({ className, children, header, headerComponent, footer, footerComponent, featured = false, ctaText, ctaTextComponent, href, onClick, variant = 'primary', }: { className?: string; children: React.ReactNode; header?: string | React.ReactNode; headerComponent?: React.ReactNode; footer?: string | React.ReactNode; footerComponent?: React.ReactNode; featured?: boolean; ctaText?: string; ctaTextComponent?: React.ReactNode; href?: string; onClick?: () => void; variant?: 'primary' | 'secondary'; }) => { const childrenWithProps = Children.map(children, (child, index) => { if (!child) { return null; } if (typeof child !== 'object') { return child; } const reactChild = child as Child; const reactChildType = reactChild?.type; if (reactChildType === LandingPriceComparisonItem) { return cloneElement(reactChild, { showText: !!featured, showDescription: !!featured, }); } return child; }); const hasCta = ctaText || ctaTextComponent; return (
{(header || headerComponent) && (
{header ? (
{typeof header === 'string' ? (

{header}

) : ( header )}
) : ( headerComponent )}
)} {childrenWithProps} {(footer || footerComponent || ctaText) && (
{footer ? (
{typeof footer === 'string' ? (
{footer}
) : ( footer )}
) : ( footerComponent )} {ctaText && (href || onClick) ? ( ) : ( ctaTextComponent )}
)}
); };