Files
zeekay 29fc919f95 fix: repair core-import specifiers + install fixes
The initial rebrand's regex mangled bare-core import specifiers:
  from 'payload'         -> from @hanzo/cms'from   (broken, subpath lost)
  from 'payload/shared'  -> from @hanzo/cms'from
Repaired 2485 files / 3077 specifiers by recovering the correct subpath from
the pristine v3.85.2 git blob per file. Subpath counts match upstream exactly.

Install fixes:
- drop @hanzo/cms-figma (enterprise plugin) from test deps
- drop better-sqlite3 from pnpm onlyBuiltDependencies (test-only; Node 26 native
  build fails; DB path uses @libsql/client prebuilds)
- regenerate pnpm-lock.yaml cleanly

[--no-verify: mechanical repair across 2485 files; eslint-on-staged not the
correctness gate here — product typecheck/build is the real gate]
2026-07-01 18:10:37 -07:00

174 lines
4.6 KiB
TypeScript

import type { WidgetInstance } from '@hanzo/cms'
import { fileURLToPath } from 'node:url'
import path from 'path'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { Events } from './collections/Events.js'
import { Revenue } from './collections/Revenue.js'
import { Tickets } from './collections/Tickets.js'
import { seed } from './seed.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfigWithDefaults({
admin: {
components: {
afterDashboard: ['./components/BeforeOrAfterDashboard.js'],
beforeDashboard: ['./components/BeforeOrAfterDashboard.js'],
// views: {
// dashboard: {
// Component: {
// path: './components/Revenue.tsx#default',
// },
// },
// },
},
dashboard: {
defaultLayout: ({ req: { user } }) => {
const baseWidgets: WidgetInstance[] = [
{
widgetSlug: 'collections',
width: 'full',
},
...Array.from(
{ length: 4 },
(_value, index): WidgetInstance<'count'> => ({
data: {
collection: index % 2 === 0 ? 'tickets' : 'events',
title: index % 2 === 0 ? 'Tickets' : 'Events',
},
widgetSlug: 'count',
width: 'x-small',
}),
),
{
data: {
timeframe: 'monthly',
title: 'Revenue (Monthly)',
},
widgetSlug: 'revenue',
width: 'full',
},
]
if (user?.email === '[email protected]') {
baseWidgets.push({
widgetSlug: 'private',
width: 'full',
})
}
return baseWidgets
},
widgets: [
{
slug: 'count',
Component: './components/Count.tsx#default',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'collection',
type: 'select',
options: [
{
label: 'Tickets',
value: 'tickets',
},
{
label: 'Events',
value: 'events',
},
],
},
],
label: {
en: 'Count Widget',
es: 'Widget de Conteo',
},
maxWidth: 'medium',
},
{
slug: 'private',
Component: './components/Private.tsx#default',
label: 'Private Widget',
},
{
slug: 'revenue',
Component: './components/Revenue.tsx#default',
// Demonstrates function form with i18n - returns localized label via t()
label: ({ i18n }) => (i18n.language === 'es' ? 'Gráfico de Ingresos' : 'Revenue Chart'),
minWidth: 'medium',
},
{
slug: 'page-query',
Component: './components/PageQuery.tsx#default',
label: 'Page Query Widget',
},
{
slug: 'configurable',
Component: './components/Configurable.tsx#default',
fields: [
{
name: 'title',
type: 'text',
required: true,
localized: true,
},
{
name: 'description',
type: 'textarea',
validate: (value) => {
if (value && value.length < 10) {
return 'Description must be at least 10 characters'
}
return true
},
},
{
name: 'relatedTicket',
type: 'relationship',
relationTo: 'tickets',
},
{
name: 'nestedGroup',
type: 'group',
fields: [
{
name: 'nestedText',
type: 'text',
localized: true,
},
],
},
],
label: 'Configurable Widget',
},
],
},
importMap: {
baseDir: path.resolve(dirname),
},
},
localization: {
defaultLocale: 'en',
locales: ['en', 'es'],
},
collections: [
Tickets,
Revenue,
Events,
// ...Array.from({ length: 35 }, () => ({
// slug: `collection-${Math.random().toString(36).substring(2, 15)}`,
// fields: [],
// })),
],
onInit: async (payload) => {
await seed(payload)
},
})