const { ICON_OPTIONS, text, date, textarea, icon, url, combobox, object, objectList, stringList, variantList, } = require("./sharedFields"); const baseConfig = { key: "policies", title: "Policies Management", subtitle: "Manage policy metadata and block-based content for the policies page", routeBase: "/admin/policies", apiPath: "/api/policies", previewPath: "/policies", dataFile: "policies", imageType: "policies", tabs: [ { key: "hero", label: "Hero", icon: "fas fa-scale-balanced", schema: object("hero", "Hero", [ text("badge", "Eyebrow label", { maxLength: 40 }), icon("icon", "Hero icon", { helpText: "Policies uses icon-only controls and does not require image upload.", }), text("titlePrefix", "Headline prefix", { maxLength: 50 }), text("titleHighlight", "Headline highlight", { maxLength: 40 }), textarea("description", "Supporting text", { maxLength: 220, rows: 4, }), ]), }, { key: "sidebar", label: "Sidebar", icon: "fas fa-bars", schema: object("sidebar", "Sidebar", [ text("heading", "Sidebar heading", { maxLength: 30 }), text("helperText", "Helper text", { maxLength: 60 }), text("contactLabel", "Contact link label", { maxLength: 25 }), url("contactHref", "Contact URL", { maxLength: 255 }), ]), }, { key: "policies", label: "Policies", icon: "fas fa-file-lines", schema: objectList( "policies", "Policies", [ text("navLabel", "Sidebar label", { maxLength: 40 }), text("title", "Policy title", { maxLength: 70 }), date("effectiveDate", "Effective date", { helpText: "Pick a calendar date. It will be saved in the standard policy display format.", }), textarea("intro", "Intro text", { maxLength: 260, rows: 4 }), ], { itemLabel: "Policy", sortable: true, itemTitleKey: "title", itemSubtitleKey: "effectiveDate", emptyText: "No policies yet.", itemActions: [ { label: "Edit Content", icon: "fas fa-pen-to-square", hrefTemplate: "/admin/policies/{id}/section", className: "btn btn-outline-primary btn-sm", }, ], }, ), }, ], }; function createPoliciesSectionEditorConfig(policy, allPolicies = []) { const policyOptions = allPolicies .filter((item) => item.id && item.id !== policy.id) .map((item) => ({ value: item.id, label: item.title || item.navLabel || item.id, })); return { key: "policyContent", title: `Policy Content: ${policy.title || policy.id}`, subtitle: "Edit block-based policy content with realtime preview", routeBase: `/admin/policies/${policy.id}/section`, previewPath: "/policies", imageType: "policies", policyId: policy.id, policyOptions, iconOptions: ICON_OPTIONS, }; } module.exports = { baseConfig, createPoliciesSectionEditorConfig, };