import { localePath, type Locale } from '@/lib/i18n' import type { getHostingPlansContent } from '@/lib/payload-content' import { formatHuf, grossAmount, DEFAULT_VAT_RATE_PERCENT, type BillingPeriod, type HostingPlanView } from '@/lib/products' type Content = Awaited> type Labels = Content['labels'] type HostingPlansViewProps = { content: Content plans: HostingPlanView[] locale: Locale } const PERIOD_LABEL: Record = { yearly: 'perYear', monthly: 'perMonth', 'one-time': 'oneTime', } const gb = (value?: number) => (value === undefined ? '–' : `${value} GB`) const num = (value?: number) => (value === undefined ? '–' : String(value)) function comparisonRows(plan: HostingPlanView, labels: Labels): [string, string][] { const s = plan.service const included = (on: boolean) => (on ? `✓ ${labels.included}` : '–') return [ [labels.storage, gb(s.storageGb)], [labels.mailStorage, gb(s.mailStorageGb)], [labels.domains, num(s.domains)], [labels.domainAliases, num(s.domainAliases)], [labels.databases, num(s.databases)], [labels.mailboxes, num(s.mailboxes)], [labels.backup, s.backup ?? '–'], [labels.ssl, included(s.ssl)], [labels.spamFilter, included(s.spamFilter)], ] } /** MITHOME-130: comparable hosting plan cards with net + VAT and gross price. */ export default function HostingPlansView({ content, plans, locale }: HostingPlansViewProps) { const { labels } = content const contactHref = localePath(locale, 'contact') const vatRate = content.vatRatePercent ?? DEFAULT_VAT_RATE_PERCENT return (

{content.hero.title}

{content.hero.subtitle}

    {plans.map((plan) => { const period = labels[PERIOD_LABEL[plan.billingPeriod]] return (
  • {plan.highlighted && ( {labels.recommended} )}

    {plan.name}

    {plan.audience}

    {plan.shortDescription}

    {formatHuf(plan.netAmount, locale)}{' '} {labels.plusVat} {period}

    {labels.grossPrice} {formatHuf(grossAmount(plan.netAmount, vatRate), locale)} {period}

    {comparisonRows(plan, labels).map(([term, value]) => (
    {term}
    {value}
    ))}
    {plan.features.length > 0 && (
      {plan.features.map((feature) => (
    • {feature}
    • ))}
    )} {plan.ctaText}
  • ) })}

{labels.priceNote}

{content.largerNeeds.title}

{content.largerNeeds.text}

{content.largerNeeds.button}
) }