- scripts/transfer-content.ts: export (shared config + MongoDB adapter, locale 'all', drafts, upload files) and import (PostgreSQL, one transaction, refuses a non-empty target); pure helpers in src/lib/content-transfer.ts - LegalPages: the section anchor is its own field; as the array row id it was a table-wide primary key in PostgreSQL and the two pages collided - Products.status: own enumName; the default name equalled the drafts _status enum, so only draft/published were accepted - baseline migration regenerated Verified on a staging copy (disposable MongoDB + PostgreSQL on llmdev): counts match, all 14 public pages (hu/en) render identical text, partner logo loads, second import writes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
129 lines
5.2 KiB
TypeScript
129 lines
5.2 KiB
TypeScript
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',
|
|
// MITHOME-136: own PostgreSQL enum name. The default "enum_products_status"
|
|
// is also Payload's name for the drafts `_status` enum, so the two
|
|
// collided and only draft/published were accepted.
|
|
enumName: 'enum_products_lifecycle_status',
|
|
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(),
|
|
],
|
|
}
|