Compare commits
6 Commits
todo/mvp1-
...
todo/mvp1-
| Author | SHA1 | Date | |
|---|---|---|---|
|
473433b220
|
|||
|
987843d96b
|
|||
|
c6ebf3759a
|
|||
|
81983cfe40
|
|||
|
697b3ab5e7
|
|||
|
984511f166
|
18
TODO.md
18
TODO.md
@@ -137,14 +137,14 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
### Admin App (Primary Focus)
|
### Admin App (Primary Focus)
|
||||||
|
|
||||||
- [~] [P1] Page management (create/edit/publish/unpublish/schedule)
|
- [~] [P1] Page management (create/edit/publish/unpublish/schedule)
|
||||||
- [ ] [P1] Page builder with reusable content blocks (hero, rich text, gallery, CTA, forms, price cards)
|
- [x] [P1] Page builder with reusable content blocks (hero, rich text, gallery, CTA, forms, price cards)
|
||||||
- [~] [P1] Navigation management (menus, nested items, order, visibility)
|
- [x] [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)
|
||||||
- [x] [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)
|
- [x] [P1] Artwork refinement fields (medium, dimensions, year, framing, availability, price visibility)
|
||||||
- [ ] [P1] Artwork rendition management (thumbnail, card, full, retina/custom sizes)
|
- [x] [P1] Artwork rendition management (thumbnail, card, full, retina/custom sizes)
|
||||||
- [ ] [P1] Type-specific processing presets (artwork/banner/promo/video/gif) with validation rules
|
- [x] [P1] Type-specific processing presets (artwork/banner/promo/video/gif) with validation rules
|
||||||
- [ ] [P1] Users management (invite, roles, status)
|
- [ ] [P1] Users management (invite, roles, status)
|
||||||
- [ ] [P1] Disable/ban user function and enforcement in auth/session checks
|
- [ ] [P1] Disable/ban user function and enforcement in auth/session checks
|
||||||
- [~] [P1] Owner/support protection rules in user management actions (cannot delete/demote)
|
- [~] [P1] Owner/support protection rules in user management actions (cannot delete/demote)
|
||||||
@@ -361,6 +361,12 @@ 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] Artwork refinement baseline completed: admin `/portfolio` now captures/edits medium, dimensions, year, framing, availability, publish state, and optional price visibility (`priceAmountCents` + `priceCurrency`), with public artwork detail rendering visible prices only.
|
||||||
|
- [2026-02-12] Artwork rendition management completed: admin `/portfolio` supports `thumbnail/card/full/retina/custom` slot assignment with dimensions and primary flag, plus per-artwork rendition listing and delete controls.
|
||||||
|
- [2026-02-12] Media type presets baseline completed in upload API: server-side validation now uses shared per-type rules (mime + max size) for `artwork/banner/promotion/video/gif/generic`, with optional env cap override via `CMS_MEDIA_UPLOAD_MAX_BYTES`.
|
||||||
|
- [2026-02-12] Page builder reusable blocks completed: admin block editor now supports full field editing + ordering controls for hero/rich-text/gallery/cta/form/price-cards; public renderer includes form-link behavior for `contact`/`commission` keys.
|
||||||
|
- [2026-02-12] Navigation management completed: admin `/navigation` now supports menu update/delete controls, nested item parent selection via menu-local dropdown, and full order/visibility updates across menus and items.
|
||||||
- [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`.
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { randomUUID } from "node:crypto"
|
import { randomUUID } from "node:crypto"
|
||||||
|
import {
|
||||||
|
getMediaUploadMaxBytes,
|
||||||
|
isMimeAllowedForMediaType,
|
||||||
|
mediaAssetTypeSchema,
|
||||||
|
} from "@cms/content"
|
||||||
import { hasPermission } from "@cms/content/rbac"
|
import { hasPermission } from "@cms/content/rbac"
|
||||||
import { createMediaAsset } from "@cms/db"
|
import { createMediaAsset } from "@cms/db"
|
||||||
|
|
||||||
@@ -7,33 +12,7 @@ import { storeUpload } from "@/lib/media/storage"
|
|||||||
|
|
||||||
export const runtime = "nodejs"
|
export const runtime = "nodejs"
|
||||||
|
|
||||||
const MAX_UPLOAD_BYTES = Number(process.env.CMS_MEDIA_UPLOAD_MAX_BYTES ?? 25 * 1024 * 1024)
|
const MAX_UPLOAD_BYTES_OVERRIDE = Number(process.env.CMS_MEDIA_UPLOAD_MAX_BYTES ?? 0)
|
||||||
|
|
||||||
type AllowedRule = {
|
|
||||||
mimePrefix?: string
|
|
||||||
mimeExact?: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
const ALLOWED_MIME_BY_TYPE: Record<string, AllowedRule> = {
|
|
||||||
artwork: {
|
|
||||||
mimePrefix: "image/",
|
|
||||||
},
|
|
||||||
banner: {
|
|
||||||
mimePrefix: "image/",
|
|
||||||
},
|
|
||||||
promotion: {
|
|
||||||
mimePrefix: "image/",
|
|
||||||
},
|
|
||||||
video: {
|
|
||||||
mimePrefix: "video/",
|
|
||||||
},
|
|
||||||
gif: {
|
|
||||||
mimeExact: ["image/gif"],
|
|
||||||
},
|
|
||||||
generic: {
|
|
||||||
mimePrefix: "",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseTextField(formData: FormData, field: string): string {
|
function parseTextField(formData: FormData, field: string): string {
|
||||||
const value = formData.get(field)
|
const value = formData.get(field)
|
||||||
@@ -88,24 +67,6 @@ function deriveTitleFromFilename(fileName: string): string {
|
|||||||
return normalized.length > 0 ? normalized : "Untitled media"
|
return normalized.length > 0 ? normalized : "Untitled media"
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMimeAllowed(mediaType: string, mimeType: string): boolean {
|
|
||||||
const rule = ALLOWED_MIME_BY_TYPE[mediaType]
|
|
||||||
|
|
||||||
if (!rule) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rule.mimeExact?.includes(mimeType)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rule.mimePrefix === "") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return rule.mimePrefix ? mimeType.startsWith(rule.mimePrefix) : false
|
|
||||||
}
|
|
||||||
|
|
||||||
function badRequest(message: string): Response {
|
function badRequest(message: string): Response {
|
||||||
return Response.json(
|
return Response.json(
|
||||||
{
|
{
|
||||||
@@ -147,12 +108,13 @@ export async function POST(request: Request): Promise<Response> {
|
|||||||
return badRequest("Invalid form payload.")
|
return badRequest("Invalid form payload.")
|
||||||
}
|
}
|
||||||
|
|
||||||
const type = parseTextField(formData, "type")
|
const parsedType = mediaAssetTypeSchema.safeParse(parseTextField(formData, "type"))
|
||||||
const fileEntry = formData.get("file")
|
const fileEntry = formData.get("file")
|
||||||
|
|
||||||
if (!type) {
|
if (!parsedType.success) {
|
||||||
return badRequest("Type is required.")
|
return badRequest("Type is required.")
|
||||||
}
|
}
|
||||||
|
const type = parsedType.data
|
||||||
|
|
||||||
if (!(fileEntry instanceof File)) {
|
if (!(fileEntry instanceof File)) {
|
||||||
return badRequest("File is required.")
|
return badRequest("File is required.")
|
||||||
@@ -162,13 +124,17 @@ export async function POST(request: Request): Promise<Response> {
|
|||||||
return badRequest("File is empty.")
|
return badRequest("File is empty.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileEntry.size > MAX_UPLOAD_BYTES) {
|
const typeMaxBytes = getMediaUploadMaxBytes(type)
|
||||||
|
const effectiveMaxBytes =
|
||||||
|
MAX_UPLOAD_BYTES_OVERRIDE > 0 ? Math.min(MAX_UPLOAD_BYTES_OVERRIDE, typeMaxBytes) : typeMaxBytes
|
||||||
|
|
||||||
|
if (fileEntry.size > effectiveMaxBytes) {
|
||||||
return badRequest(
|
return badRequest(
|
||||||
`File is too large. Maximum upload is ${Math.floor(MAX_UPLOAD_BYTES / 1024 / 1024)} MB.`,
|
`File is too large for ${type}. Maximum upload is ${Math.floor(effectiveMaxBytes / 1024 / 1024)} MB.`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isMimeAllowed(type, fileEntry.type)) {
|
if (!isMimeAllowedForMediaType(type, fileEntry.type)) {
|
||||||
return badRequest(`File type ${fileEntry.type || "unknown"} is not allowed for ${type}.`)
|
return badRequest(`File type ${fileEntry.type || "unknown"} is not allowed for ${type}.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import {
|
|||||||
createNavigationItem,
|
createNavigationItem,
|
||||||
createNavigationMenu,
|
createNavigationMenu,
|
||||||
deleteNavigationItem,
|
deleteNavigationItem,
|
||||||
|
deleteNavigationMenu,
|
||||||
listNavigationMenus,
|
listNavigationMenus,
|
||||||
listPages,
|
listPages,
|
||||||
updateNavigationItem,
|
updateNavigationItem,
|
||||||
|
updateNavigationMenu,
|
||||||
upsertNavigationItemTranslation,
|
upsertNavigationItemTranslation,
|
||||||
} from "@cms/db"
|
} from "@cms/db"
|
||||||
import { Button } from "@cms/ui/button"
|
import { Button } from "@cms/ui/button"
|
||||||
@@ -131,6 +133,50 @@ async function createItemAction(formData: FormData) {
|
|||||||
redirectWithState({ notice: "Navigation item created." })
|
redirectWithState({ notice: "Navigation item created." })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateMenuAction(formData: FormData) {
|
||||||
|
"use server"
|
||||||
|
|
||||||
|
await requirePermissionForRoute({
|
||||||
|
nextPath: "/navigation",
|
||||||
|
permission: "navigation:write",
|
||||||
|
scope: "team",
|
||||||
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateNavigationMenu({
|
||||||
|
id: readInputString(formData, "id"),
|
||||||
|
name: readInputString(formData, "name"),
|
||||||
|
slug: readInputString(formData, "slug"),
|
||||||
|
location: readInputString(formData, "location"),
|
||||||
|
isVisible: readInputString(formData, "isVisible") === "true",
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
redirectWithState({ error: "Failed to update navigation menu." })
|
||||||
|
}
|
||||||
|
|
||||||
|
revalidatePath("/navigation")
|
||||||
|
redirectWithState({ notice: "Navigation menu updated." })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteMenuAction(formData: FormData) {
|
||||||
|
"use server"
|
||||||
|
|
||||||
|
await requirePermissionForRoute({
|
||||||
|
nextPath: "/navigation",
|
||||||
|
permission: "navigation:write",
|
||||||
|
scope: "team",
|
||||||
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
await deleteNavigationMenu(readInputString(formData, "id"))
|
||||||
|
} catch {
|
||||||
|
redirectWithState({ error: "Failed to delete navigation menu." })
|
||||||
|
}
|
||||||
|
|
||||||
|
revalidatePath("/navigation")
|
||||||
|
redirectWithState({ notice: "Navigation menu deleted." })
|
||||||
|
}
|
||||||
|
|
||||||
async function updateItemAction(formData: FormData) {
|
async function updateItemAction(formData: FormData) {
|
||||||
"use server"
|
"use server"
|
||||||
|
|
||||||
@@ -279,14 +325,58 @@ export default async function NavigationManagementPage({
|
|||||||
) : (
|
) : (
|
||||||
menus.map((menu) => (
|
menus.map((menu) => (
|
||||||
<article key={menu.id} className="rounded-xl border border-neutral-200 p-6">
|
<article key={menu.id} className="rounded-xl border border-neutral-200 p-6">
|
||||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
<form action={updateMenuAction} className="rounded border border-neutral-200 p-3">
|
||||||
<h3 className="text-lg font-medium">
|
<input type="hidden" name="id" value={menu.id} />
|
||||||
{menu.name} <span className="text-sm text-neutral-500">({menu.location})</span>
|
<div className="grid gap-3 md:grid-cols-4">
|
||||||
</h3>
|
<label className="space-y-1">
|
||||||
<span className="text-xs text-neutral-500">
|
<span className="text-xs text-neutral-600">Menu name</span>
|
||||||
{menu.isVisible ? "visible" : "hidden"}
|
<input
|
||||||
</span>
|
name="name"
|
||||||
|
defaultValue={menu.name}
|
||||||
|
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">Slug</span>
|
||||||
|
<input
|
||||||
|
name="slug"
|
||||||
|
defaultValue={menu.slug}
|
||||||
|
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={menu.location}
|
||||||
|
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">Visible</span>
|
||||||
|
<select
|
||||||
|
name="isVisible"
|
||||||
|
defaultValue={menu.isVisible ? "true" : "false"}
|
||||||
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
>
|
||||||
|
<option value="true">Visible</option>
|
||||||
|
<option value="false">Hidden</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mt-3 flex items-center gap-2">
|
||||||
|
<Button type="submit" size="sm">
|
||||||
|
Save menu
|
||||||
|
</Button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
formAction={deleteMenuAction}
|
||||||
|
className="rounded-md border border-red-300 px-3 py-2 text-sm text-red-700"
|
||||||
|
>
|
||||||
|
Delete menu
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
<div className="mt-4 space-y-3">
|
<div className="mt-4 space-y-3">
|
||||||
{menu.items.length === 0 ? (
|
{menu.items.length === 0 ? (
|
||||||
@@ -348,11 +438,20 @@ export default async function NavigationManagementPage({
|
|||||||
</label>
|
</label>
|
||||||
<label className="space-y-1">
|
<label className="space-y-1">
|
||||||
<span className="text-xs text-neutral-600">Parent id</span>
|
<span className="text-xs text-neutral-600">Parent id</span>
|
||||||
<input
|
<select
|
||||||
name="parentId"
|
name="parentId"
|
||||||
defaultValue={item.parentId ?? ""}
|
defaultValue={item.parentId ?? ""}
|
||||||
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
/>
|
>
|
||||||
|
<option value="">(none)</option>
|
||||||
|
{menu.items
|
||||||
|
.filter((entry) => entry.id !== item.id)
|
||||||
|
.map((entry) => (
|
||||||
|
<option key={`${item.id}-parent-${entry.id}`} value={entry.id}>
|
||||||
|
{entry.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ import {
|
|||||||
createCategory,
|
createCategory,
|
||||||
createGallery,
|
createGallery,
|
||||||
createTag,
|
createTag,
|
||||||
|
deleteArtworkRendition,
|
||||||
|
deleteGrouping,
|
||||||
linkArtworkToGrouping,
|
linkArtworkToGrouping,
|
||||||
listArtworks,
|
listArtworks,
|
||||||
listMediaAssets,
|
listMediaAssets,
|
||||||
listMediaFoundationGroups,
|
listMediaFoundationGroups,
|
||||||
|
updateArtwork,
|
||||||
|
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 +36,30 @@ 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 readOptionalNonNegativeInt(formData: FormData, key: string): number | undefined {
|
||||||
|
const raw = readField(formData, key)
|
||||||
|
if (!raw) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const value = Number(raw)
|
||||||
|
return Number.isFinite(value) && value >= 0 ? Math.floor(value) : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
@@ -89,6 +117,15 @@ async function createArtworkAction(formData: FormData) {
|
|||||||
dimensions: readOptionalField(formData, "dimensions"),
|
dimensions: readOptionalField(formData, "dimensions"),
|
||||||
framing: readOptionalField(formData, "framing"),
|
framing: readOptionalField(formData, "framing"),
|
||||||
availability: readOptionalField(formData, "availability"),
|
availability: readOptionalField(formData, "availability"),
|
||||||
|
priceAmountCents: (() => {
|
||||||
|
const raw = readField(formData, "priceAmount")
|
||||||
|
return raw ? Math.round(Number(raw) * 100) : undefined
|
||||||
|
})(),
|
||||||
|
priceCurrency: (() => {
|
||||||
|
const raw = readField(formData, "priceCurrency").toUpperCase()
|
||||||
|
return raw.length === 3 ? raw : undefined
|
||||||
|
})(),
|
||||||
|
isPriceVisible: readBooleanField(formData, "isPriceVisible"),
|
||||||
year: (() => {
|
year: (() => {
|
||||||
const raw = readField(formData, "year")
|
const raw = readField(formData, "year")
|
||||||
return raw ? Number(raw) : undefined
|
return raw ? Number(raw) : undefined
|
||||||
@@ -102,6 +139,41 @@ async function createArtworkAction(formData: FormData) {
|
|||||||
redirectWithState({ notice: "Artwork created." })
|
redirectWithState({ notice: "Artwork created." })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateArtworkAction(formData: FormData) {
|
||||||
|
"use server"
|
||||||
|
|
||||||
|
await requireWritePermission()
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateArtwork({
|
||||||
|
id: readField(formData, "artworkId"),
|
||||||
|
medium: readOptionalNullableField(formData, "medium"),
|
||||||
|
dimensions: readOptionalNullableField(formData, "dimensions"),
|
||||||
|
year: (() => {
|
||||||
|
const raw = readField(formData, "year")
|
||||||
|
return raw ? Number(raw) : null
|
||||||
|
})(),
|
||||||
|
framing: readOptionalNullableField(formData, "framing"),
|
||||||
|
availability: readOptionalNullableField(formData, "availability"),
|
||||||
|
priceAmountCents: (() => {
|
||||||
|
const value = readOptionalNonNegativeInt(formData, "priceAmountCents")
|
||||||
|
return value ?? null
|
||||||
|
})(),
|
||||||
|
priceCurrency: (() => {
|
||||||
|
const raw = readField(formData, "priceCurrency").toUpperCase()
|
||||||
|
return raw.length === 3 ? raw : null
|
||||||
|
})(),
|
||||||
|
isPriceVisible: readBooleanField(formData, "isPriceVisible"),
|
||||||
|
isPublished: readBooleanField(formData, "isPublished"),
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
redirectWithState({ error: "Failed to update artwork refinement fields." })
|
||||||
|
}
|
||||||
|
|
||||||
|
revalidatePath("/portfolio")
|
||||||
|
redirectWithState({ notice: "Artwork refinement updated." })
|
||||||
|
}
|
||||||
|
|
||||||
async function createGroupAction(formData: FormData) {
|
async function createGroupAction(formData: FormData) {
|
||||||
"use server"
|
"use server"
|
||||||
|
|
||||||
@@ -117,23 +189,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 +225,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"
|
||||||
|
|
||||||
@@ -195,6 +317,21 @@ async function attachRenditionAction(formData: FormData) {
|
|||||||
redirectWithState({ notice: "Rendition attached." })
|
redirectWithState({ notice: "Rendition attached." })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteRenditionAction(formData: FormData) {
|
||||||
|
"use server"
|
||||||
|
|
||||||
|
await requireWritePermission()
|
||||||
|
|
||||||
|
try {
|
||||||
|
await deleteArtworkRendition(readField(formData, "renditionId"))
|
||||||
|
} catch {
|
||||||
|
redirectWithState({ error: "Failed to delete rendition." })
|
||||||
|
}
|
||||||
|
|
||||||
|
revalidatePath("/portfolio")
|
||||||
|
redirectWithState({ notice: "Rendition deleted." })
|
||||||
|
}
|
||||||
|
|
||||||
export default async function PortfolioPage({
|
export default async function PortfolioPage({
|
||||||
searchParams,
|
searchParams,
|
||||||
}: {
|
}: {
|
||||||
@@ -290,6 +427,26 @@ export default async function PortfolioPage({
|
|||||||
placeholder="Availability"
|
placeholder="Availability"
|
||||||
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
className="w-full rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
/>
|
/>
|
||||||
|
<div className="grid gap-3 md:grid-cols-3">
|
||||||
|
<input
|
||||||
|
name="priceAmount"
|
||||||
|
type="number"
|
||||||
|
step="0.01"
|
||||||
|
min={0}
|
||||||
|
placeholder="Price amount (e.g. 199.99)"
|
||||||
|
className="rounded border border-neutral-300 px-3 py-2 text-sm"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
name="priceCurrency"
|
||||||
|
maxLength={3}
|
||||||
|
placeholder="Currency (USD)"
|
||||||
|
className="rounded border border-neutral-300 px-3 py-2 text-sm uppercase"
|
||||||
|
/>
|
||||||
|
<label className="flex items-center gap-2 rounded border border-neutral-300 px-3 py-2 text-sm">
|
||||||
|
<input type="checkbox" name="isPriceVisible" />
|
||||||
|
Price visible
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<Button type="submit">Create artwork</Button>
|
<Button type="submit">Create artwork</Button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
@@ -297,7 +454,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 +476,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 +499,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">
|
||||||
@@ -405,6 +657,7 @@ export default async function PortfolioPage({
|
|||||||
<option value="thumbnail">thumbnail</option>
|
<option value="thumbnail">thumbnail</option>
|
||||||
<option value="card">card</option>
|
<option value="card">card</option>
|
||||||
<option value="full">full</option>
|
<option value="full">full</option>
|
||||||
|
<option value="retina">retina</option>
|
||||||
<option value="custom">custom</option>
|
<option value="custom">custom</option>
|
||||||
</select>
|
</select>
|
||||||
<input
|
<input
|
||||||
@@ -447,14 +700,16 @@ export default async function PortfolioPage({
|
|||||||
<th className="py-2 pr-4">Title</th>
|
<th className="py-2 pr-4">Title</th>
|
||||||
<th className="py-2 pr-4">Slug</th>
|
<th className="py-2 pr-4">Slug</th>
|
||||||
<th className="py-2 pr-4">Published</th>
|
<th className="py-2 pr-4">Published</th>
|
||||||
|
<th className="py-2 pr-4">Refinement</th>
|
||||||
<th className="py-2 pr-4">Renditions</th>
|
<th className="py-2 pr-4">Renditions</th>
|
||||||
<th className="py-2 pr-4">Groups</th>
|
<th className="py-2 pr-4">Groups</th>
|
||||||
|
<th className="py-2 pr-4">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{artworks.length === 0 ? (
|
{artworks.length === 0 ? (
|
||||||
<tr>
|
<tr>
|
||||||
<td className="py-3 text-neutral-500" colSpan={5}>
|
<td className="py-3 text-neutral-500" colSpan={7}>
|
||||||
No artworks yet. Add creation flows after media upload pipeline lands.
|
No artworks yet. Add creation flows after media upload pipeline lands.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -464,11 +719,135 @@ export default async function PortfolioPage({
|
|||||||
<td className="py-3 pr-4">{artwork.title}</td>
|
<td className="py-3 pr-4">{artwork.title}</td>
|
||||||
<td className="py-3 pr-4 font-mono text-xs">{artwork.slug}</td>
|
<td className="py-3 pr-4 font-mono text-xs">{artwork.slug}</td>
|
||||||
<td className="py-3 pr-4">{artwork.isPublished ? "yes" : "no"}</td>
|
<td className="py-3 pr-4">{artwork.isPublished ? "yes" : "no"}</td>
|
||||||
<td className="py-3 pr-4">{artwork.renditions.length}</td>
|
<td className="py-3 pr-4 text-xs text-neutral-600">
|
||||||
|
{artwork.medium ? `medium: ${artwork.medium}` : "medium: -"}
|
||||||
|
<br />
|
||||||
|
{artwork.dimensions ? `dimensions: ${artwork.dimensions}` : "dimensions: -"}
|
||||||
|
<br />
|
||||||
|
{artwork.year ? `year: ${artwork.year}` : "year: -"}
|
||||||
|
<br />
|
||||||
|
{artwork.framing ? `framing: ${artwork.framing}` : "framing: -"}
|
||||||
|
<br />
|
||||||
|
{artwork.availability
|
||||||
|
? `availability: ${artwork.availability}`
|
||||||
|
: "availability: -"}
|
||||||
|
<br />
|
||||||
|
{artwork.priceAmountCents && artwork.priceCurrency
|
||||||
|
? `price: ${(artwork.priceAmountCents / 100).toFixed(2)} ${artwork.priceCurrency} (${artwork.isPriceVisible ? "visible" : "hidden"})`
|
||||||
|
: "price: -"}
|
||||||
|
</td>
|
||||||
|
<td className="py-3 pr-4">
|
||||||
|
<div className="space-y-1">
|
||||||
|
{artwork.renditions.length === 0 ? (
|
||||||
|
<span className="text-xs text-neutral-500">0</span>
|
||||||
|
) : (
|
||||||
|
artwork.renditions.map((rendition) => (
|
||||||
|
<form
|
||||||
|
key={rendition.id}
|
||||||
|
action={deleteRenditionAction}
|
||||||
|
className="flex items-center gap-2 text-xs"
|
||||||
|
>
|
||||||
|
<input type="hidden" name="renditionId" value={rendition.id} />
|
||||||
|
<span className="rounded bg-neutral-100 px-2 py-1 font-mono">
|
||||||
|
{rendition.slot}
|
||||||
|
</span>
|
||||||
|
<span className="text-neutral-500">
|
||||||
|
{rendition.width ?? "-"}x{rendition.height ?? "-"}
|
||||||
|
</span>
|
||||||
|
{rendition.isPrimary ? (
|
||||||
|
<span className="rounded bg-emerald-100 px-2 py-1 text-emerald-700">
|
||||||
|
primary
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="rounded border border-red-300 px-2 py-1 text-red-700 hover:bg-red-50"
|
||||||
|
>
|
||||||
|
delete
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td className="py-3 pr-4 text-neutral-600">
|
<td className="py-3 pr-4 text-neutral-600">
|
||||||
g:{artwork.galleryLinks.length} a:{artwork.albumLinks.length} c:
|
g:{artwork.galleryLinks.length} a:{artwork.albumLinks.length} c:
|
||||||
{artwork.categoryLinks.length} t:{artwork.tagLinks.length}
|
{artwork.categoryLinks.length} t:{artwork.tagLinks.length}
|
||||||
</td>
|
</td>
|
||||||
|
<td className="py-3 pr-4">
|
||||||
|
<form action={updateArtworkAction} className="grid min-w-80 gap-2">
|
||||||
|
<input type="hidden" name="artworkId" value={artwork.id} />
|
||||||
|
<input
|
||||||
|
name="medium"
|
||||||
|
defaultValue={artwork.medium ?? ""}
|
||||||
|
placeholder="Medium"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-xs"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
name="dimensions"
|
||||||
|
defaultValue={artwork.dimensions ?? ""}
|
||||||
|
placeholder="Dimensions"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-xs"
|
||||||
|
/>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<input
|
||||||
|
name="year"
|
||||||
|
type="number"
|
||||||
|
defaultValue={artwork.year ?? ""}
|
||||||
|
placeholder="Year"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-xs"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
name="framing"
|
||||||
|
defaultValue={artwork.framing ?? ""}
|
||||||
|
placeholder="Framing"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
name="availability"
|
||||||
|
defaultValue={artwork.availability ?? ""}
|
||||||
|
placeholder="Availability"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-xs"
|
||||||
|
/>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<input
|
||||||
|
name="priceAmountCents"
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
defaultValue={artwork.priceAmountCents ?? ""}
|
||||||
|
placeholder="Price cents"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-xs"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
name="priceCurrency"
|
||||||
|
maxLength={3}
|
||||||
|
defaultValue={artwork.priceCurrency ?? ""}
|
||||||
|
placeholder="USD"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-xs uppercase"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-3 text-xs">
|
||||||
|
<label className="inline-flex items-center gap-1">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="isPriceVisible"
|
||||||
|
defaultChecked={artwork.isPriceVisible}
|
||||||
|
/>
|
||||||
|
price visible
|
||||||
|
</label>
|
||||||
|
<label className="inline-flex items-center gap-1">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="isPublished"
|
||||||
|
defaultChecked={artwork.isPublished}
|
||||||
|
/>
|
||||||
|
published
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<Button type="submit">Save</Button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -43,6 +43,25 @@ function updateBlock(blocks: PageBlocks, blockId: string, next: Partial<PageBloc
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function moveBlock(blocks: PageBlocks, blockId: string, direction: "up" | "down"): PageBlocks {
|
||||||
|
const index = blocks.findIndex((entry) => entry.id === blockId)
|
||||||
|
|
||||||
|
if (index < 0) {
|
||||||
|
return blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextIndex = direction === "up" ? index - 1 : index + 1
|
||||||
|
if (nextIndex < 0 || nextIndex >= blocks.length) {
|
||||||
|
return blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
const next = [...blocks]
|
||||||
|
const current = next[index]
|
||||||
|
next[index] = next[nextIndex]
|
||||||
|
next[nextIndex] = current
|
||||||
|
return next
|
||||||
|
}
|
||||||
|
|
||||||
export function PageBlockEditor({
|
export function PageBlockEditor({
|
||||||
name,
|
name,
|
||||||
initialContent,
|
initialContent,
|
||||||
@@ -156,6 +175,21 @@ export function PageBlockEditor({
|
|||||||
<span>
|
<span>
|
||||||
#{index + 1} {block.type}
|
#{index + 1} {block.type}
|
||||||
</span>
|
</span>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1"
|
||||||
|
onClick={() => setBlocks((prev) => moveBlock(prev, block.id, "up"))}
|
||||||
|
>
|
||||||
|
Up
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1"
|
||||||
|
onClick={() => setBlocks((prev) => moveBlock(prev, block.id, "down"))}
|
||||||
|
>
|
||||||
|
Down
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="rounded border px-2 py-1"
|
className="rounded border px-2 py-1"
|
||||||
@@ -164,6 +198,7 @@ export function PageBlockEditor({
|
|||||||
Remove
|
Remove
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{block.type === "hero" ? (
|
{block.type === "hero" ? (
|
||||||
<div className="grid gap-2 md:grid-cols-2">
|
<div className="grid gap-2 md:grid-cols-2">
|
||||||
@@ -187,6 +222,26 @@ export function PageBlockEditor({
|
|||||||
placeholder="Subheading"
|
placeholder="Subheading"
|
||||||
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
<input
|
||||||
|
value={block.ctaLabel ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { ctaLabel: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="CTA label"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
value={block.ctaHref ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { ctaHref: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="CTA href"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
@@ -203,6 +258,17 @@ export function PageBlockEditor({
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{block.type === "gallery" ? (
|
{block.type === "gallery" ? (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<input
|
||||||
|
value={block.title ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { title: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Gallery title"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
rows={3}
|
rows={3}
|
||||||
value={block.imageIds.join(",")}
|
value={block.imageIds.join(",")}
|
||||||
@@ -219,6 +285,7 @@ export function PageBlockEditor({
|
|||||||
placeholder="Media asset IDs (comma separated UUIDs)"
|
placeholder="Media asset IDs (comma separated UUIDs)"
|
||||||
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{block.type === "cta" ? (
|
{block.type === "cta" ? (
|
||||||
@@ -239,21 +306,71 @@ export function PageBlockEditor({
|
|||||||
placeholder="Link href"
|
placeholder="Link href"
|
||||||
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
<select
|
||||||
|
value={block.variant}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, {
|
||||||
|
variant: event.target.value as "primary" | "secondary",
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
>
|
||||||
|
<option value="primary">Primary</option>
|
||||||
|
<option value="secondary">Secondary</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{block.type === "form" ? (
|
{block.type === "form" ? (
|
||||||
|
<div className="space-y-2">
|
||||||
<input
|
<input
|
||||||
value={block.formKey}
|
value={block.formKey}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setBlocks((prev) => updateBlock(prev, block.id, { formKey: event.target.value }))
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { formKey: event.target.value }),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
placeholder="Form key (e.g. contact, commission)"
|
placeholder="Form key (e.g. contact, commission)"
|
||||||
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
<input
|
||||||
|
value={block.title ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { title: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Form title"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
<textarea
|
||||||
|
rows={2}
|
||||||
|
value={block.description ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { description: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Form description"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{block.type === "price_cards" ? (
|
{block.type === "price_cards" ? (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<input
|
||||||
|
value={block.title ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { title: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Price card section title"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
rows={4}
|
rows={4}
|
||||||
value={block.cards
|
value={block.cards
|
||||||
@@ -283,6 +400,7 @@ export function PageBlockEditor({
|
|||||||
placeholder="One card per line: Name|Price|Description"
|
placeholder="One card per line: Name|Price|Description"
|
||||||
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</article>
|
</article>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -17,6 +17,17 @@ function formatLabelList(values: string[]) {
|
|||||||
return values.join(", ")
|
return values.join(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatArtworkPrice(priceAmountCents: number | null, priceCurrency: string | null) {
|
||||||
|
if (!priceAmountCents || !priceCurrency) {
|
||||||
|
return "-"
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Intl.NumberFormat("en-US", {
|
||||||
|
style: "currency",
|
||||||
|
currency: priceCurrency,
|
||||||
|
}).format(priceAmountCents / 100)
|
||||||
|
}
|
||||||
|
|
||||||
export default async function PublicArtworkPage({ params }: PublicArtworkPageProps) {
|
export default async function PublicArtworkPage({ params }: PublicArtworkPageProps) {
|
||||||
const [{ slug }, t] = await Promise.all([params, getTranslations("Portfolio")])
|
const [{ slug }, t] = await Promise.all([params, getTranslations("Portfolio")])
|
||||||
const artwork = await getPublishedArtworkBySlug(slug)
|
const artwork = await getPublishedArtworkBySlug(slug)
|
||||||
@@ -78,6 +89,12 @@ export default async function PublicArtworkPage({ params }: PublicArtworkPagePro
|
|||||||
<p>
|
<p>
|
||||||
<strong>{t("fields.availability")}:</strong> {artwork.availability || "-"}
|
<strong>{t("fields.availability")}:</strong> {artwork.availability || "-"}
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>{t("fields.price")}:</strong>{" "}
|
||||||
|
{artwork.isPriceVisible
|
||||||
|
? formatArtworkPrice(artwork.priceAmountCents, artwork.priceCurrency)
|
||||||
|
: "-"}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-2 text-sm">
|
<div className="space-y-2 text-sm">
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ type PublicPageViewProps = {
|
|||||||
page: PageEntity
|
page: PageEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveFormLink(formKey: string): { href: string; label: string } {
|
||||||
|
const normalized = formKey.trim().toLowerCase()
|
||||||
|
|
||||||
|
if (normalized === "commission" || normalized === "commissions") {
|
||||||
|
return { href: "/commissions", label: "Open commission form" }
|
||||||
|
}
|
||||||
|
|
||||||
|
return { href: `/#form-${normalized || "contact"}`, label: "Open contact form" }
|
||||||
|
}
|
||||||
|
|
||||||
export function PublicPageView({ page }: PublicPageViewProps) {
|
export function PublicPageView({ page }: PublicPageViewProps) {
|
||||||
const blocks = (() => {
|
const blocks = (() => {
|
||||||
try {
|
try {
|
||||||
@@ -106,6 +116,7 @@ export function PublicPageView({ page }: PublicPageViewProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (block.type === "form") {
|
if (block.type === "form") {
|
||||||
|
const formLink = resolveFormLink(block.formKey)
|
||||||
return (
|
return (
|
||||||
<section key={block.id} className="space-y-2 rounded border border-neutral-200 p-4">
|
<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>
|
<h3 className="text-lg font-medium">{block.title || "Form block"}</h3>
|
||||||
@@ -113,6 +124,12 @@ export function PublicPageView({ page }: PublicPageViewProps) {
|
|||||||
{block.description || "Form integration pending."}
|
{block.description || "Form integration pending."}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-neutral-500">formKey: {block.formKey}</p>
|
<p className="text-xs text-neutral-500">formKey: {block.formKey}</p>
|
||||||
|
<a
|
||||||
|
href={formLink.href}
|
||||||
|
className="inline-flex rounded border border-neutral-300 px-3 py-1.5 text-sm"
|
||||||
|
>
|
||||||
|
{formLink.label}
|
||||||
|
</a>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
"dimensions": "Abmessungen",
|
"dimensions": "Abmessungen",
|
||||||
"year": "Jahr",
|
"year": "Jahr",
|
||||||
"availability": "Verfügbarkeit",
|
"availability": "Verfügbarkeit",
|
||||||
|
"price": "Preis",
|
||||||
"galleries": "Galerien",
|
"galleries": "Galerien",
|
||||||
"albums": "Alben",
|
"albums": "Alben",
|
||||||
"categories": "Kategorien",
|
"categories": "Kategorien",
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
"dimensions": "Dimensions",
|
"dimensions": "Dimensions",
|
||||||
"year": "Year",
|
"year": "Year",
|
||||||
"availability": "Availability",
|
"availability": "Availability",
|
||||||
|
"price": "Price",
|
||||||
"galleries": "Galleries",
|
"galleries": "Galleries",
|
||||||
"albums": "Albums",
|
"albums": "Albums",
|
||||||
"categories": "Categories",
|
"categories": "Categories",
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
"dimensions": "Dimensiones",
|
"dimensions": "Dimensiones",
|
||||||
"year": "Año",
|
"year": "Año",
|
||||||
"availability": "Disponibilidad",
|
"availability": "Disponibilidad",
|
||||||
|
"price": "Precio",
|
||||||
"galleries": "Galerías",
|
"galleries": "Galerías",
|
||||||
"albums": "Álbumes",
|
"albums": "Álbumes",
|
||||||
"categories": "Categorías",
|
"categories": "Categorías",
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
"dimensions": "Dimensions",
|
"dimensions": "Dimensions",
|
||||||
"year": "Année",
|
"year": "Année",
|
||||||
"availability": "Disponibilité",
|
"availability": "Disponibilité",
|
||||||
|
"price": "Prix",
|
||||||
"galleries": "Galeries",
|
"galleries": "Galeries",
|
||||||
"albums": "Albums",
|
"albums": "Albums",
|
||||||
"categories": "Catégories",
|
"categories": "Catégories",
|
||||||
|
|||||||
@@ -9,7 +9,57 @@ export const mediaAssetTypeSchema = z.enum([
|
|||||||
"generic",
|
"generic",
|
||||||
])
|
])
|
||||||
|
|
||||||
export const artworkRenditionSlotSchema = z.enum(["thumbnail", "card", "full", "custom"])
|
export type MediaUploadRule = {
|
||||||
|
maxBytes: number
|
||||||
|
allowedMimePrefix?: string
|
||||||
|
allowedMimeExact?: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const mediaUploadRulesByType: Record<MediaAssetType, MediaUploadRule> = {
|
||||||
|
artwork: {
|
||||||
|
maxBytes: 40 * 1024 * 1024,
|
||||||
|
allowedMimePrefix: "image/",
|
||||||
|
},
|
||||||
|
banner: {
|
||||||
|
maxBytes: 20 * 1024 * 1024,
|
||||||
|
allowedMimePrefix: "image/",
|
||||||
|
},
|
||||||
|
promotion: {
|
||||||
|
maxBytes: 20 * 1024 * 1024,
|
||||||
|
allowedMimePrefix: "image/",
|
||||||
|
},
|
||||||
|
video: {
|
||||||
|
maxBytes: 250 * 1024 * 1024,
|
||||||
|
allowedMimePrefix: "video/",
|
||||||
|
},
|
||||||
|
gif: {
|
||||||
|
maxBytes: 40 * 1024 * 1024,
|
||||||
|
allowedMimeExact: ["image/gif"],
|
||||||
|
},
|
||||||
|
generic: {
|
||||||
|
maxBytes: 50 * 1024 * 1024,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isMimeAllowedForMediaType(type: MediaAssetType, mimeType: string): boolean {
|
||||||
|
const rule = mediaUploadRulesByType[type]
|
||||||
|
|
||||||
|
if (rule.allowedMimeExact?.includes(mimeType)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rule.allowedMimePrefix) {
|
||||||
|
return mimeType.startsWith(rule.allowedMimePrefix)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMediaUploadMaxBytes(type: MediaAssetType): number {
|
||||||
|
return mediaUploadRulesByType[type].maxBytes
|
||||||
|
}
|
||||||
|
|
||||||
|
export const artworkRenditionSlotSchema = z.enum(["thumbnail", "card", "full", "retina", "custom"])
|
||||||
|
|
||||||
export const createMediaAssetInputSchema = z.object({
|
export const createMediaAssetInputSchema = z.object({
|
||||||
id: z.string().uuid().optional(),
|
id: z.string().uuid().optional(),
|
||||||
@@ -65,6 +115,25 @@ export const createArtworkInputSchema = z.object({
|
|||||||
year: z.number().int().min(1000).max(9999).optional(),
|
year: z.number().int().min(1000).max(9999).optional(),
|
||||||
framing: z.string().max(180).optional(),
|
framing: z.string().max(180).optional(),
|
||||||
availability: z.string().max(180).optional(),
|
availability: z.string().max(180).optional(),
|
||||||
|
priceAmountCents: z.number().int().min(0).optional(),
|
||||||
|
priceCurrency: z.string().min(3).max(3).optional(),
|
||||||
|
isPriceVisible: z.boolean().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const updateArtworkInputSchema = z.object({
|
||||||
|
id: z.string().uuid(),
|
||||||
|
title: z.string().min(1).max(180).optional(),
|
||||||
|
slug: z.string().min(1).max(180).optional(),
|
||||||
|
description: z.string().max(5000).nullable().optional(),
|
||||||
|
medium: z.string().max(180).nullable().optional(),
|
||||||
|
dimensions: z.string().max(180).nullable().optional(),
|
||||||
|
year: z.number().int().min(1000).max(9999).nullable().optional(),
|
||||||
|
framing: z.string().max(180).nullable().optional(),
|
||||||
|
availability: z.string().max(180).nullable().optional(),
|
||||||
|
priceAmountCents: z.number().int().min(0).nullable().optional(),
|
||||||
|
priceCurrency: z.string().min(3).max(3).nullable().optional(),
|
||||||
|
isPriceVisible: z.boolean().optional(),
|
||||||
|
isPublished: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const createGroupingInputSchema = z.object({
|
export const createGroupingInputSchema = z.object({
|
||||||
@@ -75,6 +144,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"]),
|
||||||
@@ -95,6 +179,9 @@ export type ArtworkRenditionSlot = z.infer<typeof artworkRenditionSlotSchema>
|
|||||||
export type CreateMediaAssetInput = z.infer<typeof createMediaAssetInputSchema>
|
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 UpdateArtworkInput = z.infer<typeof updateArtworkInputSchema>
|
||||||
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>
|
||||||
|
|||||||
@@ -133,6 +133,14 @@ export const createNavigationMenuInputSchema = z.object({
|
|||||||
isVisible: z.boolean().default(true),
|
isVisible: z.boolean().default(true),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const updateNavigationMenuInputSchema = z.object({
|
||||||
|
id: z.string().uuid(),
|
||||||
|
name: z.string().min(1).max(180).optional(),
|
||||||
|
slug: z.string().min(1).max(180).optional(),
|
||||||
|
location: z.string().min(1).max(80).optional(),
|
||||||
|
isVisible: z.boolean().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
export const createNavigationItemInputSchema = z.object({
|
export const createNavigationItemInputSchema = z.object({
|
||||||
menuId: z.string().uuid(),
|
menuId: z.string().uuid(),
|
||||||
label: z.string().min(1).max(180),
|
label: z.string().min(1).max(180),
|
||||||
@@ -157,6 +165,7 @@ export type CreatePageInput = z.infer<typeof createPageInputSchema>
|
|||||||
export type UpdatePageInput = z.infer<typeof updatePageInputSchema>
|
export type UpdatePageInput = z.infer<typeof updatePageInputSchema>
|
||||||
export type UpsertPageTranslationInput = z.infer<typeof upsertPageTranslationInputSchema>
|
export type UpsertPageTranslationInput = z.infer<typeof upsertPageTranslationInputSchema>
|
||||||
export type CreateNavigationMenuInput = z.infer<typeof createNavigationMenuInputSchema>
|
export type CreateNavigationMenuInput = z.infer<typeof createNavigationMenuInputSchema>
|
||||||
|
export type UpdateNavigationMenuInput = z.infer<typeof updateNavigationMenuInputSchema>
|
||||||
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 PageBlock = z.infer<typeof pageBlockSchema>
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE "Artwork"
|
||||||
|
ADD COLUMN "priceAmountCents" INTEGER,
|
||||||
|
ADD COLUMN "priceCurrency" TEXT,
|
||||||
|
ADD COLUMN "isPriceVisible" BOOLEAN NOT NULL DEFAULT false;
|
||||||
@@ -153,6 +153,9 @@ model Artwork {
|
|||||||
year Int?
|
year Int?
|
||||||
framing String?
|
framing String?
|
||||||
availability String?
|
availability String?
|
||||||
|
priceAmountCents Int?
|
||||||
|
priceCurrency String?
|
||||||
|
isPriceVisible Boolean @default(false)
|
||||||
isPublished Boolean @default(false)
|
isPublished Boolean @default(false)
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
@@ -222,6 +225,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,8 @@ export {
|
|||||||
createGallery,
|
createGallery,
|
||||||
createMediaAsset,
|
createMediaAsset,
|
||||||
createTag,
|
createTag,
|
||||||
|
deleteArtworkRendition,
|
||||||
|
deleteGrouping,
|
||||||
deleteMediaAsset,
|
deleteMediaAsset,
|
||||||
getMediaAssetById,
|
getMediaAssetById,
|
||||||
getMediaFoundationSummary,
|
getMediaFoundationSummary,
|
||||||
@@ -34,6 +36,8 @@ export {
|
|||||||
listMediaFoundationGroups,
|
listMediaFoundationGroups,
|
||||||
listPublishedArtworks,
|
listPublishedArtworks,
|
||||||
listPublishedPortfolioGroups,
|
listPublishedPortfolioGroups,
|
||||||
|
updateArtwork,
|
||||||
|
updateGrouping,
|
||||||
updateMediaAsset,
|
updateMediaAsset,
|
||||||
} from "./media-foundation"
|
} from "./media-foundation"
|
||||||
export type { PublicNavigationItem } from "./pages-navigation"
|
export type { PublicNavigationItem } from "./pages-navigation"
|
||||||
@@ -42,6 +46,7 @@ export {
|
|||||||
createNavigationMenu,
|
createNavigationMenu,
|
||||||
createPage,
|
createPage,
|
||||||
deleteNavigationItem,
|
deleteNavigationItem,
|
||||||
|
deleteNavigationMenu,
|
||||||
deletePage,
|
deletePage,
|
||||||
getPageById,
|
getPageById,
|
||||||
getPublishedPageBySlug,
|
getPublishedPageBySlug,
|
||||||
@@ -52,6 +57,7 @@ export {
|
|||||||
listPublicNavigation,
|
listPublicNavigation,
|
||||||
listPublishedPageSlugs,
|
listPublishedPageSlugs,
|
||||||
updateNavigationItem,
|
updateNavigationItem,
|
||||||
|
updateNavigationMenu,
|
||||||
updatePage,
|
updatePage,
|
||||||
upsertNavigationItemTranslation,
|
upsertNavigationItemTranslation,
|
||||||
upsertPageTranslation,
|
upsertPageTranslation,
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import {
|
|||||||
createArtworkInputSchema,
|
createArtworkInputSchema,
|
||||||
createGroupingInputSchema,
|
createGroupingInputSchema,
|
||||||
createMediaAssetInputSchema,
|
createMediaAssetInputSchema,
|
||||||
|
deleteGroupingInputSchema,
|
||||||
linkArtworkGroupingInputSchema,
|
linkArtworkGroupingInputSchema,
|
||||||
|
updateArtworkInputSchema,
|
||||||
|
updateGroupingInputSchema,
|
||||||
updateMediaAssetInputSchema,
|
updateMediaAssetInputSchema,
|
||||||
} from "@cms/content"
|
} from "@cms/content"
|
||||||
|
|
||||||
@@ -30,10 +33,14 @@ export async function listArtworks(limit = 24) {
|
|||||||
take: limit,
|
take: limit,
|
||||||
include: {
|
include: {
|
||||||
renditions: {
|
renditions: {
|
||||||
|
orderBy: [{ isPrimary: "desc" }, { updatedAt: "desc" }],
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
slot: true,
|
slot: true,
|
||||||
mediaAssetId: true,
|
mediaAssetId: true,
|
||||||
|
width: true,
|
||||||
|
height: true,
|
||||||
|
isPrimary: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
galleryLinks: {
|
galleryLinks: {
|
||||||
@@ -96,7 +103,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" }],
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -146,6 +153,16 @@ export async function createArtwork(input: unknown) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateArtwork(input: unknown) {
|
||||||
|
const payload = updateArtworkInputSchema.parse(input)
|
||||||
|
const { id, ...data } = payload
|
||||||
|
|
||||||
|
return db.artwork.update({
|
||||||
|
where: { id },
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function createGallery(input: unknown) {
|
export async function createGallery(input: unknown) {
|
||||||
const payload = createGroupingInputSchema.parse(input)
|
const payload = createGroupingInputSchema.parse(input)
|
||||||
|
|
||||||
@@ -171,18 +188,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)
|
||||||
|
|
||||||
@@ -269,6 +344,12 @@ export async function attachArtworkRendition(input: unknown) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function deleteArtworkRendition(id: string) {
|
||||||
|
return db.artworkRendition.delete({
|
||||||
|
where: { id },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function getMediaFoundationSummary() {
|
export async function getMediaFoundationSummary() {
|
||||||
const [mediaAssets, artworks, galleries, albums, categories, tags] = await Promise.all([
|
const [mediaAssets, artworks, galleries, albums, categories, tags] = await Promise.all([
|
||||||
db.mediaAsset.count(),
|
db.mediaAsset.count(),
|
||||||
@@ -325,7 +406,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 +465,7 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput =
|
|||||||
some: {
|
some: {
|
||||||
tag: {
|
tag: {
|
||||||
slug: input.groupSlug,
|
slug: input.groupSlug,
|
||||||
|
isVisible: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -398,6 +483,7 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput =
|
|||||||
isPublished: true,
|
isPublished: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
orderBy: [{ isPrimary: "desc" }, { updatedAt: "desc" }],
|
||||||
include: {
|
include: {
|
||||||
mediaAsset: {
|
mediaAsset: {
|
||||||
select: {
|
select: {
|
||||||
@@ -472,6 +558,7 @@ export async function getPublishedArtworkBySlug(slug: string) {
|
|||||||
isPublished: true,
|
isPublished: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
orderBy: [{ isPrimary: "desc" }, { updatedAt: "desc" }],
|
||||||
include: {
|
include: {
|
||||||
mediaAsset: {
|
mediaAsset: {
|
||||||
select: {
|
select: {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
createNavigationMenuInputSchema,
|
createNavigationMenuInputSchema,
|
||||||
createPageInputSchema,
|
createPageInputSchema,
|
||||||
updateNavigationItemInputSchema,
|
updateNavigationItemInputSchema,
|
||||||
|
updateNavigationMenuInputSchema,
|
||||||
updatePageInputSchema,
|
updatePageInputSchema,
|
||||||
upsertPageTranslationInputSchema,
|
upsertPageTranslationInputSchema,
|
||||||
} from "@cms/content"
|
} from "@cms/content"
|
||||||
@@ -297,6 +298,22 @@ export async function createNavigationMenu(input: unknown) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function updateNavigationMenu(input: unknown) {
|
||||||
|
const payload = updateNavigationMenuInputSchema.parse(input)
|
||||||
|
const { id, ...data } = payload
|
||||||
|
|
||||||
|
return db.navigationMenu.update({
|
||||||
|
where: { id },
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteNavigationMenu(id: string) {
|
||||||
|
return db.navigationMenu.delete({
|
||||||
|
where: { id },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function createNavigationItem(input: unknown) {
|
export async function createNavigationItem(input: unknown) {
|
||||||
const payload = createNavigationItemInputSchema.parse(input)
|
const payload = createNavigationItemInputSchema.parse(input)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user