Compare commits
3 Commits
todo/mvp1-
...
todo/mvp1-
| Author | SHA1 | Date | |
|---|---|---|---|
|
984511f166
|
|||
|
b9424c8a8b
|
|||
|
6e9c0ad4e5
|
48
TODO.md
48
TODO.md
@@ -140,8 +140,8 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
- [ ] [P1] Page builder with reusable content blocks (hero, rich text, gallery, CTA, forms, price cards)
|
- [ ] [P1] Page builder with reusable content blocks (hero, rich text, gallery, CTA, forms, price cards)
|
||||||
- [~] [P1] Navigation management (menus, nested items, order, visibility)
|
- [~] [P1] Navigation management (menus, nested items, order, visibility)
|
||||||
- [~] [P1] Media library (upload, browse, replace, delete) with media-type classification (artwork, banner, promo, generic, video/gif)
|
- [~] [P1] Media library (upload, browse, replace, delete) with media-type classification (artwork, banner, promo, generic, video/gif)
|
||||||
- [ ] [P1] Media enrichment metadata (alt text, copyright, author, source, tags, licensing, usage context)
|
- [x] [P1] Media enrichment metadata (alt text, copyright, author, source, tags, licensing, usage context)
|
||||||
- [ ] [P1] Portfolio grouping primitives (galleries, albums, categories, tags) with ordering/visibility controls
|
- [x] [P1] Portfolio grouping primitives (galleries, albums, categories, tags) with ordering/visibility controls
|
||||||
- [ ] [P1] Artwork refinement fields (medium, dimensions, year, framing, availability, price visibility)
|
- [ ] [P1] Artwork refinement fields (medium, dimensions, year, framing, availability, price visibility)
|
||||||
- [ ] [P1] Artwork rendition management (thumbnail, card, full, retina/custom sizes)
|
- [ ] [P1] Artwork rendition management (thumbnail, card, full, retina/custom sizes)
|
||||||
- [ ] [P1] Type-specific processing presets (artwork/banner/promo/video/gif) with validation rules
|
- [ ] [P1] Type-specific processing presets (artwork/banner/promo/video/gif) with validation rules
|
||||||
@@ -190,21 +190,39 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
- [ ] [P2] Add code-level diagrams (Mermaid) for service boundaries and data relationships
|
- [ ] [P2] Add code-level diagrams (Mermaid) for service boundaries and data relationships
|
||||||
- [ ] [P2] Add route/action inventory for admin and public apps with linked source files
|
- [ ] [P2] Add route/action inventory for admin and public apps with linked source files
|
||||||
|
|
||||||
## MVP 1.5: UX/UI And Theming
|
## MVP 1.5: MVP1 Refinements (Planned)
|
||||||
|
|
||||||
### MVP1.5 Suggested Branch Order
|
### Scope
|
||||||
|
|
||||||
- [ ] [P1] `todo/mvp15-design-tokens-foundation`:
|
- [ ] [P1] Refine and harden all completed MVP1 modules (pages, navigation, media, portfolio, commissions, news)
|
||||||
|
- [ ] [P1] Resolve UX rough edges discovered during MVP1 implementation
|
||||||
|
- [ ] [P1] Improve admin workflows and reduce editor friction for daily use
|
||||||
|
- [ ] [P1] Stabilize public rendering behavior with better fallbacks and consistency
|
||||||
|
|
||||||
|
## MVP 2: MVP1 Quality Refinements (Planned)
|
||||||
|
|
||||||
|
### Scope
|
||||||
|
|
||||||
|
- [ ] [P1] Finish non-blocking enhancements postponed from MVP1 implementation
|
||||||
|
- [ ] [P1] Improve data modeling consistency and migration hygiene for MVP1 modules
|
||||||
|
- [ ] [P1] Consolidate reusable UI and domain primitives introduced during MVP1
|
||||||
|
- [ ] [P1] Address integration debt before moving to larger design/production phases
|
||||||
|
|
||||||
|
## MVP 3: UX/UI And Theming
|
||||||
|
|
||||||
|
### MVP3 Suggested Branch Order
|
||||||
|
|
||||||
|
- [ ] [P1] `todo/mvp3-design-tokens-foundation`:
|
||||||
establish shared design tokens (color, spacing, radius, typography scale, motion) in `@cms/ui` and app-level theme contracts
|
establish shared design tokens (color, spacing, radius, typography scale, motion) in `@cms/ui` and app-level theme contracts
|
||||||
- [ ] [P1] `todo/mvp15-admin-layout-polish`:
|
- [ ] [P1] `todo/mvp3-admin-layout-polish`:
|
||||||
refine admin shell, navigation hierarchy, spacing rhythm, table/form visual consistency, empty/loading/error states
|
refine admin shell, navigation hierarchy, spacing rhythm, table/form visual consistency, empty/loading/error states
|
||||||
- [ ] [P1] `todo/mvp15-public-layout-and-templates`:
|
- [ ] [P1] `todo/mvp3-public-layout-and-templates`:
|
||||||
define public visual direction (hero/header/footer/content widths), page templates for home/content/news/portfolio
|
define public visual direction (hero/header/footer/content widths), page templates for home/content/news/portfolio
|
||||||
- [ ] [P2] `todo/mvp15-component-library-pass`:
|
- [ ] [P2] `todo/mvp3-component-library-pass`:
|
||||||
align shadcn-based primitives with CMS brand system (buttons, inputs, cards, badges, tabs, dialogs, toasts)
|
align shadcn-based primitives with CMS brand system (buttons, inputs, cards, badges, tabs, dialogs, toasts)
|
||||||
- [ ] [P2] `todo/mvp15-responsive-and-a11y-pass`:
|
- [ ] [P2] `todo/mvp3-responsive-and-a11y-pass`:
|
||||||
mobile/tablet breakpoints, keyboard flow, focus states, contrast checks, reduced-motion support
|
mobile/tablet breakpoints, keyboard flow, focus states, contrast checks, reduced-motion support
|
||||||
- [ ] [P2] `todo/mvp15-visual-regression-baseline`:
|
- [ ] [P2] `todo/mvp3-visual-regression-baseline`:
|
||||||
add screenshot baselines for critical admin/public routes to guard layout regressions
|
add screenshot baselines for critical admin/public routes to guard layout regressions
|
||||||
|
|
||||||
### Deliverables
|
### Deliverables
|
||||||
@@ -214,7 +232,7 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
- [ ] [P2] Shared UI primitives are consistent across admin and public apps
|
- [ ] [P2] Shared UI primitives are consistent across admin and public apps
|
||||||
- [ ] [P2] Core routes have visual-regression coverage for the new layout baseline
|
- [ ] [P2] Core routes have visual-regression coverage for the new layout baseline
|
||||||
|
|
||||||
## MVP 2: Production Readiness
|
## MVP 4: Production Readiness
|
||||||
|
|
||||||
### Admin App
|
### Admin App
|
||||||
|
|
||||||
@@ -253,9 +271,9 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
- [~] [P1] Testing workstream moved to `MVP 3: Testing and Quality` and temporarily paused to prioritize feature delivery
|
- [~] [P1] Testing workstream moved to `MVP 5: Testing and Quality` and temporarily paused to prioritize feature delivery
|
||||||
|
|
||||||
## MVP 3: Testing and Quality
|
## MVP 5: Testing and Quality
|
||||||
|
|
||||||
### Status
|
### Status
|
||||||
|
|
||||||
@@ -316,7 +334,7 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
- [2026-02-11] Release workflow now publishes changelog-derived notes to Gitea releases and supports executable production rollback via SSH + compose tag switch.
|
- [2026-02-11] Release workflow now publishes changelog-derived notes to Gitea releases and supports executable production rollback via SSH + compose tag switch.
|
||||||
- [2026-02-11] Branch protection verification checklist is now documented; final UI-level verification remains environment-specific.
|
- [2026-02-11] Branch protection verification checklist is now documented; final UI-level verification remains environment-specific.
|
||||||
- [2026-02-11] Added a staging deployment execution checklist and deployment-record template to capture first real-host rollout evidence.
|
- [2026-02-11] Added a staging deployment execution checklist and deployment-record template to capture first real-host rollout evidence.
|
||||||
- [2026-02-11] Artist-focused feature map refined: MVP1 covers portfolio media/domain CRUD + announcements + customer/commission linking; MVP2 covers advanced automation (watermark, palette extraction, media transform pipelines).
|
- [2026-02-11] Artist-focused feature map refined: MVP1 covers portfolio media/domain CRUD + announcements + customer/commission linking; MVP4 covers advanced automation (watermark, palette extraction, media transform pipelines).
|
||||||
- [2026-02-11] `gaertan` inspiration to reuse: S3 object strategy with signed delivery, commission type/options/extras/custom-input modeling, request-status kanban mapping, and gallery rendition/color extraction patterns.
|
- [2026-02-11] `gaertan` inspiration to reuse: S3 object strategy with signed delivery, commission type/options/extras/custom-input modeling, request-status kanban mapping, and gallery rendition/color extraction patterns.
|
||||||
- [2026-02-11] MVP1 media foundation started: portfolio domain models (`MediaAsset`, `Artwork`, galleries/albums/categories/tags, rendition links) plus initial admin `/media` and `/portfolio` data views.
|
- [2026-02-11] MVP1 media foundation started: portfolio domain models (`MediaAsset`, `Artwork`, galleries/albums/categories/tags, rendition links) plus initial admin `/media` and `/portfolio` data views.
|
||||||
- [2026-02-11] `prisma migrate dev --name media_foundation` can fail when DB endpoint is unreachable; apply this named migration once `DATABASE_URL` host is reachable again.
|
- [2026-02-11] `prisma migrate dev --name media_foundation` can fail when DB endpoint is unreachable; apply this named migration once `DATABASE_URL` host is reachable again.
|
||||||
@@ -325,6 +343,7 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
- [2026-02-12] Upload storage is now provider-based (`local` + `s3`) via `CMS_MEDIA_STORAGE_PROVIDER`; admin-side GUI toggle remains a later MVP item.
|
- [2026-02-12] Upload storage is now provider-based (`local` + `s3`) via `CMS_MEDIA_STORAGE_PROVIDER`; admin-side GUI toggle remains a later MVP item.
|
||||||
- [2026-02-12] Media storage keys now use asset-centric layout (`tenant/<id>/asset/<assetId>/<fileRole>/<assetId>__<variant>.<ext>`) with DB-managed media taxonomy.
|
- [2026-02-12] Media storage keys now use asset-centric layout (`tenant/<id>/asset/<assetId>/<fileRole>/<assetId>__<variant>.<ext>`) with DB-managed media taxonomy.
|
||||||
- [2026-02-12] Admin media CRUD now includes list-to-detail flow (`/media/:id`) with metadata edit and delete actions.
|
- [2026-02-12] Admin media CRUD now includes list-to-detail flow (`/media/:id`) with metadata edit and delete actions.
|
||||||
|
- [2026-02-12] Media enrichment metadata baseline completed: `MediaAsset` now supports licensing/usage/location/captured-at fields across upload input, admin editor, and public artwork detail rendering.
|
||||||
- [2026-02-12] MVP1 pages/navigation baseline started: `Page`, `NavigationMenu`, and `NavigationItem` models plus admin CRUD routes (`/pages`, `/pages/:id`, `/navigation`).
|
- [2026-02-12] MVP1 pages/navigation baseline started: `Page`, `NavigationMenu`, and `NavigationItem` models plus admin CRUD routes (`/pages`, `/pages/:id`, `/navigation`).
|
||||||
- [2026-02-12] Public app now renders CMS-managed navigation (header) and CMS-managed pages by slug (including homepage when `home` page exists).
|
- [2026-02-12] Public app now renders CMS-managed navigation (header) and CMS-managed pages by slug (including homepage when `home` page exists).
|
||||||
- [2026-02-12] Commissions/customer baseline added: admin `/commissions` now supports customer creation, commission intake, status transitions, and a basic kanban board.
|
- [2026-02-12] Commissions/customer baseline added: admin `/commissions` now supports customer creation, commission intake, status transitions, and a basic kanban board.
|
||||||
@@ -342,6 +361,7 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
- [2026-02-12] Page editor now supports locale translations in `/pages/:id`; public page rendering uses locale-aware page lookup with base-content fallback.
|
- [2026-02-12] Page editor now supports locale translations in `/pages/:id`; public page rendering uses locale-aware page lookup with base-content fallback.
|
||||||
- [2026-02-12] Public rendering integration advanced with locale-aware navigation/news translations and a new public commission request entry route (`/[locale]/commissions`) that creates/reuses customer records and opens a `new` commission.
|
- [2026-02-12] Public rendering integration advanced with locale-aware navigation/news translations and a new public commission request entry route (`/[locale]/commissions`) that creates/reuses customer records and opens a `new` commission.
|
||||||
- [2026-02-12] Public portfolio baseline added with `/{locale}/portfolio` and `/{locale}/portfolio/{slug}`, including published-artwork filters (gallery/album/category/tag), rendition image streaming via web `/api/media/file/:id`, and media-aware artwork detail rendering.
|
- [2026-02-12] Public portfolio baseline added with `/{locale}/portfolio` and `/{locale}/portfolio/{slug}`, including published-artwork filters (gallery/album/category/tag), rendition image streaming via web `/api/media/file/:id`, and media-aware artwork detail rendering.
|
||||||
|
- [2026-02-12] Portfolio grouping controls completed in admin `/portfolio`: galleries/albums/categories/tags now support visibility and sort-order management (create/update/delete), and public tag filters now respect visibility.
|
||||||
- [2026-02-12] Public UX pass: commission request flow now reports explicit invalid budget range errors, and header navigation now falls back to localized defaults (`home`, `portfolio`, `news`, `commissions`) when no CMS menu exists; seed data now creates those default menu entries.
|
- [2026-02-12] Public UX pass: commission request flow now reports explicit invalid budget range errors, and header navigation now falls back to localized defaults (`home`, `portfolio`, `news`, `commissions`) when no CMS menu exists; seed data now creates those default menu entries.
|
||||||
- [2026-02-12] Added `e2e/public-rendering.pw.ts` web coverage for fallback navigation visibility, portfolio routes, and commission submission validation (invalid budget range + successful submission path).
|
- [2026-02-12] Added `e2e/public-rendering.pw.ts` web coverage for fallback navigation visibility, portfolio routes, and commission submission validation (invalid budget range + successful submission path).
|
||||||
- [2026-02-12] Testing execution is temporarily paused for delivery velocity: root test scripts are stubbed and CI test steps are disabled; all testing backlog is consolidated under `MVP 3: Testing and Quality`.
|
- [2026-02-12] Testing execution is temporarily paused for delivery velocity: root test scripts are stubbed and CI test steps are disabled; all testing backlog is consolidated under `MVP 3: Testing and Quality`.
|
||||||
|
|||||||
@@ -58,6 +58,22 @@ function parseTags(formData: FormData): string[] {
|
|||||||
.filter((item) => item.length > 0)
|
.filter((item) => item.length > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseOptionalDateField(formData: FormData, field: string): Date | undefined {
|
||||||
|
const value = parseTextField(formData, field)
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed = new Date(value)
|
||||||
|
|
||||||
|
if (Number.isNaN(parsed.getTime())) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed
|
||||||
|
}
|
||||||
|
|
||||||
function deriveTitleFromFilename(fileName: string): string {
|
function deriveTitleFromFilename(fileName: string): string {
|
||||||
const trimmed = fileName.trim()
|
const trimmed = fileName.trim()
|
||||||
|
|
||||||
@@ -178,6 +194,11 @@ export async function POST(request: Request): Promise<Response> {
|
|||||||
source: parseOptionalField(formData, "source"),
|
source: parseOptionalField(formData, "source"),
|
||||||
copyright: parseOptionalField(formData, "copyright"),
|
copyright: parseOptionalField(formData, "copyright"),
|
||||||
author: parseOptionalField(formData, "author"),
|
author: parseOptionalField(formData, "author"),
|
||||||
|
licenseType: parseOptionalField(formData, "licenseType"),
|
||||||
|
licenseUrl: parseOptionalField(formData, "licenseUrl"),
|
||||||
|
usageContext: parseOptionalField(formData, "usageContext"),
|
||||||
|
location: parseOptionalField(formData, "location"),
|
||||||
|
capturedAt: parseOptionalDateField(formData, "capturedAt"),
|
||||||
tags: parseTags(formData),
|
tags: parseTags(formData),
|
||||||
storageKey: stored.storageKey,
|
storageKey: stored.storageKey,
|
||||||
mimeType: fileEntry.type || undefined,
|
mimeType: fileEntry.type || undefined,
|
||||||
|
|||||||
@@ -50,6 +50,22 @@ function readNullableInt(formData: FormData, field: string): number | null {
|
|||||||
return parsed
|
return parsed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readNullableDate(formData: FormData, field: string): Date | null {
|
||||||
|
const value = readInputString(formData, field)
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed = new Date(value)
|
||||||
|
|
||||||
|
if (Number.isNaN(parsed.getTime())) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed
|
||||||
|
}
|
||||||
|
|
||||||
function readTags(formData: FormData): string[] {
|
function readTags(formData: FormData): string[] {
|
||||||
const raw = readInputString(formData, "tags")
|
const raw = readInputString(formData, "tags")
|
||||||
|
|
||||||
@@ -127,6 +143,11 @@ export default async function MediaAssetEditorPage({ params, searchParams }: Pag
|
|||||||
source: readNullableString(formData, "source"),
|
source: readNullableString(formData, "source"),
|
||||||
copyright: readNullableString(formData, "copyright"),
|
copyright: readNullableString(formData, "copyright"),
|
||||||
author: readNullableString(formData, "author"),
|
author: readNullableString(formData, "author"),
|
||||||
|
licenseType: readNullableString(formData, "licenseType"),
|
||||||
|
licenseUrl: readNullableString(formData, "licenseUrl"),
|
||||||
|
usageContext: readNullableString(formData, "usageContext"),
|
||||||
|
location: readNullableString(formData, "location"),
|
||||||
|
capturedAt: readNullableDate(formData, "capturedAt"),
|
||||||
tags: readTags(formData),
|
tags: readTags(formData),
|
||||||
mimeType: readNullableString(formData, "mimeType"),
|
mimeType: readNullableString(formData, "mimeType"),
|
||||||
width: readNullableInt(formData, "width"),
|
width: readNullableInt(formData, "width"),
|
||||||
@@ -320,6 +341,56 @@ export default async function MediaAssetEditorPage({ params, searchParams }: Pag
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="grid gap-3 md:grid-cols-2">
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">License type</span>
|
||||||
|
<input
|
||||||
|
name="licenseType"
|
||||||
|
defaultValue={mediaAsset.licenseType ?? ""}
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">License URL</span>
|
||||||
|
<input
|
||||||
|
name="licenseUrl"
|
||||||
|
defaultValue={mediaAsset.licenseUrl ?? ""}
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid gap-3 md:grid-cols-2">
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">Usage context</span>
|
||||||
|
<input
|
||||||
|
name="usageContext"
|
||||||
|
defaultValue={mediaAsset.usageContext ?? ""}
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">Location</span>
|
||||||
|
<input
|
||||||
|
name="location"
|
||||||
|
defaultValue={mediaAsset.location ?? ""}
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">Captured at</span>
|
||||||
|
<input
|
||||||
|
name="capturedAt"
|
||||||
|
type="datetime-local"
|
||||||
|
defaultValue={
|
||||||
|
mediaAsset.capturedAt ? toLocalDateTimeInputValue(mediaAsset.capturedAt) : ""
|
||||||
|
}
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
<div className="grid gap-3 md:grid-cols-3">
|
<div className="grid gap-3 md:grid-cols-3">
|
||||||
<label className="space-y-1">
|
<label className="space-y-1">
|
||||||
<span className="text-xs text-neutral-600">MIME type</span>
|
<span className="text-xs text-neutral-600">MIME type</span>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Link from "next/link"
|
|||||||
import { redirect } from "next/navigation"
|
import { redirect } from "next/navigation"
|
||||||
|
|
||||||
import { AdminShell } from "@/components/admin-shell"
|
import { AdminShell } from "@/components/admin-shell"
|
||||||
|
import { PageBlockEditor } from "@/components/pages/page-block-editor"
|
||||||
import { requirePermissionForRoute } from "@/lib/route-guards"
|
import { requirePermissionForRoute } from "@/lib/route-guards"
|
||||||
|
|
||||||
export const dynamic = "force-dynamic"
|
export const dynamic = "force-dynamic"
|
||||||
@@ -242,16 +243,7 @@ export default async function PageEditorPage({ params, searchParams }: PageProps
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className="space-y-1">
|
<PageBlockEditor name="content" initialContent={page.content} />
|
||||||
<span className="text-xs text-neutral-600">Content</span>
|
|
||||||
<textarea
|
|
||||||
name="content"
|
|
||||||
rows={10}
|
|
||||||
defaultValue={page.content}
|
|
||||||
required
|
|
||||||
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div className="grid gap-3 md:grid-cols-2">
|
<div className="grid gap-3 md:grid-cols-2">
|
||||||
<label className="space-y-1">
|
<label className="space-y-1">
|
||||||
@@ -368,16 +360,11 @@ export default async function PageEditorPage({ params, searchParams }: PageProps
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className="space-y-1">
|
<PageBlockEditor
|
||||||
<span className="text-xs text-neutral-600">Content</span>
|
name="content"
|
||||||
<textarea
|
initialContent={selectedTranslation?.content ?? page.content}
|
||||||
name="content"
|
label="Translation Blocks"
|
||||||
rows={8}
|
/>
|
||||||
defaultValue={selectedTranslation?.content ?? page.content}
|
|
||||||
required
|
|
||||||
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div className="grid gap-3 md:grid-cols-2">
|
<div className="grid gap-3 md:grid-cols-2">
|
||||||
<label className="space-y-1">
|
<label className="space-y-1">
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import {
|
|||||||
createCategory,
|
createCategory,
|
||||||
createGallery,
|
createGallery,
|
||||||
createTag,
|
createTag,
|
||||||
|
deleteGrouping,
|
||||||
linkArtworkToGrouping,
|
linkArtworkToGrouping,
|
||||||
listArtworks,
|
listArtworks,
|
||||||
listMediaAssets,
|
listMediaAssets,
|
||||||
listMediaFoundationGroups,
|
listMediaFoundationGroups,
|
||||||
|
updateGrouping,
|
||||||
} from "@cms/db"
|
} from "@cms/db"
|
||||||
import { Button } from "@cms/ui/button"
|
import { Button } from "@cms/ui/button"
|
||||||
import { revalidatePath } from "next/cache"
|
import { revalidatePath } from "next/cache"
|
||||||
@@ -32,6 +34,21 @@ function readOptionalField(formData: FormData, key: string): string | undefined
|
|||||||
return value.length > 0 ? value : undefined
|
return value.length > 0 ? value : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readOptionalNullableField(formData: FormData, key: string): string | null {
|
||||||
|
const value = readField(formData, key)
|
||||||
|
return value.length > 0 ? value : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function readNonNegativeInt(formData: FormData, key: string): number {
|
||||||
|
const raw = readField(formData, key)
|
||||||
|
const value = Number(raw)
|
||||||
|
return Number.isFinite(value) && value >= 0 ? Math.floor(value) : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function readBooleanField(formData: FormData, key: string): boolean {
|
||||||
|
return formData.get(key) === "on" || readField(formData, key) === "true"
|
||||||
|
}
|
||||||
|
|
||||||
function readFirstValue(value: string | string[] | undefined): string | null {
|
function readFirstValue(value: string | string[] | undefined): string | null {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
return value[0] ?? null
|
return value[0] ?? null
|
||||||
@@ -117,23 +134,32 @@ async function createGroupAction(formData: FormData) {
|
|||||||
name,
|
name,
|
||||||
slug,
|
slug,
|
||||||
description: readOptionalField(formData, "description"),
|
description: readOptionalField(formData, "description"),
|
||||||
|
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||||
|
isVisible: readBooleanField(formData, "isVisible"),
|
||||||
})
|
})
|
||||||
} else if (type === "album") {
|
} else if (type === "album") {
|
||||||
await createAlbum({
|
await createAlbum({
|
||||||
name,
|
name,
|
||||||
slug,
|
slug,
|
||||||
description: readOptionalField(formData, "description"),
|
description: readOptionalField(formData, "description"),
|
||||||
|
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||||
|
isVisible: readBooleanField(formData, "isVisible"),
|
||||||
})
|
})
|
||||||
} else if (type === "category") {
|
} else if (type === "category") {
|
||||||
await createCategory({
|
await createCategory({
|
||||||
name,
|
name,
|
||||||
slug,
|
slug,
|
||||||
description: readOptionalField(formData, "description"),
|
description: readOptionalField(formData, "description"),
|
||||||
|
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||||
|
isVisible: readBooleanField(formData, "isVisible"),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await createTag({
|
await createTag({
|
||||||
name,
|
name,
|
||||||
slug,
|
slug,
|
||||||
|
description: readOptionalField(formData, "description"),
|
||||||
|
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||||
|
isVisible: readBooleanField(formData, "isVisible"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -144,6 +170,47 @@ async function createGroupAction(formData: FormData) {
|
|||||||
redirectWithState({ notice: `${type} created.` })
|
redirectWithState({ notice: `${type} created.` })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateGroupAction(formData: FormData) {
|
||||||
|
"use server"
|
||||||
|
|
||||||
|
await requireWritePermission()
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateGrouping({
|
||||||
|
groupType: readField(formData, "groupType"),
|
||||||
|
groupId: readField(formData, "groupId"),
|
||||||
|
name: readField(formData, "name"),
|
||||||
|
slug: slugify(readField(formData, "slug")),
|
||||||
|
description: readOptionalNullableField(formData, "description"),
|
||||||
|
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||||
|
isVisible: readBooleanField(formData, "isVisible"),
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
redirectWithState({ error: "Failed to update grouping entity." })
|
||||||
|
}
|
||||||
|
|
||||||
|
revalidatePath("/portfolio")
|
||||||
|
redirectWithState({ notice: "Grouping entity updated." })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteGroupAction(formData: FormData) {
|
||||||
|
"use server"
|
||||||
|
|
||||||
|
await requireWritePermission()
|
||||||
|
|
||||||
|
try {
|
||||||
|
await deleteGrouping({
|
||||||
|
groupType: readField(formData, "groupType"),
|
||||||
|
groupId: readField(formData, "groupId"),
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
redirectWithState({ error: "Failed to delete grouping entity." })
|
||||||
|
}
|
||||||
|
|
||||||
|
revalidatePath("/portfolio")
|
||||||
|
redirectWithState({ notice: "Grouping entity deleted." })
|
||||||
|
}
|
||||||
|
|
||||||
async function linkArtworkGroupAction(formData: FormData) {
|
async function linkArtworkGroupAction(formData: FormData) {
|
||||||
"use server"
|
"use server"
|
||||||
|
|
||||||
@@ -297,7 +364,7 @@ export default async function PortfolioPage({
|
|||||||
<section className="rounded-xl border border-neutral-200 p-6">
|
<section className="rounded-xl border border-neutral-200 p-6">
|
||||||
<h2 className="text-xl font-medium">Create Group Entity</h2>
|
<h2 className="text-xl font-medium">Create Group Entity</h2>
|
||||||
<form action={createGroupAction} className="mt-4 space-y-3">
|
<form action={createGroupAction} className="mt-4 space-y-3">
|
||||||
<div className="grid gap-3 md:grid-cols-3">
|
<div className="grid gap-3 md:grid-cols-5">
|
||||||
<select
|
<select
|
||||||
name="groupType"
|
name="groupType"
|
||||||
defaultValue="gallery"
|
defaultValue="gallery"
|
||||||
@@ -319,6 +386,18 @@ export default async function PortfolioPage({
|
|||||||
placeholder="Slug (optional)"
|
placeholder="Slug (optional)"
|
||||||
className="rounded border border-neutral-300 px-3 py-2 text-sm"
|
className="rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
/>
|
/>
|
||||||
|
<input
|
||||||
|
name="sortOrder"
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
defaultValue={0}
|
||||||
|
placeholder="Sort order"
|
||||||
|
className="rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
<label className="flex items-center gap-2 rounded border border-neutral-300 px-3 py-2 text-sm">
|
||||||
|
<input type="checkbox" name="isVisible" defaultChecked />
|
||||||
|
Visible
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<textarea
|
<textarea
|
||||||
name="description"
|
name="description"
|
||||||
@@ -330,6 +409,89 @@ export default async function PortfolioPage({
|
|||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section className="rounded-xl border border-neutral-200 p-6">
|
||||||
|
<h2 className="text-xl font-medium">Manage Group Entities</h2>
|
||||||
|
<div className="mt-4 grid gap-4">
|
||||||
|
{(
|
||||||
|
[
|
||||||
|
{ type: "gallery" as const, label: "Gallery", items: groups.galleries },
|
||||||
|
{ type: "album" as const, label: "Album", items: groups.albums },
|
||||||
|
{ type: "category" as const, label: "Category", items: groups.categories },
|
||||||
|
{ type: "tag" as const, label: "Tag", items: groups.tags },
|
||||||
|
] as const
|
||||||
|
).map((groupConfig) => (
|
||||||
|
<section
|
||||||
|
key={`manage-${groupConfig.type}`}
|
||||||
|
className="rounded border border-neutral-200 p-4"
|
||||||
|
>
|
||||||
|
<h3 className="text-sm font-semibold">{groupConfig.label} Entities</h3>
|
||||||
|
<div className="mt-3 space-y-3">
|
||||||
|
{groupConfig.items.length === 0 ? (
|
||||||
|
<p className="text-xs text-neutral-500">No entities created yet.</p>
|
||||||
|
) : (
|
||||||
|
groupConfig.items.map((group) => (
|
||||||
|
<form
|
||||||
|
key={`manage-${groupConfig.type}-${group.id}`}
|
||||||
|
action={updateGroupAction}
|
||||||
|
className="space-y-3 rounded border border-neutral-200 p-3"
|
||||||
|
>
|
||||||
|
<input type="hidden" name="groupType" value={groupConfig.type} />
|
||||||
|
<input type="hidden" name="groupId" value={group.id} />
|
||||||
|
<div className="grid gap-3 md:grid-cols-2 xl:grid-cols-4">
|
||||||
|
<input
|
||||||
|
name="name"
|
||||||
|
required
|
||||||
|
defaultValue={group.name}
|
||||||
|
className="rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
name="slug"
|
||||||
|
required
|
||||||
|
defaultValue={group.slug}
|
||||||
|
className="rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
name="sortOrder"
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
defaultValue={group.sortOrder}
|
||||||
|
className="rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
<label className="flex items-center gap-2 rounded border border-neutral-300 px-3 py-2 text-sm">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="isVisible"
|
||||||
|
defaultChecked={group.isVisible}
|
||||||
|
/>
|
||||||
|
Visible
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<textarea
|
||||||
|
name="description"
|
||||||
|
rows={2}
|
||||||
|
defaultValue={group.description ?? ""}
|
||||||
|
placeholder="Description"
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
<Button type="submit">Save group</Button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
formAction={deleteGroupAction}
|
||||||
|
className="rounded border border-red-300 px-3 py-2 text-sm text-red-700 hover:bg-red-50"
|
||||||
|
>
|
||||||
|
Delete group
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section className="rounded-xl border border-neutral-200 p-6">
|
<section className="rounded-xl border border-neutral-200 p-6">
|
||||||
<h2 className="text-xl font-medium">Link Artwork To Group</h2>
|
<h2 className="text-xl font-medium">Link Artwork To Group</h2>
|
||||||
<div className="mt-4 grid gap-4 lg:grid-cols-2">
|
<div className="mt-4 grid gap-4 lg:grid-cols-2">
|
||||||
|
|||||||
@@ -149,6 +149,52 @@ export function MediaUploadForm() {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="grid gap-3 md:grid-cols-2">
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">License type</span>
|
||||||
|
<input
|
||||||
|
name="licenseType"
|
||||||
|
placeholder="e.g. CC BY-NC 4.0"
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">License URL</span>
|
||||||
|
<input
|
||||||
|
name="licenseUrl"
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid gap-3 md:grid-cols-2">
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">Usage context</span>
|
||||||
|
<input
|
||||||
|
name="usageContext"
|
||||||
|
placeholder="e.g. homepage hero, social preview"
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">Location</span>
|
||||||
|
<input
|
||||||
|
name="location"
|
||||||
|
placeholder="e.g. Berlin studio"
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="text-xs text-neutral-600">Captured at</span>
|
||||||
|
<input
|
||||||
|
name="capturedAt"
|
||||||
|
type="datetime-local"
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
<label className="space-y-1">
|
<label className="space-y-1">
|
||||||
<span className="text-xs text-neutral-600">Tags (comma-separated)</span>
|
<span className="text-xs text-neutral-600">Tags (comma-separated)</span>
|
||||||
<input name="tags" className="w-full rounded border border-neutral-300 px-3 py-2 text-sm" />
|
<input name="tags" className="w-full rounded border border-neutral-300 px-3 py-2 text-sm" />
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ describe("CreatePageForm", () => {
|
|||||||
|
|
||||||
expect((screen.getByLabelText("Title") as HTMLInputElement).name).toBe("title")
|
expect((screen.getByLabelText("Title") as HTMLInputElement).name).toBe("title")
|
||||||
expect((screen.getByLabelText("Slug") as HTMLInputElement).name).toBe("slug")
|
expect((screen.getByLabelText("Slug") as HTMLInputElement).name).toBe("slug")
|
||||||
expect((screen.getByLabelText("Content") as HTMLTextAreaElement).name).toBe("content")
|
const contentField = document.querySelector('input[name="content"]') as HTMLInputElement | null
|
||||||
|
expect(contentField).not.toBeNull()
|
||||||
|
expect(contentField?.value.startsWith("[")).toBe(true)
|
||||||
|
|
||||||
const status = screen.getByLabelText("Status") as HTMLSelectElement
|
const status = screen.getByLabelText("Status") as HTMLSelectElement
|
||||||
expect(status.value).toBe("draft")
|
expect(status.value).toBe("draft")
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import { serializePageBlocks } from "@cms/content"
|
||||||
import { Button } from "@cms/ui/button"
|
import { Button } from "@cms/ui/button"
|
||||||
|
|
||||||
|
import { PageBlockEditor } from "./page-block-editor"
|
||||||
|
|
||||||
type CreatePageFormProps = {
|
type CreatePageFormProps = {
|
||||||
action: (formData: FormData) => void | Promise<void>
|
action: (formData: FormData) => void | Promise<void>
|
||||||
}
|
}
|
||||||
@@ -46,15 +49,16 @@ export function CreatePageForm({ action }: CreatePageFormProps) {
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className="space-y-1">
|
<PageBlockEditor
|
||||||
<span className="text-xs text-neutral-600">Content</span>
|
name="content"
|
||||||
<textarea
|
initialContent={serializePageBlocks([
|
||||||
name="content"
|
{
|
||||||
rows={6}
|
id: "initial-rich-text",
|
||||||
required
|
type: "rich_text",
|
||||||
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
body: "",
|
||||||
/>
|
},
|
||||||
</label>
|
])}
|
||||||
|
/>
|
||||||
|
|
||||||
<div className="grid gap-3 md:grid-cols-2">
|
<div className="grid gap-3 md:grid-cols-2">
|
||||||
<label className="space-y-1">
|
<label className="space-y-1">
|
||||||
|
|||||||
292
apps/admin/src/components/pages/page-block-editor.tsx
Normal file
292
apps/admin/src/components/pages/page-block-editor.tsx
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { type PageBlock, type PageBlocks, parsePageBlocks, serializePageBlocks } from "@cms/content"
|
||||||
|
import { useMemo, useState } from "react"
|
||||||
|
|
||||||
|
type PageBlockEditorProps = {
|
||||||
|
name: string
|
||||||
|
initialContent: string
|
||||||
|
label?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomId(prefix: string): string {
|
||||||
|
return `${prefix}-${Math.random().toString(36).slice(2, 10)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeInitialBlocks(initialContent: string): PageBlocks {
|
||||||
|
if (!initialContent.trim()) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: randomId("rich"),
|
||||||
|
type: "rich_text",
|
||||||
|
body: "",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return parsePageBlocks(initialContent)
|
||||||
|
} catch {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: randomId("rich"),
|
||||||
|
type: "rich_text",
|
||||||
|
body: initialContent,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateBlock(blocks: PageBlocks, blockId: string, next: Partial<PageBlock>): PageBlocks {
|
||||||
|
return blocks.map((block) =>
|
||||||
|
block.id === blockId ? ({ ...block, ...next } as PageBlock) : block,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PageBlockEditor({
|
||||||
|
name,
|
||||||
|
initialContent,
|
||||||
|
label = "Page Blocks",
|
||||||
|
}: PageBlockEditorProps) {
|
||||||
|
const [blocks, setBlocks] = useState<PageBlocks>(() => normalizeInitialBlocks(initialContent))
|
||||||
|
|
||||||
|
const serialized = useMemo(() => serializePageBlocks(blocks), [blocks])
|
||||||
|
|
||||||
|
function addBlock(type: PageBlock["type"]) {
|
||||||
|
if (type === "hero") {
|
||||||
|
setBlocks((prev) => [
|
||||||
|
...prev,
|
||||||
|
{
|
||||||
|
id: randomId("hero"),
|
||||||
|
type,
|
||||||
|
heading: "Hero heading",
|
||||||
|
subheading: null,
|
||||||
|
ctaHref: null,
|
||||||
|
ctaLabel: null,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === "rich_text") {
|
||||||
|
setBlocks((prev) => [...prev, { id: randomId("rich"), type, body: "" }])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === "gallery") {
|
||||||
|
setBlocks((prev) => [...prev, { id: randomId("gallery"), type, title: null, imageIds: [] }])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === "cta") {
|
||||||
|
setBlocks((prev) => [
|
||||||
|
...prev,
|
||||||
|
{ id: randomId("cta"), type, label: "Open", href: "/", variant: "primary" },
|
||||||
|
])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === "form") {
|
||||||
|
setBlocks((prev) => [
|
||||||
|
...prev,
|
||||||
|
{ id: randomId("form"), type, formKey: "contact", title: null, description: null },
|
||||||
|
])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setBlocks((prev) => [
|
||||||
|
...prev,
|
||||||
|
{ id: randomId("price"), type: "price_cards", title: null, cards: [] },
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-3 rounded border border-neutral-200 p-3">
|
||||||
|
<input type="hidden" name={name} value={serialized} />
|
||||||
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
|
<span className="text-xs text-neutral-600">{label}</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1 text-xs"
|
||||||
|
onClick={() => addBlock("hero")}
|
||||||
|
>
|
||||||
|
+ Hero
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1 text-xs"
|
||||||
|
onClick={() => addBlock("rich_text")}
|
||||||
|
>
|
||||||
|
+ Rich text
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1 text-xs"
|
||||||
|
onClick={() => addBlock("gallery")}
|
||||||
|
>
|
||||||
|
+ Gallery
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1 text-xs"
|
||||||
|
onClick={() => addBlock("cta")}
|
||||||
|
>
|
||||||
|
+ CTA
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1 text-xs"
|
||||||
|
onClick={() => addBlock("form")}
|
||||||
|
>
|
||||||
|
+ Form
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1 text-xs"
|
||||||
|
onClick={() => addBlock("price_cards")}
|
||||||
|
>
|
||||||
|
+ Price cards
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-3">
|
||||||
|
{blocks.map((block, index) => (
|
||||||
|
<article key={block.id} className="space-y-2 rounded border border-neutral-200 p-3">
|
||||||
|
<div className="flex items-center justify-between text-xs text-neutral-600">
|
||||||
|
<span>
|
||||||
|
#{index + 1} {block.type}
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1"
|
||||||
|
onClick={() => setBlocks((prev) => prev.filter((entry) => entry.id !== block.id))}
|
||||||
|
>
|
||||||
|
Remove
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{block.type === "hero" ? (
|
||||||
|
<div className="grid gap-2 md:grid-cols-2">
|
||||||
|
<input
|
||||||
|
value={block.heading}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { heading: event.target.value }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Heading"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
value={block.subheading ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { subheading: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Subheading"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{block.type === "rich_text" ? (
|
||||||
|
<textarea
|
||||||
|
rows={5}
|
||||||
|
value={block.body}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) => updateBlock(prev, block.id, { body: event.target.value }))
|
||||||
|
}
|
||||||
|
placeholder="Text"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{block.type === "gallery" ? (
|
||||||
|
<textarea
|
||||||
|
rows={3}
|
||||||
|
value={block.imageIds.join(",")}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, {
|
||||||
|
imageIds: event.target.value
|
||||||
|
.split(",")
|
||||||
|
.map((entry) => entry.trim())
|
||||||
|
.filter((entry) => entry.length > 0),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Media asset IDs (comma separated UUIDs)"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{block.type === "cta" ? (
|
||||||
|
<div className="grid gap-2 md:grid-cols-2">
|
||||||
|
<input
|
||||||
|
value={block.label}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) => updateBlock(prev, block.id, { label: event.target.value }))
|
||||||
|
}
|
||||||
|
placeholder="Button label"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
value={block.href}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) => updateBlock(prev, block.id, { href: event.target.value }))
|
||||||
|
}
|
||||||
|
placeholder="Link href"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{block.type === "form" ? (
|
||||||
|
<input
|
||||||
|
value={block.formKey}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) => updateBlock(prev, block.id, { formKey: event.target.value }))
|
||||||
|
}
|
||||||
|
placeholder="Form key (e.g. contact, commission)"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{block.type === "price_cards" ? (
|
||||||
|
<textarea
|
||||||
|
rows={4}
|
||||||
|
value={block.cards
|
||||||
|
.map((card) => [card.name, card.price ?? "", card.description ?? ""].join("|"))
|
||||||
|
.join("\n")}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, {
|
||||||
|
cards: event.target.value
|
||||||
|
.split("\n")
|
||||||
|
.map((line) => line.trim())
|
||||||
|
.filter((line) => line.length > 0)
|
||||||
|
.map((line, lineIndex) => {
|
||||||
|
const [name, price, description] = line
|
||||||
|
.split("|")
|
||||||
|
.map((entry) => entry.trim())
|
||||||
|
return {
|
||||||
|
id: `card-${lineIndex}`,
|
||||||
|
name: name || `Card ${lineIndex + 1}`,
|
||||||
|
price: price || null,
|
||||||
|
description: description || null,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="One card per line: Name|Price|Description"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -25,6 +25,8 @@ export default async function PublicArtworkPage({ params }: PublicArtworkPagePro
|
|||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const primaryMedia = artwork.renditions[0]?.mediaAsset ?? null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="mx-auto w-full max-w-5xl space-y-6 px-6 py-16">
|
<section className="mx-auto w-full max-w-5xl space-y-6 px-6 py-16">
|
||||||
<header className="space-y-2">
|
<header className="space-y-2">
|
||||||
@@ -94,6 +96,22 @@ export default async function PublicArtworkPage({ params }: PublicArtworkPagePro
|
|||||||
<strong>{t("fields.tags")}:</strong>{" "}
|
<strong>{t("fields.tags")}:</strong>{" "}
|
||||||
{formatLabelList(artwork.tagLinks.map((entry) => entry.tag.name))}
|
{formatLabelList(artwork.tagLinks.map((entry) => entry.tag.name))}
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>{t("fields.licenseType")}:</strong> {primaryMedia?.licenseType || "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>{t("fields.licenseUrl")}:</strong> {primaryMedia?.licenseUrl || "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>{t("fields.usageContext")}:</strong> {primaryMedia?.usageContext || "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>{t("fields.location")}:</strong> {primaryMedia?.location || "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>{t("fields.capturedAt")}:</strong>{" "}
|
||||||
|
{primaryMedia?.capturedAt ? primaryMedia.capturedAt.toLocaleDateString("en-US") : "-"}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { parsePageBlocks } from "@cms/content"
|
||||||
|
import Image from "next/image"
|
||||||
|
|
||||||
type PageEntity = {
|
type PageEntity = {
|
||||||
title: string
|
title: string
|
||||||
status: string
|
status: string
|
||||||
@@ -10,6 +13,20 @@ type PublicPageViewProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function PublicPageView({ page }: PublicPageViewProps) {
|
export function PublicPageView({ page }: PublicPageViewProps) {
|
||||||
|
const blocks = (() => {
|
||||||
|
try {
|
||||||
|
return parsePageBlocks(page.content)
|
||||||
|
} catch {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: "fallback-rich-text",
|
||||||
|
type: "rich_text" as const,
|
||||||
|
body: page.content,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-16">
|
<article className="mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-16">
|
||||||
<header className="space-y-3">
|
<header className="space-y-3">
|
||||||
@@ -18,8 +35,105 @@ export function PublicPageView({ page }: PublicPageViewProps) {
|
|||||||
{page.summary ? <p className="text-neutral-600">{page.summary}</p> : null}
|
{page.summary ? <p className="text-neutral-600">{page.summary}</p> : null}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section className="prose prose-neutral max-w-none whitespace-pre-wrap rounded-xl border border-neutral-200 bg-white p-6 text-neutral-800">
|
<section className="space-y-4 rounded-xl border border-neutral-200 bg-white p-6 text-neutral-800">
|
||||||
{page.content}
|
{blocks.map((block) => {
|
||||||
|
if (block.type === "hero") {
|
||||||
|
return (
|
||||||
|
<section key={block.id} className="space-y-2 rounded border border-neutral-200 p-4">
|
||||||
|
<h2 className="text-2xl font-semibold">{block.heading}</h2>
|
||||||
|
{block.subheading ? <p className="text-neutral-600">{block.subheading}</p> : null}
|
||||||
|
{block.ctaLabel && block.ctaHref ? (
|
||||||
|
<a
|
||||||
|
href={block.ctaHref}
|
||||||
|
className="inline-flex rounded bg-neutral-900 px-3 py-1.5 text-sm text-white"
|
||||||
|
>
|
||||||
|
{block.ctaLabel}
|
||||||
|
</a>
|
||||||
|
) : null}
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.type === "rich_text") {
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
key={block.id}
|
||||||
|
className="prose prose-neutral max-w-none whitespace-pre-wrap"
|
||||||
|
>
|
||||||
|
{block.body}
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.type === "gallery") {
|
||||||
|
return (
|
||||||
|
<section key={block.id} className="space-y-3">
|
||||||
|
{block.title ? <h3 className="text-lg font-medium">{block.title}</h3> : null}
|
||||||
|
<div className="grid gap-3 sm:grid-cols-2">
|
||||||
|
{block.imageIds.length === 0 ? (
|
||||||
|
<p className="text-sm text-neutral-500">No media linked yet.</p>
|
||||||
|
) : (
|
||||||
|
block.imageIds.map((imageId) => (
|
||||||
|
<Image
|
||||||
|
key={imageId}
|
||||||
|
src={`/api/media/file/${imageId}`}
|
||||||
|
alt=""
|
||||||
|
width={1200}
|
||||||
|
height={800}
|
||||||
|
className="h-48 w-full rounded border border-neutral-200 object-cover"
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.type === "cta") {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
key={block.id}
|
||||||
|
href={block.href}
|
||||||
|
className={`inline-flex rounded px-3 py-2 text-sm ${
|
||||||
|
block.variant === "secondary"
|
||||||
|
? "border border-neutral-300 text-neutral-800"
|
||||||
|
: "bg-neutral-900 text-white"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{block.label}
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.type === "form") {
|
||||||
|
return (
|
||||||
|
<section key={block.id} className="space-y-2 rounded border border-neutral-200 p-4">
|
||||||
|
<h3 className="text-lg font-medium">{block.title || "Form block"}</h3>
|
||||||
|
<p className="text-sm text-neutral-600">
|
||||||
|
{block.description || "Form integration pending."}
|
||||||
|
</p>
|
||||||
|
<p className="text-xs text-neutral-500">formKey: {block.formKey}</p>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section key={block.id} className="space-y-2 rounded border border-neutral-200 p-4">
|
||||||
|
{block.title ? <h3 className="text-lg font-medium">{block.title}</h3> : null}
|
||||||
|
<div className="grid gap-3 md:grid-cols-2">
|
||||||
|
{block.cards.map((card) => (
|
||||||
|
<article key={card.id} className="rounded border border-neutral-200 p-3">
|
||||||
|
<h4 className="font-medium">{card.name}</h4>
|
||||||
|
{card.price ? <p className="text-sm text-neutral-700">{card.price}</p> : null}
|
||||||
|
{card.description ? (
|
||||||
|
<p className="text-sm text-neutral-600">{card.description}</p>
|
||||||
|
) : null}
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -87,7 +87,12 @@
|
|||||||
"galleries": "Galerien",
|
"galleries": "Galerien",
|
||||||
"albums": "Alben",
|
"albums": "Alben",
|
||||||
"categories": "Kategorien",
|
"categories": "Kategorien",
|
||||||
"tags": "Tags"
|
"tags": "Tags",
|
||||||
|
"licenseType": "Lizenztyp",
|
||||||
|
"licenseUrl": "Lizenz-URL",
|
||||||
|
"usageContext": "Nutzungskontext",
|
||||||
|
"location": "Ort",
|
||||||
|
"capturedAt": "Aufgenommen am"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,12 @@
|
|||||||
"galleries": "Galleries",
|
"galleries": "Galleries",
|
||||||
"albums": "Albums",
|
"albums": "Albums",
|
||||||
"categories": "Categories",
|
"categories": "Categories",
|
||||||
"tags": "Tags"
|
"tags": "Tags",
|
||||||
|
"licenseType": "License type",
|
||||||
|
"licenseUrl": "License URL",
|
||||||
|
"usageContext": "Usage context",
|
||||||
|
"location": "Location",
|
||||||
|
"capturedAt": "Captured at"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,12 @@
|
|||||||
"galleries": "Galerías",
|
"galleries": "Galerías",
|
||||||
"albums": "Álbumes",
|
"albums": "Álbumes",
|
||||||
"categories": "Categorías",
|
"categories": "Categorías",
|
||||||
"tags": "Etiquetas"
|
"tags": "Etiquetas",
|
||||||
|
"licenseType": "Tipo de licencia",
|
||||||
|
"licenseUrl": "URL de licencia",
|
||||||
|
"usageContext": "Contexto de uso",
|
||||||
|
"location": "Ubicación",
|
||||||
|
"capturedAt": "Capturado el"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,12 @@
|
|||||||
"galleries": "Galeries",
|
"galleries": "Galeries",
|
||||||
"albums": "Albums",
|
"albums": "Albums",
|
||||||
"categories": "Catégories",
|
"categories": "Catégories",
|
||||||
"tags": "Tags"
|
"tags": "Tags",
|
||||||
|
"licenseType": "Type de licence",
|
||||||
|
"licenseUrl": "URL de licence",
|
||||||
|
"usageContext": "Contexte d'utilisation",
|
||||||
|
"location": "Lieu",
|
||||||
|
"capturedAt": "Capturé le"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import {
|
|||||||
createCustomerInputSchema,
|
createCustomerInputSchema,
|
||||||
createNavigationMenuInputSchema,
|
createNavigationMenuInputSchema,
|
||||||
createPageInputSchema,
|
createPageInputSchema,
|
||||||
|
parsePageBlocks,
|
||||||
|
serializePageBlocks,
|
||||||
updateCommissionStatusInputSchema,
|
updateCommissionStatusInputSchema,
|
||||||
updateNavigationItemInputSchema,
|
updateNavigationItemInputSchema,
|
||||||
} from "./index"
|
} from "./index"
|
||||||
@@ -64,4 +66,23 @@ describe("domain schemas", () => {
|
|||||||
expect(menu.success).toBe(true)
|
expect(menu.success).toBe(true)
|
||||||
expect(navUpdate.success).toBe(false)
|
expect(navUpdate.success).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("parses and serializes page blocks with legacy fallback", () => {
|
||||||
|
const legacy = parsePageBlocks("Legacy body")
|
||||||
|
expect(legacy[0]?.type).toBe("rich_text")
|
||||||
|
|
||||||
|
const serialized = serializePageBlocks([
|
||||||
|
{
|
||||||
|
id: "hero-1",
|
||||||
|
type: "hero",
|
||||||
|
heading: "Hello",
|
||||||
|
subheading: null,
|
||||||
|
ctaLabel: null,
|
||||||
|
ctaHref: null,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const parsed = parsePageBlocks(serialized)
|
||||||
|
expect(parsed[0]?.type).toBe("hero")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -12,10 +12,14 @@ describe("media schemas", () => {
|
|||||||
const parsed = createMediaAssetInputSchema.parse({
|
const parsed = createMediaAssetInputSchema.parse({
|
||||||
type: "artwork",
|
type: "artwork",
|
||||||
title: "Artwork",
|
title: "Artwork",
|
||||||
|
licenseType: "CC BY",
|
||||||
|
usageContext: "homepage hero",
|
||||||
|
capturedAt: new Date("2026-01-02T10:30:00.000Z"),
|
||||||
tags: ["tag-a"],
|
tags: ["tag-a"],
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(parsed.type).toBe("artwork")
|
expect(parsed.type).toBe("artwork")
|
||||||
|
expect(parsed.licenseType).toBe("CC BY")
|
||||||
expect(parsed.tags).toEqual(["tag-a"])
|
expect(parsed.tags).toEqual(["tag-a"])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ export const createMediaAssetInputSchema = z.object({
|
|||||||
source: z.string().max(500).optional(),
|
source: z.string().max(500).optional(),
|
||||||
copyright: z.string().max(500).optional(),
|
copyright: z.string().max(500).optional(),
|
||||||
author: z.string().max(180).optional(),
|
author: z.string().max(180).optional(),
|
||||||
|
licenseType: z.string().max(120).optional(),
|
||||||
|
licenseUrl: z.string().max(500).optional(),
|
||||||
|
usageContext: z.string().max(300).optional(),
|
||||||
|
location: z.string().max(180).optional(),
|
||||||
|
capturedAt: z.date().optional(),
|
||||||
tags: z.array(z.string().min(1).max(100)).default([]),
|
tags: z.array(z.string().min(1).max(100)).default([]),
|
||||||
storageKey: z.string().max(500).optional(),
|
storageKey: z.string().max(500).optional(),
|
||||||
mimeType: z.string().max(180).optional(),
|
mimeType: z.string().max(180).optional(),
|
||||||
@@ -38,6 +43,11 @@ export const updateMediaAssetInputSchema = z.object({
|
|||||||
source: z.string().max(500).nullable().optional(),
|
source: z.string().max(500).nullable().optional(),
|
||||||
copyright: z.string().max(500).nullable().optional(),
|
copyright: z.string().max(500).nullable().optional(),
|
||||||
author: z.string().max(180).nullable().optional(),
|
author: z.string().max(180).nullable().optional(),
|
||||||
|
licenseType: z.string().max(120).nullable().optional(),
|
||||||
|
licenseUrl: z.string().max(500).nullable().optional(),
|
||||||
|
usageContext: z.string().max(300).nullable().optional(),
|
||||||
|
location: z.string().max(180).nullable().optional(),
|
||||||
|
capturedAt: z.date().nullable().optional(),
|
||||||
tags: z.array(z.string().min(1).max(100)).optional(),
|
tags: z.array(z.string().min(1).max(100)).optional(),
|
||||||
mimeType: z.string().max(180).nullable().optional(),
|
mimeType: z.string().max(180).nullable().optional(),
|
||||||
width: z.number().int().positive().nullable().optional(),
|
width: z.number().int().positive().nullable().optional(),
|
||||||
@@ -65,6 +75,21 @@ export const createGroupingInputSchema = z.object({
|
|||||||
isVisible: z.boolean().default(true),
|
isVisible: z.boolean().default(true),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const updateGroupingInputSchema = z.object({
|
||||||
|
groupType: z.enum(["gallery", "album", "category", "tag"]),
|
||||||
|
groupId: z.string().uuid(),
|
||||||
|
name: z.string().min(1).max(180),
|
||||||
|
slug: z.string().min(1).max(180),
|
||||||
|
description: z.string().max(5000).nullable().optional(),
|
||||||
|
sortOrder: z.number().int().min(0),
|
||||||
|
isVisible: z.boolean(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const deleteGroupingInputSchema = z.object({
|
||||||
|
groupType: z.enum(["gallery", "album", "category", "tag"]),
|
||||||
|
groupId: z.string().uuid(),
|
||||||
|
})
|
||||||
|
|
||||||
export const linkArtworkGroupingInputSchema = z.object({
|
export const linkArtworkGroupingInputSchema = z.object({
|
||||||
artworkId: z.string().uuid(),
|
artworkId: z.string().uuid(),
|
||||||
groupType: z.enum(["gallery", "album", "category", "tag"]),
|
groupType: z.enum(["gallery", "album", "category", "tag"]),
|
||||||
@@ -86,5 +111,7 @@ export type CreateMediaAssetInput = z.infer<typeof createMediaAssetInputSchema>
|
|||||||
export type UpdateMediaAssetInput = z.infer<typeof updateMediaAssetInputSchema>
|
export type UpdateMediaAssetInput = z.infer<typeof updateMediaAssetInputSchema>
|
||||||
export type CreateArtworkInput = z.infer<typeof createArtworkInputSchema>
|
export type CreateArtworkInput = z.infer<typeof createArtworkInputSchema>
|
||||||
export type CreateGroupingInput = z.infer<typeof createGroupingInputSchema>
|
export type CreateGroupingInput = z.infer<typeof createGroupingInputSchema>
|
||||||
|
export type UpdateGroupingInput = z.infer<typeof updateGroupingInputSchema>
|
||||||
|
export type DeleteGroupingInput = z.infer<typeof deleteGroupingInputSchema>
|
||||||
export type LinkArtworkGroupingInput = z.infer<typeof linkArtworkGroupingInputSchema>
|
export type LinkArtworkGroupingInput = z.infer<typeof linkArtworkGroupingInputSchema>
|
||||||
export type AttachArtworkRenditionInput = z.infer<typeof attachArtworkRenditionInputSchema>
|
export type AttachArtworkRenditionInput = z.infer<typeof attachArtworkRenditionInputSchema>
|
||||||
|
|||||||
@@ -3,6 +3,98 @@ import { z } from "zod"
|
|||||||
export const pageStatusSchema = z.enum(["draft", "published"])
|
export const pageStatusSchema = z.enum(["draft", "published"])
|
||||||
export const pageLocaleSchema = z.enum(["de", "en", "es", "fr"])
|
export const pageLocaleSchema = z.enum(["de", "en", "es", "fr"])
|
||||||
|
|
||||||
|
const pageBlockBaseSchema = z.object({
|
||||||
|
id: z.string().min(1),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const heroPageBlockSchema = pageBlockBaseSchema.extend({
|
||||||
|
type: z.literal("hero"),
|
||||||
|
heading: z.string().min(1).max(180),
|
||||||
|
subheading: z.string().max(500).nullable().optional(),
|
||||||
|
ctaLabel: z.string().max(80).nullable().optional(),
|
||||||
|
ctaHref: z.string().max(500).nullable().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const richTextPageBlockSchema = pageBlockBaseSchema.extend({
|
||||||
|
type: z.literal("rich_text"),
|
||||||
|
body: z.string().min(1),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const galleryPageBlockSchema = pageBlockBaseSchema.extend({
|
||||||
|
type: z.literal("gallery"),
|
||||||
|
title: z.string().max(180).nullable().optional(),
|
||||||
|
imageIds: z.array(z.string().uuid()).default([]),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const ctaPageBlockSchema = pageBlockBaseSchema.extend({
|
||||||
|
type: z.literal("cta"),
|
||||||
|
label: z.string().min(1).max(80),
|
||||||
|
href: z.string().max(500),
|
||||||
|
variant: z.enum(["primary", "secondary"]).default("primary"),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const formPageBlockSchema = pageBlockBaseSchema.extend({
|
||||||
|
type: z.literal("form"),
|
||||||
|
formKey: z.string().min(1).max(120),
|
||||||
|
title: z.string().max(180).nullable().optional(),
|
||||||
|
description: z.string().max(500).nullable().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const priceCardsPageBlockSchema = pageBlockBaseSchema.extend({
|
||||||
|
type: z.literal("price_cards"),
|
||||||
|
title: z.string().max(180).nullable().optional(),
|
||||||
|
cards: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
id: z.string().min(1),
|
||||||
|
name: z.string().min(1).max(180),
|
||||||
|
price: z.string().max(80).nullable().optional(),
|
||||||
|
description: z.string().max(500).nullable().optional(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.default([]),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const pageBlockSchema = z.discriminatedUnion("type", [
|
||||||
|
heroPageBlockSchema,
|
||||||
|
richTextPageBlockSchema,
|
||||||
|
galleryPageBlockSchema,
|
||||||
|
ctaPageBlockSchema,
|
||||||
|
formPageBlockSchema,
|
||||||
|
priceCardsPageBlockSchema,
|
||||||
|
])
|
||||||
|
|
||||||
|
export const pageBlocksSchema = z.array(pageBlockSchema)
|
||||||
|
|
||||||
|
function isJsonLike(value: string): boolean {
|
||||||
|
const trimmed = value.trim()
|
||||||
|
return trimmed.startsWith("{") || trimmed.startsWith("[")
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parsePageBlocks(content: string): z.infer<typeof pageBlocksSchema> {
|
||||||
|
if (!isJsonLike(content)) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: "legacy-rich-text",
|
||||||
|
type: "rich_text",
|
||||||
|
body: content,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed = JSON.parse(content)
|
||||||
|
|
||||||
|
if (!Array.isArray(parsed)) {
|
||||||
|
throw new Error("Page block payload must be an array.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return pageBlocksSchema.parse(parsed)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function serializePageBlocks(blocks: z.infer<typeof pageBlocksSchema>): string {
|
||||||
|
return JSON.stringify(pageBlocksSchema.parse(blocks))
|
||||||
|
}
|
||||||
|
|
||||||
export const createPageInputSchema = z.object({
|
export const createPageInputSchema = z.object({
|
||||||
title: z.string().min(1).max(180),
|
title: z.string().min(1).max(180),
|
||||||
slug: z.string().min(1).max(180),
|
slug: z.string().min(1).max(180),
|
||||||
@@ -67,3 +159,5 @@ export type UpsertPageTranslationInput = z.infer<typeof upsertPageTranslationInp
|
|||||||
export type CreateNavigationMenuInput = z.infer<typeof createNavigationMenuInputSchema>
|
export type CreateNavigationMenuInput = z.infer<typeof createNavigationMenuInputSchema>
|
||||||
export type CreateNavigationItemInput = z.infer<typeof createNavigationItemInputSchema>
|
export type CreateNavigationItemInput = z.infer<typeof createNavigationItemInputSchema>
|
||||||
export type UpdateNavigationItemInput = z.infer<typeof updateNavigationItemInputSchema>
|
export type UpdateNavigationItemInput = z.infer<typeof updateNavigationItemInputSchema>
|
||||||
|
export type PageBlock = z.infer<typeof pageBlockSchema>
|
||||||
|
export type PageBlocks = z.infer<typeof pageBlocksSchema>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ALTER TABLE "MediaAsset"
|
||||||
|
ADD COLUMN "licenseType" TEXT,
|
||||||
|
ADD COLUMN "licenseUrl" TEXT,
|
||||||
|
ADD COLUMN "usageContext" TEXT,
|
||||||
|
ADD COLUMN "location" TEXT,
|
||||||
|
ADD COLUMN "capturedAt" TIMESTAMP(3);
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE "Tag"
|
||||||
|
ADD COLUMN "description" TEXT,
|
||||||
|
ADD COLUMN "sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
ADD COLUMN "isVisible" BOOLEAN NOT NULL DEFAULT true;
|
||||||
@@ -123,6 +123,11 @@ model MediaAsset {
|
|||||||
source String?
|
source String?
|
||||||
copyright String?
|
copyright String?
|
||||||
author String?
|
author String?
|
||||||
|
licenseType String?
|
||||||
|
licenseUrl String?
|
||||||
|
usageContext String?
|
||||||
|
location String?
|
||||||
|
capturedAt DateTime?
|
||||||
tags String[]
|
tags String[]
|
||||||
storageKey String? @unique
|
storageKey String? @unique
|
||||||
mimeType String?
|
mimeType String?
|
||||||
@@ -217,6 +222,9 @@ model Tag {
|
|||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
name String
|
name String
|
||||||
slug String @unique
|
slug String @unique
|
||||||
|
description String?
|
||||||
|
sortOrder Int @default(0)
|
||||||
|
isVisible Boolean @default(true)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
artworkLinks ArtworkTag[]
|
artworkLinks ArtworkTag[]
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export {
|
|||||||
createGallery,
|
createGallery,
|
||||||
createMediaAsset,
|
createMediaAsset,
|
||||||
createTag,
|
createTag,
|
||||||
|
deleteGrouping,
|
||||||
deleteMediaAsset,
|
deleteMediaAsset,
|
||||||
getMediaAssetById,
|
getMediaAssetById,
|
||||||
getMediaFoundationSummary,
|
getMediaFoundationSummary,
|
||||||
@@ -34,6 +35,7 @@ export {
|
|||||||
listMediaFoundationGroups,
|
listMediaFoundationGroups,
|
||||||
listPublishedArtworks,
|
listPublishedArtworks,
|
||||||
listPublishedPortfolioGroups,
|
listPublishedPortfolioGroups,
|
||||||
|
updateGrouping,
|
||||||
updateMediaAsset,
|
updateMediaAsset,
|
||||||
} from "./media-foundation"
|
} from "./media-foundation"
|
||||||
export type { PublicNavigationItem } from "./pages-navigation"
|
export type { PublicNavigationItem } from "./pages-navigation"
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import {
|
|||||||
createArtworkInputSchema,
|
createArtworkInputSchema,
|
||||||
createGroupingInputSchema,
|
createGroupingInputSchema,
|
||||||
createMediaAssetInputSchema,
|
createMediaAssetInputSchema,
|
||||||
|
deleteGroupingInputSchema,
|
||||||
linkArtworkGroupingInputSchema,
|
linkArtworkGroupingInputSchema,
|
||||||
|
updateGroupingInputSchema,
|
||||||
updateMediaAssetInputSchema,
|
updateMediaAssetInputSchema,
|
||||||
} from "@cms/content"
|
} from "@cms/content"
|
||||||
|
|
||||||
@@ -96,7 +98,7 @@ export async function listMediaFoundationGroups() {
|
|||||||
orderBy: [{ sortOrder: "asc" }, { name: "asc" }],
|
orderBy: [{ sortOrder: "asc" }, { name: "asc" }],
|
||||||
}),
|
}),
|
||||||
db.tag.findMany({
|
db.tag.findMany({
|
||||||
orderBy: { name: "asc" },
|
orderBy: [{ sortOrder: "asc" }, { name: "asc" }],
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -171,18 +173,76 @@ export async function createCategory(input: unknown) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function createTag(input: unknown) {
|
export async function createTag(input: unknown) {
|
||||||
const payload = createGroupingInputSchema
|
const payload = createGroupingInputSchema.parse(input)
|
||||||
.pick({
|
|
||||||
name: true,
|
|
||||||
slug: true,
|
|
||||||
})
|
|
||||||
.parse(input)
|
|
||||||
|
|
||||||
return db.tag.create({
|
return db.tag.create({
|
||||||
data: payload,
|
data: payload,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateGrouping(input: unknown) {
|
||||||
|
const payload = updateGroupingInputSchema.parse(input)
|
||||||
|
const data = {
|
||||||
|
name: payload.name,
|
||||||
|
slug: payload.slug,
|
||||||
|
description: payload.description ?? null,
|
||||||
|
sortOrder: payload.sortOrder,
|
||||||
|
isVisible: payload.isVisible,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.groupType === "gallery") {
|
||||||
|
return db.gallery.update({
|
||||||
|
where: { id: payload.groupId },
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.groupType === "album") {
|
||||||
|
return db.album.update({
|
||||||
|
where: { id: payload.groupId },
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.groupType === "category") {
|
||||||
|
return db.category.update({
|
||||||
|
where: { id: payload.groupId },
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return db.tag.update({
|
||||||
|
where: { id: payload.groupId },
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteGrouping(input: unknown) {
|
||||||
|
const payload = deleteGroupingInputSchema.parse(input)
|
||||||
|
|
||||||
|
if (payload.groupType === "gallery") {
|
||||||
|
return db.gallery.delete({
|
||||||
|
where: { id: payload.groupId },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.groupType === "album") {
|
||||||
|
return db.album.delete({
|
||||||
|
where: { id: payload.groupId },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.groupType === "category") {
|
||||||
|
return db.category.delete({
|
||||||
|
where: { id: payload.groupId },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return db.tag.delete({
|
||||||
|
where: { id: payload.groupId },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function linkArtworkToGrouping(input: unknown) {
|
export async function linkArtworkToGrouping(input: unknown) {
|
||||||
const payload = linkArtworkGroupingInputSchema.parse(input)
|
const payload = linkArtworkGroupingInputSchema.parse(input)
|
||||||
|
|
||||||
@@ -325,7 +385,10 @@ export async function listPublishedPortfolioGroups() {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
db.tag.findMany({
|
db.tag.findMany({
|
||||||
orderBy: [{ name: "asc" }],
|
where: {
|
||||||
|
isVisible: true,
|
||||||
|
},
|
||||||
|
orderBy: [{ sortOrder: "asc" }, { name: "asc" }],
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
@@ -381,6 +444,7 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput =
|
|||||||
some: {
|
some: {
|
||||||
tag: {
|
tag: {
|
||||||
slug: input.groupSlug,
|
slug: input.groupSlug,
|
||||||
|
isVisible: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -484,6 +548,11 @@ export async function getPublishedArtworkBySlug(slug: string) {
|
|||||||
source: true,
|
source: true,
|
||||||
author: true,
|
author: true,
|
||||||
copyright: true,
|
copyright: true,
|
||||||
|
licenseType: true,
|
||||||
|
licenseUrl: true,
|
||||||
|
usageContext: true,
|
||||||
|
location: true,
|
||||||
|
capturedAt: true,
|
||||||
tags: true,
|
tags: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user