131 lines
4.9 KiB
TypeScript
131 lines
4.9 KiB
TypeScript
import type { Block } from 'payload'
|
|
import { anchorField } from '@/fields/anchorField'
|
|
|
|
export const FDVpsCalculatorBlock: Block = {
|
|
slug: 'fdVpsCalculator',
|
|
imageURL: '/block-thumbnails/fd-vps-calculator.png',
|
|
imageAltText: 'FD VPS-kalkylator',
|
|
interfaceName: 'FDVpsCalculatorBlock',
|
|
labels: { singular: 'FD VPS-kalkylator', plural: 'FD VPS-kalkylatorer' },
|
|
fields: [
|
|
// ─── Presentation ──────────────────────────────────────────────────────
|
|
{ name: 'heading', type: 'text', label: 'Rubrik', defaultValue: 'Virtuell server — kalkylator', localized: true },
|
|
{ name: 'description', type: 'text', label: 'Beskrivning', localized: true },
|
|
{
|
|
type: 'row',
|
|
fields: [
|
|
{ name: 'orderCtaText', type: 'text', label: 'Beställ-knapp text', defaultValue: 'Beställ', localized: true },
|
|
{ name: 'orderCtaLink', type: 'text', label: 'Beställ-länk', defaultValue: '/kontakt?subject=vps-bestallning' },
|
|
],
|
|
},
|
|
{
|
|
type: 'row',
|
|
fields: [
|
|
{ name: 'contactCtaText', type: 'text', label: 'Kontakt-knapp text', defaultValue: 'Frågor? Kontakta oss', localized: true },
|
|
{ name: 'contactCtaLink', type: 'text', label: 'Kontakt-länk', defaultValue: '/kontakt' },
|
|
],
|
|
},
|
|
{
|
|
name: 'sectionBackground',
|
|
type: 'select',
|
|
label: 'Bakgrundsfärg',
|
|
defaultValue: 'white',
|
|
options: [
|
|
{ label: 'Vit', value: 'white' },
|
|
{ label: 'Grå', value: 'gray' },
|
|
{ label: 'Navy (mörkt läge)', value: 'navy' },
|
|
],
|
|
},
|
|
|
|
// ─── Prissättning ──────────────────────────────────────────────────────
|
|
{
|
|
type: 'collapsible',
|
|
label: 'Prissättning (kr/enhet)',
|
|
admin: { initCollapsed: true },
|
|
fields: [
|
|
{
|
|
type: 'row',
|
|
fields: [
|
|
{ name: 'pricingCpuPerCore', type: 'number', label: 'CPU per kärna (kr)', defaultValue: 120 },
|
|
{ name: 'pricingRamPerGb', type: 'number', label: 'RAM per GB (kr)', defaultValue: 100 },
|
|
],
|
|
},
|
|
{
|
|
type: 'row',
|
|
fields: [
|
|
{ name: 'pricingSsdPerGb', type: 'number', label: 'SSD NVMe per GB (kr)', defaultValue: 4 },
|
|
{ name: 'pricingHddPerGb', type: 'number', label: 'HDD per GB (kr)', defaultValue: 1 },
|
|
],
|
|
},
|
|
{
|
|
name: 'pricingWindowsLicense',
|
|
type: 'number',
|
|
label: 'Windows-licens per månad (kr)',
|
|
defaultValue: 250,
|
|
},
|
|
{
|
|
name: 'discountPercent',
|
|
type: 'number',
|
|
label: 'Kampanjrabatt (%)',
|
|
min: 0,
|
|
max: 100,
|
|
admin: { description: 'Appliceras på alla resurser. 0 = ingen rabatt.' },
|
|
},
|
|
],
|
|
},
|
|
|
|
// ─── Administrationsavgift ─────────────────────────────────────────────
|
|
// This is an ADMIN-only setting — shown as a fixed line in the calculator,
|
|
// NOT a toggle for the end user.
|
|
{
|
|
type: 'collapsible',
|
|
label: 'Administrationsavgift',
|
|
admin: { initCollapsed: true, description: 'Visas som en fast rad i kalkylatorn. Kunden kan inte välja bort den.' },
|
|
fields: [
|
|
{
|
|
type: 'row',
|
|
fields: [
|
|
{
|
|
name: 'showAdminFee',
|
|
type: 'checkbox',
|
|
label: 'Inkludera administrationsavgift',
|
|
defaultValue: false,
|
|
admin: { description: 'Lägg till en fast avgift som alltid ingår i totalen.' },
|
|
},
|
|
{
|
|
name: 'adminFeeAmount',
|
|
type: 'number',
|
|
label: 'Belopp (kr/mån)',
|
|
defaultValue: 200,
|
|
admin: {
|
|
description: 'Standard: 200 kr/mån',
|
|
condition: (_, siblingData) => siblingData?.showAdminFee,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
|
|
// ─── Tillvalstjänster ──────────────────────────────────────────────────
|
|
// These ARE customer-toggleable — shown with a toggle in the calculator
|
|
{
|
|
name: 'additionalServices',
|
|
type: 'array',
|
|
label: 'Tillvalstjänster',
|
|
admin: {
|
|
description: 'Kunden kan slå på/av dessa i kalkylatorn. Visas under "Tillvalstjänster".',
|
|
},
|
|
fields: [
|
|
{ name: 'label', type: 'text', label: 'Tjänstnamn', required: true, localized: true },
|
|
{
|
|
name: 'price',
|
|
type: 'number',
|
|
label: 'Pris (kr/mån)',
|
|
required: true,
|
|
},
|
|
],
|
|
},
|
|
anchorField,
|
|
],
|
|
} |