feat(cms): hosting plans page with lifecycle gate and net + VAT prices (MITHOME-130)
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s

- Products collection (interim mirror of the PLATFM-14 catalogue contract):
  lifecycle status, product type, required whole-forint net price, yearly
  billing, service definition, per-product English gate
- HostingPlans global: page copy, comparison labels, VAT rate (27%)
- Gate: production shows only active plans, staging all but retired; with no
  showable plan the page is 404 and left out of the menu and the sitemap
- /hu/tarhely-csomagok <-> /en/hosting-plans via PAGE_SLUGS (hreflang,
  language switcher, CTA page picker)
- Seed migration 20260929_hosting_plans: mIT Start (14 900 Ft/yr, 5 mailboxes)
  and mIT Mid (23 900 Ft/yr) as drafts, English AI draft; idempotent
- Production SEO suite expects at least 12 sitemap URLs; new SMOKE-10

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Do Siki
2026-09-29 19:36:44 +02:00
co-authored by Claude Opus 5.5
parent 0c5888761b
commit 1e0742a548
26 changed files with 1114 additions and 32 deletions
+167
View File
@@ -0,0 +1,167 @@
/**
* MITHOME-130: hosting plans — lifecycle gate, price and view model.
*
* The product structure follows the central catalogue contract (mitplatform
* PLATFM-14, docs/architecture/product-catalog-contract.md). The Payload
* `products` collection is an interim mirror of it; reading goes through
* src/lib/payload-content.ts so the source can be swapped in one place.
*
* Pure functions only — no Payload import, unit-testable.
*/
import { contentLocale } from './translation-gate'
import type { Locale } from './i18n'
export const PRODUCT_STATUSES = ['draft', 'internal', 'publishable', 'active', 'retired'] as const
export type ProductStatus = (typeof PRODUCT_STATUSES)[number]
export const PRODUCT_STATUS_LABELS: Record<ProductStatus, string> = {
draft: 'Tervezet',
internal: 'Belső',
publishable: 'Publikálható',
active: 'Aktív (éles)',
retired: 'Kivezetett',
}
export const PRODUCT_TYPES = ['hosting', 'managed-service'] as const
export type ProductType = (typeof PRODUCT_TYPES)[number]
export const PRODUCT_TYPE_LABELS: Record<ProductType, string> = {
hosting: 'Tárhely',
'managed-service': 'Menedzselt szolgáltatás',
}
export const BILLING_PERIODS = ['yearly', 'monthly', 'one-time'] as const
export type BillingPeriod = (typeof BILLING_PERIODS)[number]
export const BILLING_PERIOD_LABELS: Record<BillingPeriod, string> = {
yearly: 'Éves',
monthly: 'Havi',
'one-time': 'Egyszeri',
}
export const DEFAULT_VAT_RATE_PERCENT = 27
/**
* DECISION (user): production shows only active products; staging shows
* everything except retired ones so drafts can be reviewed there.
*/
export function showableStatuses(deployEnv: string | undefined = process.env.NEXT_PUBLIC_DEPLOY_ENV): ProductStatus[] {
return deployEnv === 'staging' ? PRODUCT_STATUSES.filter((s) => s !== 'retired') : ['active']
}
/** Gross price from the stored net amount (whole forints). */
export function grossAmount(netAmount: number, vatRatePercent: number = DEFAULT_VAT_RATE_PERCENT): number {
return Math.round(netAmount * (1 + vatRatePercent / 100))
}
/** "14 900 Ft" (hu) / "14,900 Ft" (en). */
export function formatHuf(amount: number, locale: Locale): string {
const number = new Intl.NumberFormat(locale === 'hu' ? 'hu-HU' : 'en-GB', { maximumFractionDigits: 0 }).format(amount)
return `${number} Ft`
}
type Localized<T> = T | null | undefined
export type ProductDoc = {
id: string | number
slug: string
name: string
productType?: string | null
status?: string | null
sortOrder?: number | null
highlighted?: boolean | null
enTranslationStatus?: string | null
public?: {
audience?: Localized<string>
shortDescription?: Localized<string>
features?: { value: string }[] | null
ctaText?: Localized<string>
} | null
pricing?: { netAmount?: number | null; billingPeriod?: string | null } | null
serviceDefinition?: {
storageGb?: number | null
mailStorageGb?: number | null
domains?: number | null
domainAliases?: number | null
databases?: number | null
mailboxes?: number | null
backup?: Localized<string>
ssl?: boolean | null
spamFilter?: boolean | null
} | null
}
export type HostingPlanView = {
id: string
slug: string
name: string
highlighted: boolean
audience: string
shortDescription: string
features: string[]
ctaText: string
netAmount: number
billingPeriod: BillingPeriod
service: {
storageGb?: number
mailStorageGb?: number
domains?: number
domainAliases?: number
databases?: number
mailboxes?: number
backup?: string
ssl: boolean
spamFilter: boolean
}
}
const orUndefined = (value: number | null | undefined) => (value ?? undefined)
function toView(doc: ProductDoc): HostingPlanView {
const s = doc.serviceDefinition ?? {}
const period = doc.pricing?.billingPeriod
return {
id: String(doc.id),
slug: doc.slug,
name: doc.name,
highlighted: doc.highlighted === true,
audience: doc.public?.audience ?? '',
shortDescription: doc.public?.shortDescription ?? '',
features: (doc.public?.features ?? []).map((f) => f.value),
ctaText: doc.public?.ctaText ?? '',
netAmount: doc.pricing?.netAmount ?? 0,
billingPeriod: (BILLING_PERIODS as readonly string[]).includes(period ?? '') ? (period as BillingPeriod) : 'yearly',
service: {
storageGb: orUndefined(s.storageGb),
mailStorageGb: orUndefined(s.mailStorageGb),
domains: orUndefined(s.domains),
domainAliases: orUndefined(s.domainAliases),
databases: orUndefined(s.databases),
mailboxes: orUndefined(s.mailboxes),
backup: s.backup ?? undefined,
ssl: s.ssl === true,
spamFilter: s.spamFilter === true,
},
}
}
/**
* Hosting products for `locale`, gated and ordered. The translation gate
* works per product: `requested` holds the docs read in the requested
* locale, `fallback` the same docs in the default locale (only needed for
* English).
*/
export function hostingPlanViews(
locale: Locale,
requested: readonly ProductDoc[],
fallback: readonly ProductDoc[] = [],
statuses: readonly string[] = showableStatuses(),
): HostingPlanView[] {
const fallbackById = new Map(fallback.map((doc) => [String(doc.id), doc]))
return requested
.filter((doc) => doc.productType === 'hosting' && statuses.includes(doc.status ?? ''))
.filter((doc) => typeof doc.pricing?.netAmount === 'number')
.map((doc) => (contentLocale(locale, doc.enTranslationStatus) === locale ? doc : fallbackById.get(String(doc.id)) ?? doc))
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0))
.map(toView)
}