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
@@ -2,24 +2,24 @@
## 1. Adatmodell és kapu
- [ ] 1.1 A `Products` collection (D1) és a `HostingPlans` global (D4) elkészítése és regisztrálása, a típusok újragenerálása. Ellenőrzés: config tesztek (mezők, lokalizációs szabály, a státusz alapértéke `draft`, `productType` opciók, a `pricing.netAmount` kötelező, a `vatRatePercent` alapértéke 27), `tsc`.
- [ ] 1.2 `src/lib/products.ts`: `showableStatuses`, termékenkénti nyelvi kapu, `getHostingPlans`, `hasHostingPlans` (D2). Unit tesztek: production csak `active`; staging minden, kivéve `retired`; `managed-service` kiszűrve; `sortOrder`; approved → en, egyébként hu; `grossAmount` (14 900 → 18 923, 23 900 → 30 353, kerekítés). Ellenőrzés: `npm test`.
- [x] 1.1 A `Products` collection (D1) és a `HostingPlans` global (D4) elkészítése és regisztrálása, a típusok újragenerálása. Ellenőrzés: config tesztek (mezők, lokalizációs szabály, a státusz alapértéke `draft`, `productType` opciók, a `pricing.netAmount` kötelező, a `vatRatePercent` alapértéke 27), `tsc`.
- [x] 1.2 `src/lib/products.ts`: `showableStatuses`, termékenkénti nyelvi kapu, `getHostingPlans`, `hasHostingPlans` (D2). Unit tesztek: production csak `active`; staging minden, kivéve `retired`; `managed-service` kiszűrve; `sortOrder`; approved → en, egyébként hu; `grossAmount` (14 900 → 18 923, 23 900 → 30 353, kerekítés). Ellenőrzés: `npm test`.
## 2. Útvonal, menü, sitemap
- [ ] 2.1 `PAGE_SLUGS.hostingPlans`, feltételes menüpont (`getMainNavigation(locale, { hostingPlans })`), feltételes sitemap-bejegyzés (`sitemapEntries(…, hiddenPages)`) és a layout/sitemap bekötése (D3). A meglévő i18n-, seo- és Header-tesztek frissítése, új tesztek a rejtett és a látható esetre. A production SEO-csomag 12-es fix elvárásának átírása „legalább 12”-re. Ellenőrzés: `npm test`, `tsc`, lint.
- [x] 2.1 `PAGE_SLUGS.hostingPlans`, feltételes menüpont (`getMainNavigation(locale, { hostingPlans })`), feltételes sitemap-bejegyzés (`sitemapEntries(…, hiddenPages)`) és a layout/sitemap bekötése (D3). A meglévő i18n-, seo- és Header-tesztek frissítése, új tesztek a rejtett és a látható esetre. A production SEO-csomag 12-es fix elvárásának átírása „legalább 12”-re. Ellenőrzés: `npm test`, `tsc`, lint.
## 3. Oldal
- [ ] 3.1 `HostingPlansView` és a catch-all oldal ága (`hostingPlans` kulcs): 404, ha nincs megjeleníthető csomag; `generateMetadata` a globalból, `pageAlternates`-szel (D5). Komponensteszt: két kártya, összehasonlító sorok, kiemelés, nettó ár „+ ÁFA / év” és bruttó ár (hu és en formázás), „Kérjen ajánlatot” csak a nagyobb igény blokkban. Ellenőrzés: `npm test`.
- [x] 3.1 `HostingPlansView` és a catch-all oldal ága (`hostingPlans` kulcs): 404, ha nincs megjeleníthető csomag; `generateMetadata` a globalból, `pageAlternates`-szel (D5). Komponensteszt: két kártya, összehasonlító sorok, kiemelés, nettó ár „+ ÁFA / év” és bruttó ár (hu és en formázás), „Kérjen ajánlatot” csak a nagyobb igény blokkban. Ellenőrzés: `npm test`.
## 4. Kezdőadatok
- [ ] 4.1 A `20260929_hosting_plans` migráció (D6): két `draft` termék a PLATFM-14 (0.1.1) adataival és áraival, a global szövegei hu + en nyelven, `vatRatePercent` 27; az en AI-draft; idempotens; a fordítási memória bővítése. Unit teszt a fake Mongóval (létrehozás, meglévő slugot nem ír felül, második futás 0). Ellenőrzés: `npm test`.
- [x] 4.1 A `20260929_hosting_plans` migráció (D6): két `draft` termék a PLATFM-14 (0.1.1) adataival és áraival, a global szövegei hu + en nyelven, `vatRatePercent` 27; az en AI-draft; idempotens; a fordítási memória bővítése. Unit teszt a fake Mongóval (létrehozás, meglévő slugot nem ír felül, második futás 0). Ellenőrzés: `npm test`.
## 5. Élő ellenőrzés és lezárás
- [ ] 5.1 A staging-másolaton (eldobható konténer):
- [x] 5.1 A staging-másolaton (eldobható konténer):
- production-módú build: az oldal 404, nincs benne a menüben és a sitemapben (draft);
- staging-módú build: az oldal a két csomaggal látszik, és benne van a menüben;
- a nyelvváltó `/hu/tarhely-csomagok` ↔ `/en/hosting-plans`;
+2 -1
View File
@@ -28,7 +28,8 @@ test('robots.txt allows crawling and points to the sitemap', async ({ request, b
test('every sitemap URL is final, indexable and correctly annotated', async ({ request, baseURL }) => {
const urls = locs(await text(request, '/sitemap.xml'))
expect(urls).toHaveLength(12)
// MITHOME-130: 12 core URLs, +2 once a hosting plan is active.
expect(urls.length).toBeGreaterThanOrEqual(12)
for (const url of urls) {
expect(url.startsWith(`${baseURL}/`), `${url} is on ${baseURL}`).toBe(true)
+13
View File
@@ -100,6 +100,19 @@ test('SMOKE-09: hreflang alternates and staging noindex', async ({ page, request
expect(robots).not.toContain('Sitemap:')
})
// MITHOME-130: staging shows the draft hosting plans for review (production
// shows only active ones), with the menu item and both languages.
test('SMOKE-10: hosting plans page and menu item', async ({ page }) => {
await page.goto('/hu')
await page.getByRole('navigation').getByRole('link', { name: 'Tárhelycsomagok' }).first().click()
await expect(page).toHaveURL(/\/hu\/tarhely-csomagok$/)
await expect(page.getByRole('heading', { level: 2, name: 'mIT Start' })).toBeVisible()
await expect(page.getByRole('heading', { level: 2, name: 'mIT Mid' })).toBeVisible()
await expect(page.getByText(/\+ ÁFA \/ év/).first()).toBeVisible()
const english = page.getByRole('group', { name: 'Nyelv kiválasztása' }).first().getByRole('link', { name: 'English' })
await expect(english).toHaveAttribute('href', '/en/hosting-plans')
})
test('SMOKE-05: empty contact form is blocked client-side without API submission', async ({ page }) => {
let contactPostCount = 0
page.on('request', request => {
@@ -0,0 +1,74 @@
import { HOSTING_PLAN_SEEDS, productData, up } from '../migrations/20260929_hosting_plans'
type Doc = Record<string, unknown>
/** Minimal Local API stand-in: products by slug + one global. */
function fakePayload(products: Doc[] = [], page: Doc = {}) {
const payload = {
find: jest.fn(async ({ where }: { where: { slug: { equals: string } } }) => ({
docs: products.filter((p) => p.slug === where.slug.equals),
})),
create: jest.fn(async ({ data }: { data: Doc }) => {
const doc = { id: `id-${products.length}`, ...data }
products.push(doc)
return doc
}),
update: jest.fn(async () => ({})),
findGlobal: jest.fn(async () => page),
updateGlobal: jest.fn(async ({ data, locale }: { data: Doc; locale: string }) => {
if (locale === 'hu') Object.assign(page, data)
return page
}),
logger: { info: jest.fn(), warn: jest.fn() },
}
return { payload, args: { payload, req: {} } as never }
}
describe('20260929_hosting_plans migration (MITHOME-130)', () => {
it('should seed the catalogue figures and prices as a draft, with an English AI draft', () => {
const start = productData(HOSTING_PLAN_SEEDS[0], 'hu')
expect(start).toMatchObject({
slug: 'mit-start',
productType: 'hosting',
status: 'draft',
enTranslationStatus: 'ai-draft',
pricing: { netAmount: 14900, billingPeriod: 'yearly' },
serviceDefinition: { storageGb: 3, mailStorageGb: 1, databases: 1, mailboxes: 5, ssl: true, spamFilter: true },
_status: 'published',
})
expect(productData(HOSTING_PLAN_SEEDS[1], 'hu')).toMatchObject({
highlighted: true,
pricing: { netAmount: 23900 },
serviceDefinition: { storageGb: 8, mailStorageGb: 4, domainAliases: 2, databases: 2, mailboxes: 10 },
})
})
it('should write only localized fields in English', () => {
const en = productData(HOSTING_PLAN_SEEDS[0], 'en')
expect(Object.keys(en).sort()).toEqual(['_status', 'public', 'serviceDefinition'])
expect(en.serviceDefinition).toEqual({ backup: 'Daily, with 7-day restore' })
})
it('should create the missing products and page copy once', async () => {
const products: Doc[] = []
const { args, payload } = fakePayload(products)
await up(args)
expect(payload.create).toHaveBeenCalledTimes(2)
expect(payload.update).toHaveBeenCalledWith(expect.objectContaining({ locale: 'en' }))
expect(payload.updateGlobal).toHaveBeenCalledWith(
expect.objectContaining({ locale: 'hu', data: expect.objectContaining({ vatRatePercent: 27, hero: expect.objectContaining({ title: 'Tárhelycsomagok' }) }) }),
)
expect(payload.logger.info).toHaveBeenLastCalledWith('MITHOME-130 hosting plans: 2 product(s) created, 1 page copy seeded')
await up(args)
expect(payload.create).toHaveBeenCalledTimes(2)
expect(payload.logger.info).toHaveBeenLastCalledWith('MITHOME-130 hosting plans: 0 product(s) created, 0 page copy seeded')
})
it('should not overwrite an existing product or edited page copy', async () => {
const { args, payload } = fakePayload([{ id: 'x', slug: 'mit-start', pricing: { netAmount: 1 } }], { hero: { title: 'Saját cím' } })
await up(args)
expect(payload.create).toHaveBeenCalledTimes(1)
expect(payload.updateGlobal).not.toHaveBeenCalled()
})
})
@@ -4,6 +4,7 @@ import AboutView from '@/components/views/AboutView'
import ServicesView from '@/components/views/ServicesView'
import ContactView from '@/components/views/ContactView'
import LegalPageView from '@/components/views/LegalPageView'
import HostingPlansView from '@/components/views/HostingPlansView'
import { resolvePageKey, isLocale, localePath, type Locale } from '@/lib/i18n'
import { absoluteUrl, pageAlternates } from '@/lib/seo'
import {
@@ -13,6 +14,8 @@ import {
getHomeContent,
getCommonContent,
getLegalPage,
getHostingPlans,
getHostingPlansContent,
} from '@/lib/payload-content'
import { siteConfig, getOgLocale } from '@/config/site'
@@ -65,6 +68,10 @@ export async function generateMetadata({ params }: { params: Promise<Params> }):
const contact = await getContactContent(locale)
return base(contact.meta.title, contact.meta.description)
}
if (key === 'hostingPlans') {
const plans = await getHostingPlansContent(locale)
return plans.meta ? base(plans.meta.title, plans.meta.description) : {}
}
if (key === 'privacy') {
const page = await getLegalPage('adatvedelem', locale)
return base(page?.title ?? 'Adatvédelem', LEGAL_META.privacy[locale])
@@ -103,6 +110,13 @@ export default async function CatchAllPage({ params }: { params: Promise<Params>
)
}
// MITHOME-130: not found while no plan is showable (the menu and sitemap follow the same gate).
if (key === 'hostingPlans') {
const [content, plans] = await Promise.all([getHostingPlansContent(locale), getHostingPlans(locale)])
if (plans.length === 0) notFound()
return <HostingPlansView content={content} plans={plans} locale={locale} />
}
if (key === 'contact') {
const [content, home, common] = await Promise.all([
getContactContent(locale),
+4 -3
View File
@@ -2,7 +2,7 @@ import { notFound } from 'next/navigation'
import Header from '../../../components/Header'
import Footer from '../../../components/Footer'
import { isLocale, localePath, type Locale } from '@/lib/i18n'
import { getCommonContent, getHomeContent } from '@/lib/payload-content'
import { getCommonContent, getHomeContent, hasHostingPlans } from '@/lib/payload-content'
import { siteConfig, getMainNavigation, getFooterNavigation, getFooterLegalLinks, getSiteDescription, getLanguageSwitcherLabel } from '@/config/site'
// WHY force-dynamic (MITHOME-97): ezek az oldalak a Payload Local API-t hívják
@@ -25,9 +25,10 @@ export default async function LocaleLayout({
if (!isLocale(rawLocale)) notFound()
const locale: Locale = rawLocale
const [common, home] = await Promise.all([
const [common, home, hostingPlans] = await Promise.all([
getCommonContent(locale),
getHomeContent(locale),
hasHostingPlans(), // MITHOME-130: menu item only while the page has a plan
])
const isStaging = process.env.NEXT_PUBLIC_DEPLOY_ENV === 'staging'
@@ -40,7 +41,7 @@ export default async function LocaleLayout({
</div>
)}
<Header
nav={getMainNavigation(locale)}
nav={getMainNavigation(locale, { hostingPlans })}
homeHref={localePath(locale)}
a11y={common.a11y}
languageLabel={getLanguageSwitcherLabel(locale)}
+8 -2
View File
@@ -1,8 +1,14 @@
import type { MetadataRoute } from 'next'
import { isIndexingDisabled, sitemapEntries } from '@/lib/seo'
import { hasHostingPlans } from '@/lib/payload-content'
// MITHOME-116: /sitemap.xml — every page in hu + en with hreflang alternates.
// Staging publishes no sitemap (DECISION: staging is never indexed).
export default function sitemap(): MetadataRoute.Sitemap {
return isIndexingDisabled() ? [] : sitemapEntries()
// MITHOME-130: the hosting plans page is listed only while it has a showable
// plan; force-dynamic because that is a live Payload read (no build-time DB).
export const dynamic = 'force-dynamic'
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
if (isIndexingDisabled()) return []
return sitemapEntries(undefined, (await hasHostingPlans()) ? [] : ['hostingPlans'])
}
+124
View File
@@ -0,0 +1,124 @@
import type { CollectionConfig, NumberFieldSingleValidation } from 'payload'
import { collectionVersions } from '../lib/payload-versions'
import {
BILLING_PERIOD_LABELS,
BILLING_PERIODS,
PRODUCT_STATUS_LABELS,
PRODUCT_STATUSES,
PRODUCT_TYPE_LABELS,
PRODUCT_TYPES,
} from '../lib/products'
import { stringArrayField } from '../globals/fields/stringArray'
import { translationStatusField } from '../globals/fields/translationStatus'
const wholeForints: NumberFieldSingleValidation = (value) =>
value === null || value === undefined || (Number.isInteger(value) && value >= 0) || 'Egész, nem negatív forintösszeget adj meg.'
const count = (name: string, label: string) => ({ name, label, type: 'number' as const, min: 0 })
/**
* MITHOME-130: hosting (and later managed-service) products.
*
* Interim mirror of the central product catalogue (mitplatform PLATFM-14,
* docs/architecture/product-catalog-contract.md) — same structure, so the
* data source can be swapped later. Prices and service figures come from
* the catalogue; change them there first.
*
* WHY two statuses: Payload's own `_status` (draft/published) only decides
* which version of the record is saved; `status` is the product lifecycle
* and decides where the product is shown (src/lib/products.ts).
* Internal operations data (runbooks, owners, costs) never goes here.
*/
export const Products: CollectionConfig = {
slug: 'products',
labels: { singular: 'Termék', plural: 'Termékek' },
admin: {
useAsTitle: 'name',
group: 'Oldalak',
defaultColumns: ['name', 'productType', 'status', 'sortOrder'],
},
versions: collectionVersions,
fields: [
{ name: 'name', label: 'Név', type: 'text', required: true, admin: { description: 'Márkanév, minden nyelven azonos (pl. „mIT Start”).' } },
{
name: 'slug',
label: 'Azonosító',
type: 'text',
required: true,
unique: true,
admin: { position: 'sidebar', description: 'Stabil azonosító a központi katalógusból (pl. mit-start). Ne változtasd.' },
},
{
name: 'productType',
label: 'Terméktípus',
type: 'select',
required: true,
defaultValue: 'hosting',
options: PRODUCT_TYPES.map((value) => ({ label: PRODUCT_TYPE_LABELS[value], value })),
admin: { position: 'sidebar' },
},
{
name: 'status',
label: 'Életciklus-állapot',
type: 'select',
required: true,
defaultValue: 'draft',
options: PRODUCT_STATUSES.map((value) => ({ label: PRODUCT_STATUS_LABELS[value], value })),
admin: {
position: 'sidebar',
description:
'Az éles oldalon csak az „Aktív” termék jelenik meg; a staging a „Kivezetett” kivételével mindent mutat. ' +
'Aktívra csak üzleti jóváhagyás és a név védjegyvizsgálata után állítsd.',
},
},
{ name: 'sortOrder', label: 'Sorrend', type: 'number', defaultValue: 0, admin: { position: 'sidebar' } },
{ name: 'highlighted', label: 'Ajánlott csomag', type: 'checkbox', defaultValue: false, admin: { position: 'sidebar' } },
{
name: 'public',
label: 'Publikus szövegek',
type: 'group',
fields: [
{ name: 'audience', label: 'Kinek szól', type: 'text', required: true, localized: true },
{ name: 'shortDescription', label: 'Rövid leírás', type: 'textarea', required: true, localized: true },
stringArrayField('features', 'Kiemelt jellemzők', { localized: true }),
{ name: 'ctaText', label: 'Gomb felirata', type: 'text', required: true, localized: true },
{ name: 'seoDescription', label: 'SEO-leírás', type: 'textarea', localized: true },
],
},
{
name: 'pricing',
label: 'Ár',
type: 'group',
admin: { description: 'Nettó ár; a bruttót az oldal számolja az ÁFA-kulcsból (Tárhelycsomagok oldal beállítása).' },
fields: [
{ name: 'netAmount', label: 'Nettó ár (Ft)', type: 'number', required: true, min: 0, validate: wholeForints },
{
name: 'billingPeriod',
label: 'Számlázási periódus',
type: 'select',
required: true,
defaultValue: 'yearly',
options: BILLING_PERIODS.map((value) => ({ label: BILLING_PERIOD_LABELS[value], value })),
},
],
},
{
name: 'serviceDefinition',
label: 'Szolgáltatás',
type: 'group',
fields: [
count('storageGb', 'Tárhely összesen (GB)'),
count('mailStorageGb', 'Ebből levelezés (GB)'),
count('domains', 'Domain'),
count('domainAliases', 'Domain-alias'),
count('databases', 'Adatbázis'),
count('mailboxes', 'E-mail-fiók (legfeljebb)'),
{ name: 'backup', label: 'Mentés', type: 'text', localized: true },
{ name: 'ssl', label: 'SSL-tanúsítvány', type: 'checkbox', defaultValue: false },
{ name: 'spamFilter', label: 'Spamszűrés', type: 'checkbox', defaultValue: false },
],
},
translationStatusField(),
],
}
@@ -0,0 +1,66 @@
import { render, screen, within } from '@testing-library/react'
import '@testing-library/jest-dom'
import HostingPlansView from './HostingPlansView'
import { HOSTING_PLANS_PAGE_COPY, pickLanguage } from '@/migrations/20260929_hosting_plans'
import type { HostingPlanView } from '@/lib/products'
type Content = Parameters<typeof HostingPlansView>[0]['content']
const content = (lang: 'hu' | 'en') =>
({ ...pickLanguage(HOSTING_PLANS_PAGE_COPY as never, lang), vatRatePercent: 27 }) as unknown as Content
const plan = (over: Partial<HostingPlanView>): HostingPlanView => ({
id: 'start',
slug: 'mit-start',
name: 'mIT Start',
highlighted: false,
audience: 'Egyéni vállalkozóknak',
shortDescription: 'Tárhely egy weboldalhoz.',
features: ['Spamszűrés'],
ctaText: 'Ezt választom',
netAmount: 14900,
billingPeriod: 'yearly',
service: { storageGb: 3, mailStorageGb: 1, domains: 1, domainAliases: 0, databases: 1, mailboxes: 5, backup: 'Napi', ssl: true, spamFilter: true },
...over,
})
const PLANS = [plan({}), plan({ id: 'mid', slug: 'mit-mid', name: 'mIT Mid', highlighted: true, netAmount: 23900, service: { storageGb: 8, mailboxes: 10, ssl: true, spamFilter: true } })]
const text = (el: HTMLElement) => (el.textContent ?? '').replace(/\s/g, ' ')
describe('HostingPlansView (MITHOME-130)', () => {
it('should show both plans as cards with their comparison rows', () => {
render(<HostingPlansView content={content('hu')} plans={PLANS} locale="hu" />)
expect(screen.getByRole('heading', { level: 1, name: 'Tárhelycsomagok' })).toBeInTheDocument()
const start = screen.getByTestId('plan-mit-start')
expect(within(start).getByRole('heading', { name: 'mIT Start' })).toBeInTheDocument()
expect(text(start)).toContain('Tárhely összesen3 GB')
expect(text(start)).toContain('E-mail-fiók (legfeljebb)5')
expect(text(screen.getByTestId('plan-mit-mid'))).toContain('Tárhely összesen8 GB')
})
it('should show the net price with VAT and the gross price per year', () => {
render(<HostingPlansView content={content('hu')} plans={PLANS} locale="hu" />)
const start = text(screen.getByTestId('plan-mit-start'))
expect(start).toContain('14 900 Ft + ÁFA / év')
expect(start).toContain('bruttó 18 923 Ft / év')
expect(text(screen.getByTestId('plan-mit-mid'))).toContain('bruttó 30 353 Ft / év')
})
it('should format the English page and mark only the highlighted plan', () => {
render(<HostingPlansView content={content('en')} plans={PLANS} locale="en" />)
expect(text(screen.getByTestId('plan-mit-start'))).toContain('14,900 Ft + VAT / year')
expect(within(screen.getByTestId('plan-mit-mid')).getByText('Recommended')).toBeInTheDocument()
expect(within(screen.getByTestId('plan-mit-start')).queryByText('Recommended')).not.toBeInTheDocument()
})
it('should offer a custom quote only for larger needs, linking to the contact page', () => {
render(<HostingPlansView content={content('hu')} plans={PLANS} locale="hu" />)
expect(screen.getAllByText(/ajánlat/i)).toHaveLength(2) // larger-needs text + button, never a card
expect(screen.getByRole('link', { name: 'Kérjen egyedi ajánlatot' })).toHaveAttribute('href', '/hu/kapcsolat')
for (const card of [screen.getByTestId('plan-mit-start'), screen.getByTestId('plan-mit-mid')]) {
expect(within(card).queryByText(/ajánlat/i)).not.toBeInTheDocument()
expect(within(card).getByRole('link', { name: 'Ezt választom' })).toHaveAttribute('href', '/hu/kapcsolat')
}
})
})
@@ -0,0 +1,128 @@
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<ReturnType<typeof getHostingPlansContent>>
type Labels = Content['labels']
type HostingPlansViewProps = {
content: Content
plans: HostingPlanView[]
locale: Locale
}
const PERIOD_LABEL: Record<BillingPeriod, keyof Labels> = {
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 (
<div className="space-y-16 py-8">
<section className="bg-gradient-to-r from-blue-50 to-indigo-50 py-16">
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
<h1 className="text-4xl md:text-5xl font-bold text-gray-900 mb-6">{content.hero.title}</h1>
<p className="text-xl text-gray-600 leading-relaxed">{content.hero.subtitle}</p>
</div>
</section>
<section className="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8">
<ul className="grid grid-cols-1 md:grid-cols-2 gap-8">
{plans.map((plan) => {
const period = labels[PERIOD_LABEL[plan.billingPeriod]]
return (
<li
key={plan.id}
data-testid={`plan-${plan.slug}`}
className={`relative flex flex-col bg-white rounded-xl p-8 shadow-sm border ${plan.highlighted ? 'border-blue-600 ring-2 ring-blue-600' : 'border-gray-200'}`}
>
{plan.highlighted && (
<span className="absolute -top-3 left-8 rounded-full bg-blue-600 px-3 py-1 text-xs font-semibold text-white">
{labels.recommended}
</span>
)}
<h2 className="text-2xl font-bold text-gray-900">{plan.name}</h2>
<p className="mt-1 text-sm font-medium text-blue-700">{plan.audience}</p>
<p className="mt-4 text-gray-600">{plan.shortDescription}</p>
<p className="mt-6">
<span className="text-3xl font-bold text-gray-900">{formatHuf(plan.netAmount, locale)}</span>{' '}
<span className="text-gray-700">{labels.plusVat} {period}</span>
</p>
<p className="text-sm text-gray-500">
{labels.grossPrice} {formatHuf(grossAmount(plan.netAmount, vatRate), locale)} {period}
</p>
<dl className="mt-6 divide-y divide-gray-100 border-y border-gray-100">
{comparisonRows(plan, labels).map(([term, value]) => (
<div key={term} className="flex justify-between gap-4 py-2 text-sm">
<dt className="text-gray-600">{term}</dt>
<dd className="font-medium text-gray-900 text-right">{value}</dd>
</div>
))}
</dl>
{plan.features.length > 0 && (
<ul className="mt-6 space-y-2">
{plan.features.map((feature) => (
<li key={feature} className="flex items-start text-gray-700">
<span className="text-blue-500 mr-3" aria-hidden="true">✓</span>
{feature}
</li>
))}
</ul>
)}
<a
href={contactHref}
className={`mt-8 inline-flex justify-center rounded-lg px-6 py-3 font-semibold transition-colors ${plan.highlighted ? 'bg-blue-600 text-white hover:bg-blue-700' : 'border border-blue-600 text-blue-700 hover:bg-blue-50'}`}
>
{plan.ctaText}
</a>
</li>
)
})}
</ul>
<p className="mt-6 text-center text-sm text-gray-500">{labels.priceNote}</p>
</section>
<section className="bg-gray-50 py-16">
<div className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
<h2 className="text-3xl font-bold text-gray-900 mb-4">{content.largerNeeds.title}</h2>
<p className="text-lg text-gray-600 mb-8">{content.largerNeeds.text}</p>
<a
href={contactHref}
className="inline-flex rounded-lg bg-blue-600 px-8 py-3 font-semibold text-white hover:bg-blue-700 transition-colors"
>
{content.largerNeeds.button}
</a>
</div>
</section>
</div>
)
}
+19
View File
@@ -0,0 +1,19 @@
import { getMainNavigation } from './site'
describe('main navigation (MITHOME-130)', () => {
it('should hide the hosting plans item unless a plan is showable', () => {
expect(getMainNavigation('hu').map((item) => item.href)).not.toContain('/hu/tarhely-csomagok')
expect(getMainNavigation('hu', { hostingPlans: false }).map((item) => item.label)).not.toContain('Tárhelycsomagok')
})
it('should place the hosting plans item right after services, in both languages', () => {
expect(getMainNavigation('hu', { hostingPlans: true }).map((item) => item.href)).toEqual([
'/hu',
'/hu/rolunk',
'/hu/szolgaltatasok',
'/hu/tarhely-csomagok',
'/hu/kapcsolat',
])
expect(getMainNavigation('en', { hostingPlans: true })[3]).toEqual({ label: 'Hosting plans', href: '/en/hosting-plans' })
})
})
+9 -4
View File
@@ -37,9 +37,9 @@ export function getOgLocale(locale: Locale): string {
return locale === 'hu' ? 'hu-HU' : 'en-US'
}
const NAV_LABELS: Record<Locale, { home: string; about: string; services: string; contact: string; privacy: string; terms: string }> = {
hu: { home: 'Kezdőlap', about: 'Rólunk', services: 'Szolgáltatások', contact: 'Kapcsolat', privacy: 'Adatvédelmi tájékoztató', terms: 'Használati feltételek' },
en: { home: 'Home', about: 'About', services: 'Services', contact: 'Contact', privacy: 'Privacy Policy', terms: 'Terms of Service' },
const NAV_LABELS: Record<Locale, { home: string; about: string; services: string; hostingPlans: string; contact: string; privacy: string; terms: string }> = {
hu: { home: 'Kezdőlap', about: 'Rólunk', services: 'Szolgáltatások', hostingPlans: 'Tárhelycsomagok', contact: 'Kapcsolat', privacy: 'Adatvédelmi tájékoztató', terms: 'Használati feltételek' },
en: { home: 'Home', about: 'About', services: 'Services', hostingPlans: 'Hosting plans', contact: 'Contact', privacy: 'Privacy Policy', terms: 'Terms of Service' },
}
/** MITHOME-115: a nyelvválasztó csoportjának akadálymentes címkéje. */
@@ -52,12 +52,17 @@ export function getLanguageSwitcherLabel(locale: Locale): string {
return LANGUAGE_SWITCHER_LABELS[locale]
}
export function getMainNavigation(locale: Locale): NavigationItem[] {
/**
* MITHOME-130: the hosting plans item appears only while the page has a
* showable plan — the layout asks the same gate as the page (hasHostingPlans).
*/
export function getMainNavigation(locale: Locale, { hostingPlans = false }: { hostingPlans?: boolean } = {}): NavigationItem[] {
const t = NAV_LABELS[locale]
return [
{ label: t.home, href: localePath(locale) },
{ label: t.about, href: localePath(locale, 'about') },
{ label: t.services, href: localePath(locale, 'services') },
...(hostingPlans ? [{ label: t.hostingPlans, href: localePath(locale, 'hostingPlans') }] : []),
{ label: t.contact, href: localePath(locale, 'contact'), primary: true },
]
}
+33 -1
View File
@@ -203,5 +203,37 @@
"Technológiai háttér": "Infrastructure provider",
"Beszállító": "Supplier",
"Általunk használt technológia": "Technology we use",
"Szakmai partner": "Professional partner"
"Szakmai partner": "Professional partner",
"Tárhelycsomagok": "Hosting plans",
"mIT Start és mIT Mid tárhelycsomagok céges levelezéssel, napi mentéssel és személyes támogatással, átlátható éves díjjal.": "mIT Start and mIT Mid hosting plans with business email, daily backups and personal support, at a clear yearly price.",
"Két egyszerű csomag kis- és középvállalkozásoknak – napi mentéssel, céges levelezéssel és személyes támogatással.": "Two simple plans for small and medium-sized businesses – with daily backups, business email and personal support.",
"Tárhely összesen": "Total storage",
"Ebből levelezés": "Of which email",
"Domain": "Domains",
"Domain-alias": "Domain aliases",
"Adatbázis (MariaDB)": "Databases (MariaDB)",
"E-mail-fiók (legfeljebb)": "Mailboxes (up to)",
"Mentés": "Backups",
"SSL-tanúsítvány": "SSL certificate",
"Spamszűrés": "Spam filtering",
"/ év": "/ year",
"/ hó": "/ month",
"egyszeri díj": "one-off fee",
"+ ÁFA": "+ VAT",
"bruttó": "gross",
"Ajánlott": "Recommended",
"Benne van": "Included",
"Az árak éves díjak, 27% ÁFA-val számolva. A domain regisztrációja külön tétel.": "Prices are yearly fees, calculated with 27% Hungarian VAT. Domain registration is charged separately.",
"Nagyobb igénye van?": "Need more?",
"Webáruházhoz, nagyobb forgalomhoz vagy 8 GB feletti tárhelyhez egyedi ajánlatot készítünk.": "For an online shop, higher traffic or more than 8 GB of storage, we prepare a custom quote.",
"Kérjen egyedi ajánlatot": "Request a custom quote",
"Egyéni vállalkozóknak és kis bemutatkozó oldalaknak": "For sole traders and small presentation sites",
"Tárhely egy weboldalhoz, céges levelezéssel és napi mentéssel.": "Hosting for one website, with business email and daily backups.",
"Kisvállalkozásoknak, több postafiókkal és egy kiegészítő oldallal": "For small businesses with several mailboxes and an additional site",
"Nagyobb tárhely, két adatbázis és domain-aliasok egy növekvő céges jelenléthez.": "More storage, two databases and domain aliases for a growing business presence.",
"Ingyenes SSL-tanúsítvány": "Free SSL certificate",
"Napi mentés, 7 napos visszaállítás": "Daily backups with 7-day restore",
"Személyes, magyar nyelvű támogatás munkanapokon": "Personal support in Hungarian on weekdays",
"Ezt választom": "Choose this plan",
"Napi, 7 napos visszaállítással": "Daily, with 7-day restore"
}
+83
View File
@@ -0,0 +1,83 @@
import type { GlobalConfig } from 'payload'
import { globalVersions } from '../lib/payload-versions'
import { DEFAULT_VAT_RATE_PERCENT } from '../lib/products'
import { translationStatusField } from './fields/translationStatus'
const LABEL_FIELDS = [
'storage',
'mailStorage',
'domains',
'domainAliases',
'databases',
'mailboxes',
'backup',
'ssl',
'spamFilter',
'perYear',
'perMonth',
'oneTime',
'plusVat',
'grossPrice',
'recommended',
'included',
'priceNote',
] as const
export type HostingPlansLabel = (typeof LABEL_FIELDS)[number]
/**
* MITHOME-130: copy of the hosting plans page (/hu/tarhely-csomagok,
* /en/hosting-plans). The plans themselves live in the Products collection.
*/
export const HostingPlans: GlobalConfig = {
slug: 'hosting-plans',
label: 'Tárhelycsomagok oldal',
admin: { group: 'Oldalak' },
versions: globalVersions,
fields: [
{
name: 'meta',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'description', type: 'textarea', required: true, localized: true },
],
},
{
name: 'hero',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'subtitle', type: 'textarea', required: true, localized: true },
],
},
{
name: 'labels',
label: 'Feliratok',
type: 'group',
fields: LABEL_FIELDS.map((name) => ({ name, type: 'text' as const, required: true, localized: true })),
},
{
name: 'largerNeeds',
label: 'Nagyobb igény blokk',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'text', type: 'textarea', required: true, localized: true },
{ name: 'button', type: 'text', required: true, localized: true },
],
},
{
name: 'vatRatePercent',
label: 'ÁFA-kulcs (%)',
type: 'number',
required: true,
min: 0,
max: 100,
defaultValue: DEFAULT_VAT_RATE_PERCENT,
admin: { position: 'sidebar', description: 'A bruttó árak ebből számolódnak.' },
},
translationStatusField(),
],
}
+2
View File
@@ -6,6 +6,8 @@ const PAGE_LABELS: Record<CtaPage, string> = {
home: 'Főoldal',
about: 'Rólunk',
services: 'Szolgáltatások',
// MITHOME-130: 404 while no plan is showable — link to it only once a plan is active.
hostingPlans: 'Tárhelycsomagok (csak aktív csomaggal)',
contact: 'Kapcsolat',
privacy: 'Adatvédelem',
terms: 'Felhasználási feltételek',
+2
View File
@@ -19,6 +19,8 @@ describe('languageLinks (MITHOME-115)', () => {
{ locale: 'en', href: '/en/services', isActive: false },
])
expect(languageLinks('/en/privacy-policy').map((l) => l.href)).toEqual(['/hu/adatvedelem', '/en/privacy-policy'])
// MITHOME-130
expect(languageLinks('/hu/tarhely-csomagok').map((l) => l.href)).toEqual(['/hu/tarhely-csomagok', '/en/hosting-plans'])
})
it('should link the home pages from a home page', () => {
+3 -1
View File
@@ -17,13 +17,15 @@ export function isLocale(value: string): value is Locale {
}
/** A catch-all [slug] route alá tartozó oldalak azonosítói. */
export type PageKey = 'about' | 'services' | 'contact' | 'privacy' | 'terms'
export type PageKey = 'about' | 'services' | 'hostingPlans' | 'contact' | 'privacy' | 'terms'
/** Nyelvenkénti szlög minden oldalhoz — a nyelvváltó (MITHOME-115) és a
* sitemap/hreflang (MITHOME-116) is ezt a táblát fogja használni. */
export const PAGE_SLUGS: Record<PageKey, Record<Locale, string>> = {
about: { hu: 'rolunk', en: 'about' },
services: { hu: 'szolgaltatasok', en: 'services' },
// MITHOME-130: only reachable while a showable plan exists (src/lib/products.ts).
hostingPlans: { hu: 'tarhely-csomagok', en: 'hosting-plans' },
contact: { hu: 'kapcsolat', en: 'contact' },
privacy: { hu: 'adatvedelem', en: 'privacy-policy' },
terms: { hu: 'felhasznalasi-feltetelek', en: 'terms-of-service' },
+36 -1
View File
@@ -14,10 +14,11 @@
*/
import { getPayload } from 'payload'
import config from '@payload-config'
import type { Locale } from './i18n'
import { DEFAULT_LOCALE, type Locale } from './i18n'
import { resolveCtaHref, type CtaLink } from './cta-link'
import { readGated } from './translation-gate'
import { publicPartners, type PartnerView } from './partner-references'
import { hostingPlanViews, showableStatuses, type HostingPlanView, type ProductDoc } from './products'
let cached: ReturnType<typeof getPayload> | undefined
@@ -114,3 +115,37 @@ export async function getPartners(): Promise<PartnerView[]> {
const result = await payload.find({ collection: 'partners', limit: 100, sort: 'name', depth: 1 })
return publicPartners(result.docs)
}
export type { HostingPlanView } from './products'
/** MITHOME-130: raw hosting products in one locale, lifecycle-gated in the query. */
async function findHostingProducts(locale: Locale): Promise<ProductDoc[]> {
const payload = await payloadClient()
const result = await payload.find({
collection: 'products',
where: { productType: { equals: 'hosting' }, status: { in: showableStatuses() } },
sort: 'sortOrder',
locale,
limit: 50,
depth: 0,
})
return result.docs as unknown as ProductDoc[]
}
/** MITHOME-130: showable hosting plans; the English gate works per product. */
export async function getHostingPlans(locale: Locale): Promise<HostingPlanView[]> {
const requested = await findHostingProducts(locale)
const needsFallback = locale !== DEFAULT_LOCALE && requested.some((doc) => doc.enTranslationStatus !== 'approved')
const fallback = needsFallback ? await findHostingProducts(DEFAULT_LOCALE) : []
return hostingPlanViews(locale, requested, fallback)
}
/** The page, the menu item and the sitemap entry all follow this one gate. */
export async function hasHostingPlans(): Promise<boolean> {
return (await getHostingPlans(DEFAULT_LOCALE)).length > 0
}
export async function getHostingPlansContent(locale: Locale) {
const payload = await payloadClient()
return readGated(locale, (l) => payload.findGlobal({ slug: 'hosting-plans', locale: l }))
}
+77
View File
@@ -0,0 +1,77 @@
import { formatHuf, grossAmount, hostingPlanViews, showableStatuses, type ProductDoc } from './products'
const product = (over: Partial<ProductDoc> = {}): ProductDoc => ({
id: 'p1',
slug: 'mit-start',
name: 'mIT Start',
productType: 'hosting',
status: 'draft',
sortOrder: 10,
enTranslationStatus: 'ai-draft',
public: { audience: 'Kinek', shortDescription: 'Leírás', features: [{ value: 'SSL' }], ctaText: 'Ezt választom' },
pricing: { netAmount: 14900, billingPeriod: 'yearly' },
serviceDefinition: { storageGb: 3, mailboxes: 5, ssl: true },
...over,
})
const normalizeSpaces = (text: string) => text.replace(/\s/g, ' ')
describe('hosting plans (MITHOME-130)', () => {
it('should show only active products in production and everything but retired on staging', () => {
expect(showableStatuses(undefined)).toEqual(['active'])
expect(showableStatuses('production')).toEqual(['active'])
expect(showableStatuses('staging')).toEqual(['draft', 'internal', 'publishable', 'active'])
})
it('should compute the gross price from the net price and the VAT rate', () => {
expect(grossAmount(14900)).toBe(18923)
expect(grossAmount(23900, 27)).toBe(30353)
expect(grossAmount(10001, 27)).toBe(12701)
expect(grossAmount(1000, 0)).toBe(1000)
})
it('should format forint amounts per locale', () => {
expect(normalizeSpaces(formatHuf(14900, 'hu'))).toBe('14 900 Ft')
expect(formatHuf(14900, 'en')).toBe('14,900 Ft')
})
it('should gate by status and type, and order by sortOrder', () => {
const docs = [
product({ id: 'mid', slug: 'mit-mid', sortOrder: 20 }),
product({ id: 'start', sortOrder: 10 }),
product({ id: 'old', slug: 'old', status: 'retired' }),
product({ id: 'webor', slug: 'webor', productType: 'managed-service' }),
product({ id: 'live', slug: 'live', status: 'active', sortOrder: 30 }),
]
expect(hostingPlanViews('hu', docs, [], showableStatuses('staging')).map((p) => p.id)).toEqual(['start', 'mid', 'live'])
expect(hostingPlanViews('hu', docs, [], showableStatuses('production')).map((p) => p.id)).toEqual(['live'])
})
it('should never show a plan without a price', () => {
const docs = [product({ pricing: { netAmount: null, billingPeriod: 'yearly' } })]
expect(hostingPlanViews('hu', docs, [], ['draft'])).toEqual([])
})
it('should apply the English gate per product', () => {
const en = [
product({ id: 'a', public: { audience: 'EN draft' }, enTranslationStatus: 'ai-draft' }),
product({ id: 'b', public: { audience: 'EN approved' }, enTranslationStatus: 'approved', sortOrder: 20 }),
]
const hu = [product({ id: 'a', public: { audience: 'HU a' } }), product({ id: 'b', public: { audience: 'HU b' }, sortOrder: 20 })]
expect(hostingPlanViews('en', en, hu, ['draft']).map((p) => p.audience)).toEqual(['HU a', 'EN approved'])
expect(hostingPlanViews('hu', hu, [], ['draft']).map((p) => p.audience)).toEqual(['HU a', 'HU b'])
})
it('should build the view model with unwrapped features and service figures', () => {
const [view] = hostingPlanViews('hu', [product({ highlighted: true })], [], ['draft'])
expect(view).toMatchObject({
slug: 'mit-start',
highlighted: true,
features: ['SSL'],
netAmount: 14900,
billingPeriod: 'yearly',
service: { storageGb: 3, mailboxes: 5, ssl: true, spamFilter: false },
})
expect(view.service.databases).toBeUndefined()
})
})
+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)
}
+10 -1
View File
@@ -25,7 +25,7 @@ describe('SEO helpers (MITHOME-116)', () => {
it('should list every page in both languages in the sitemap', () => {
const entries = sitemapEntries(SITE)
expect(entries).toHaveLength(12)
expect(entries).toHaveLength(14)
expect(entries.map((e) => e.url)).toEqual(
expect.arrayContaining(['https://mozdit.hu/hu', 'https://mozdit.hu/en', 'https://mozdit.hu/en/privacy-policy', 'https://mozdit.hu/hu/felhasznalasi-feltetelek']),
)
@@ -33,6 +33,15 @@ describe('SEO helpers (MITHOME-116)', () => {
expect(privacy.alternates?.languages).toMatchObject({ hu: 'https://mozdit.hu/hu/adatvedelem' })
})
it('should leave hidden pages out of the sitemap (MITHOME-130)', () => {
const urls = sitemapEntries(SITE, ['hostingPlans']).map((e) => e.url)
expect(urls).toHaveLength(12)
expect(urls).not.toContain('https://mozdit.hu/hu/tarhely-csomagok')
expect(sitemapEntries(SITE).map((e) => e.url)).toEqual(
expect.arrayContaining(['https://mozdit.hu/hu/tarhely-csomagok', 'https://mozdit.hu/en/hosting-plans']),
)
})
it('should block all crawling on staging and publish the sitemap elsewhere', () => {
expect(isIndexingDisabled('staging')).toBe(true)
expect(isIndexingDisabled(undefined)).toBe(false)
+3 -2
View File
@@ -44,8 +44,9 @@ export function isIndexingDisabled(deployEnv: string | undefined = process.env.N
return deployEnv === 'staging'
}
export function sitemapEntries(siteUrl?: string): MetadataRoute.Sitemap {
return PAGES.flatMap((page) =>
/** MITHOME-130: `hiddenPages` are left out (e.g. hosting plans with no showable plan). */
export function sitemapEntries(siteUrl?: string, hiddenPages: readonly PageKey[] = []): MetadataRoute.Sitemap {
return PAGES.filter((page) => page === undefined || !hiddenPages.includes(page)).flatMap((page) =>
LOCALES.map((locale) => ({
url: absoluteUrl(localePath(locale, page), siteUrl),
changeFrequency: 'monthly' as const,
@@ -0,0 +1,176 @@
/**
* MITHOME-130: seed the hosting plans (mIT Start, mIT Mid) and the copy of
* the hosting plans page.
*
* Figures and prices come from the central catalogue — mitplatform
* docs/plans/PLATFM-14-products-v0.json, catalogVersion 0.1.1 (owner
* decision 2026-09-29: variant B, yearly billing, net + 27% VAT).
*
* - Products are created in the "draft" lifecycle status: staging shows
* them for review, production does not (src/lib/products.ts).
* - English is an AI draft (enTranslationStatus "ai-draft").
* - Only creates what is missing (product by slug, page copy when empty);
* never touches existing data. Idempotent.
*
* WHY the Local API (not rewriteDocs): these are new documents, and the
* Local API writes the version records and the Payload `_status` for us.
*/
import type { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/db-mongodb'
type Copy = { hu: string; en: string }
type ListCopy = { hu: string[]; en: string[] }
const FEATURES: ListCopy = {
hu: ['Ingyenes SSL-tanúsítvány', 'Spamszűrés', 'Napi mentés, 7 napos visszaállítás', 'Személyes, magyar nyelvű támogatás munkanapokon'],
en: ['Free SSL certificate', 'Spam filtering', 'Daily backups with 7-day restore', 'Personal support in Hungarian on weekdays'],
}
const BACKUP: Copy = { hu: 'Napi, 7 napos visszaállítással', en: 'Daily, with 7-day restore' }
const CTA: Copy = { hu: 'Ezt választom', en: 'Choose this plan' }
export const HOSTING_PLAN_SEEDS = [
{
slug: 'mit-start',
name: 'mIT Start',
sortOrder: 10,
highlighted: false,
audience: { hu: 'Egyéni vállalkozóknak és kis bemutatkozó oldalaknak', en: 'For sole traders and small presentation sites' },
shortDescription: {
hu: 'Tárhely egy weboldalhoz, céges levelezéssel és napi mentéssel.',
en: 'Hosting for one website, with business email and daily backups.',
},
netAmount: 14900,
service: { storageGb: 3, mailStorageGb: 1, domains: 1, domainAliases: 0, databases: 1, mailboxes: 5 },
},
{
slug: 'mit-mid',
name: 'mIT Mid',
sortOrder: 20,
highlighted: true,
audience: {
hu: 'Kisvállalkozásoknak, több postafiókkal és egy kiegészítő oldallal',
en: 'For small businesses with several mailboxes and an additional site',
},
shortDescription: {
hu: 'Nagyobb tárhely, két adatbázis és domain-aliasok egy növekvő céges jelenléthez.',
en: 'More storage, two databases and domain aliases for a growing business presence.',
},
netAmount: 23900,
service: { storageGb: 8, mailStorageGb: 4, domains: 1, domainAliases: 2, databases: 2, mailboxes: 10 },
},
] as const
export const HOSTING_PLANS_PAGE_COPY = {
meta: {
title: { hu: 'Tárhelycsomagok', en: 'Hosting plans' },
description: {
hu: 'mIT Start és mIT Mid tárhelycsomagok céges levelezéssel, napi mentéssel és személyes támogatással, átlátható éves díjjal.',
en: 'mIT Start and mIT Mid hosting plans with business email, daily backups and personal support, at a clear yearly price.',
},
},
hero: {
title: { hu: 'Tárhelycsomagok', en: 'Hosting plans' },
subtitle: {
hu: 'Két egyszerű csomag kis- és középvállalkozásoknak – napi mentéssel, céges levelezéssel és személyes támogatással.',
en: 'Two simple plans for small and medium-sized businesses – with daily backups, business email and personal support.',
},
},
labels: {
storage: { hu: 'Tárhely összesen', en: 'Total storage' },
mailStorage: { hu: 'Ebből levelezés', en: 'Of which email' },
domains: { hu: 'Domain', en: 'Domains' },
domainAliases: { hu: 'Domain-alias', en: 'Domain aliases' },
databases: { hu: 'Adatbázis (MariaDB)', en: 'Databases (MariaDB)' },
mailboxes: { hu: 'E-mail-fiók (legfeljebb)', en: 'Mailboxes (up to)' },
backup: { hu: 'Mentés', en: 'Backups' },
ssl: { hu: 'SSL-tanúsítvány', en: 'SSL certificate' },
spamFilter: { hu: 'Spamszűrés', en: 'Spam filtering' },
perYear: { hu: '/ év', en: '/ year' },
perMonth: { hu: '/ hó', en: '/ month' },
oneTime: { hu: 'egyszeri díj', en: 'one-off fee' },
plusVat: { hu: '+ ÁFA', en: '+ VAT' },
grossPrice: { hu: 'bruttó', en: 'gross' },
recommended: { hu: 'Ajánlott', en: 'Recommended' },
included: { hu: 'Benne van', en: 'Included' },
priceNote: {
hu: 'Az árak éves díjak, 27% ÁFA-val számolva. A domain regisztrációja külön tétel.',
en: 'Prices are yearly fees, calculated with 27% Hungarian VAT. Domain registration is charged separately.',
},
},
largerNeeds: {
title: { hu: 'Nagyobb igénye van?', en: 'Need more?' },
text: {
hu: 'Webáruházhoz, nagyobb forgalomhoz vagy 8 GB feletti tárhelyhez egyedi ajánlatot készítünk.',
en: 'For an online shop, higher traffic or more than 8 GB of storage, we prepare a custom quote.',
},
button: { hu: 'Kérjen egyedi ajánlatot', en: 'Request a custom quote' },
},
} as const
type Lang = 'hu' | 'en'
type Tree = { readonly [key: string]: Tree | Copy }
const isCopy = (node: Tree | Copy): node is Copy => typeof (node as Copy).hu === 'string'
/** One language of a { hu, en } copy tree. */
export function pickLanguage(tree: Tree, lang: Lang): Record<string, unknown> {
return Object.fromEntries(
Object.entries(tree).map(([key, node]) => [key, isCopy(node) ? node[lang] : pickLanguage(node, lang)]),
)
}
type Seed = (typeof HOSTING_PLAN_SEEDS)[number]
/** Product data for one language; shared fields only in the default locale. */
export function productData(seed: Seed, lang: Lang): Record<string, unknown> {
const localized = {
public: {
audience: seed.audience[lang],
shortDescription: seed.shortDescription[lang],
features: FEATURES[lang].map((value) => ({ value })),
ctaText: CTA[lang],
},
serviceDefinition: { backup: BACKUP[lang] },
}
if (lang === 'en') return { ...localized, _status: 'published' }
return {
slug: seed.slug,
name: seed.name,
productType: 'hosting',
status: 'draft',
sortOrder: seed.sortOrder,
highlighted: seed.highlighted,
enTranslationStatus: 'ai-draft',
public: localized.public,
pricing: { netAmount: seed.netAmount, billingPeriod: 'yearly' },
serviceDefinition: { ...seed.service, backup: BACKUP.hu, ssl: true, spamFilter: true },
_status: 'published',
}
}
export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
let created = 0
for (const seed of HOSTING_PLAN_SEEDS) {
const existing = await payload.find({ collection: 'products', where: { slug: { equals: seed.slug } }, limit: 1, depth: 0, req })
if (existing.docs.length > 0) continue
const doc = await payload.create({ collection: 'products', data: productData(seed, 'hu') as never, locale: 'hu', req })
await payload.update({ collection: 'products', id: doc.id, data: productData(seed, 'en') as never, locale: 'en', req })
created += 1
}
let pageSeeded = 0
const page = await payload.findGlobal({ slug: 'hosting-plans', locale: 'hu', depth: 0, req })
if (!page?.hero?.title) {
const copy = HOSTING_PLANS_PAGE_COPY as unknown as Tree
const hu = { ...pickLanguage(copy, 'hu'), vatRatePercent: 27, enTranslationStatus: 'ai-draft', _status: 'published' }
await payload.updateGlobal({ slug: 'hosting-plans', data: hu as never, locale: 'hu', req })
await payload.updateGlobal({ slug: 'hosting-plans', data: { ...pickLanguage(copy, 'en'), _status: 'published' } as never, locale: 'en', req })
pageSeeded = 1
}
payload.logger.info(`MITHOME-130 hosting plans: ${created} product(s) created, ${pageSeeded} page copy seeded`)
}
/** DECISION: no automatic down — restore the pre-deploy dump instead. */
export async function down({ payload }: MigrateDownArgs): Promise<void> {
payload.logger.warn('MITHOME-130 hosting plans: down is a no-op — restore the pre-deploy dump instead')
}
+7
View File
@@ -5,6 +5,7 @@ import * as migration_20260929_en_ai_draft from './20260929_en_ai_draft'
import * as migration_20260929_service_claims from './20260929_service_claims'
import * as migration_20260929_partner_references from './20260929_partner_references'
import * as migration_20260929_atlantisz_pending from './20260929_atlantisz_pending'
import * as migration_20260929_hosting_plans from './20260929_hosting_plans'
/**
* Payload migrations, in order. Passed to `mongooseAdapter({ prodMigrations })`
@@ -52,4 +53,10 @@ export const migrations = [
down: migration_20260929_atlantisz_pending.down,
name: '20260929_atlantisz_pending',
},
{
// MITHOME-130 — hosting plans (draft) + page copy, from the PLATFM-14 catalogue.
up: migration_20260929_hosting_plans.up,
down: migration_20260929_hosting_plans.down,
name: '20260929_hosting_plans',
},
]
+43 -8
View File
@@ -24,11 +24,13 @@ import { LegalPages } from './collections/LegalPages'
import { Media } from './collections/Media'
import { Partners } from './collections/Partners'
import { ContactSubmissions } from './collections/ContactSubmissions'
import { Products } from './collections/Products'
import { Home } from './globals/Home'
import { About } from './globals/About'
import { Services } from './globals/Services'
import { Contact } from './globals/Contact'
import { Common } from './globals/Common'
import { HostingPlans } from './globals/HostingPlans'
type FieldLike = { name?: string; required?: boolean; type?: string }
@@ -38,8 +40,8 @@ function findField(fields: unknown[], name: string): FieldLike | undefined {
describe('Payload collections', () => {
it('all collection slugs are present and unique', () => {
const slugs = [Users, LegalPages, Media, Partners, ContactSubmissions].map((c) => c.slug)
expect(slugs).toEqual(['users', 'legal-pages', 'media', 'partners', 'contact-submissions'])
const slugs = [Users, LegalPages, Media, Partners, ContactSubmissions, Products].map((c) => c.slug)
expect(slugs).toEqual(['users', 'legal-pages', 'media', 'partners', 'contact-submissions', 'products'])
expect(new Set(slugs).size).toBe(slugs.length)
})
@@ -130,8 +132,8 @@ describe('Payload collections', () => {
describe('Payload globals', () => {
it('all global slugs are present and unique', () => {
const slugs = [Home, About, Services, Contact, Common].map((g) => g.slug)
expect(slugs).toEqual(['home', 'about', 'services', 'contact', 'common'])
const slugs = [Home, About, Services, Contact, Common, HostingPlans].map((g) => g.slug)
expect(slugs).toEqual(['home', 'about', 'services', 'contact', 'common', 'hosting-plans'])
expect(new Set(slugs).size).toBe(slugs.length)
})
@@ -155,7 +157,8 @@ describe('Payload globals', () => {
// DECISION (design D1): structural values shared across locales.
// MITHOME-112: `slug` is the shared URL identifier of LegalPages.
// MITHOME-113: `result`/`notes` are legal-validation metadata, not copy.
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'address', 'slug', 'result', 'notes'])
// MITHOME-130: a product `name` is a brand, the same in every language.
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'address', 'slug', 'result', 'notes', 'name'])
type Node = FieldLike & { localized?: boolean; fields?: Node[] }
type Finding = { path: string; type?: string; localized: boolean }
@@ -187,7 +190,7 @@ describe('Payload globals', () => {
return !SHARED_TEXT_FIELDS.has(finding.path.split('.').pop()!)
}
it.each([Home, About, Services, Contact, Common, LegalPages].map((g) => [g.slug, g] as const))(
it.each([Home, About, Services, Contact, Common, LegalPages, Products, HostingPlans].map((g) => [g.slug, g] as const))(
'should localize exactly the translatable fields of %s',
(_slug, global) => {
const findings = walk(global.fields as Node[], '', [])
@@ -218,7 +221,7 @@ describe('Payload globals', () => {
it('should offer every routable page, including home, in the page selector', () => {
const page = findField(cta('primary'), 'page') as unknown as { options: { value: string }[] }
expect(page.options.map((o) => o.value)).toEqual(['home', 'about', 'services', 'contact', 'privacy', 'terms'])
expect(page.options.map((o) => o.value)).toEqual(['home', 'about', 'services', 'hostingPlans', 'contact', 'privacy', 'terms'])
})
it('should require a page only for internal links and a URL only for external links', () => {
@@ -232,7 +235,7 @@ describe('Payload globals', () => {
})
describe('MITHOME-113 English translation status', () => {
it.each([Home, About, Services, Contact, Common, LegalPages].map((d) => [d.slug, d] as const))(
it.each([Home, About, Services, Contact, Common, LegalPages, Products, HostingPlans].map((d) => [d.slug, d] as const))(
'should give %s a shared sidebar status that defaults to "none"',
(_slug, doc) => {
const field = findField(doc.fields, 'enTranslationStatus') as unknown as {
@@ -266,3 +269,35 @@ describe('MITHOME-113 legal validation gate', () => {
},
)
})
describe('MITHOME-130 hosting plans', () => {
type Select = { defaultValue: string; required?: boolean; options: { value: string }[]; admin?: { position?: string } }
type Validate = (value: unknown) => true | string
const group = (name: string) => (findField(Products.fields, name) as unknown as { fields: unknown[] }).fields
it('should start every product as a draft with the catalogue lifecycle and types', () => {
const status = findField(Products.fields, 'status') as unknown as Select
expect(status).toMatchObject({ required: true, defaultValue: 'draft', admin: { position: 'sidebar' } })
expect(status.options.map((o) => o.value)).toEqual(['draft', 'internal', 'publishable', 'active', 'retired'])
const type = findField(Products.fields, 'productType') as unknown as Select
expect(type.options.map((o) => o.value)).toEqual(['hosting', 'managed-service'])
const slug = findField(Products.fields, 'slug') as FieldLike & { unique?: boolean }
expect(slug).toMatchObject({ required: true, unique: true })
})
it('should require a whole, non-negative net price and default to yearly billing', () => {
const net = findField(group('pricing'), 'netAmount') as unknown as FieldLike & { validate: Validate }
expect(net.required).toBe(true)
expect(net.validate(14900)).toBe(true)
expect(net.validate(14900.5)).toEqual(expect.any(String))
expect(net.validate(-1)).toEqual(expect.any(String))
const period = findField(group('pricing'), 'billingPeriod') as unknown as Select
expect(period.defaultValue).toBe('yearly')
})
it('should keep the VAT rate as a shared page setting, 27% by default', () => {
const vat = findField(HostingPlans.fields, 'vatRatePercent') as unknown as FieldLike & { defaultValue: number; localized?: boolean }
expect(vat).toMatchObject({ type: 'number', required: true, defaultValue: 27 })
expect(vat.localized).toBeUndefined()
})
})
+5 -2
View File
@@ -23,6 +23,7 @@
* felületen. Mostantól Payload collection, a route.ts a Local API-n ír bele.
* MITHOME-111: a Globals fordítható mezői lokalizáltak; a meglévő adatot a
* src/migrations/20260929_localize_globals.ts alakítja át (prodMigrations).
* MITHOME-130: Products collection + HostingPlans global (tárhelycsomagok).
*/
import path from 'path'
import { fileURLToPath } from 'url'
@@ -36,11 +37,13 @@ import { LegalPages } from './collections/LegalPages'
import { Media } from './collections/Media'
import { Partners } from './collections/Partners'
import { ContactSubmissions } from './collections/ContactSubmissions'
import { Products } from './collections/Products'
import { Home } from './globals/Home'
import { About } from './globals/About'
import { Services } from './globals/Services'
import { Contact } from './globals/Contact'
import { Common } from './globals/Common'
import { HostingPlans } from './globals/HostingPlans'
import { migrations } from './migrations'
const filename = fileURLToPath(import.meta.url)
@@ -63,9 +66,9 @@ export default buildConfig({
editor: lexicalEditor(),
collections: [Users, LegalPages, Media, Partners, ContactSubmissions],
collections: [Users, LegalPages, Media, Partners, ContactSubmissions, Products],
globals: [Home, About, Services, Contact, Common],
globals: [Home, About, Services, Contact, Common, HostingPlans],
// MITHOME-109/110: hu alapértelmezett (URL-prefix nélkül), en /en/ alatt
// (Next.js routing oldala: MITHOME-114). fallback:true -> amíg egy mezőnek