Compare commits
3 Commits
todo/mvp1-
...
todo/mvp1-
| Author | SHA1 | Date | |
|---|---|---|---|
|
697b3ab5e7
|
|||
|
984511f166
|
|||
|
b9424c8a8b
|
9
TODO.md
9
TODO.md
@@ -140,9 +140,9 @@ 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] 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 enrichment metadata (alt text, copyright, author, source, tags, licensing, usage context)
|
||||
- [ ] [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] Media enrichment metadata (alt text, copyright, author, source, tags, licensing, usage context)
|
||||
- [x] [P1] Portfolio grouping primitives (galleries, albums, categories, tags) with ordering/visibility controls
|
||||
- [x] [P1] Artwork refinement fields (medium, dimensions, year, framing, availability, price visibility)
|
||||
- [ ] [P1] Artwork rendition management (thumbnail, card, full, retina/custom sizes)
|
||||
- [ ] [P1] Type-specific processing presets (artwork/banner/promo/video/gif) with validation rules
|
||||
- [ ] [P1] Users management (invite, roles, status)
|
||||
@@ -343,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] 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] 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] 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.
|
||||
@@ -360,6 +361,8 @@ 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] 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] 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] 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] 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)
|
||||
}
|
||||
|
||||
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 {
|
||||
const trimmed = fileName.trim()
|
||||
|
||||
@@ -178,6 +194,11 @@ export async function POST(request: Request): Promise<Response> {
|
||||
source: parseOptionalField(formData, "source"),
|
||||
copyright: parseOptionalField(formData, "copyright"),
|
||||
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),
|
||||
storageKey: stored.storageKey,
|
||||
mimeType: fileEntry.type || undefined,
|
||||
|
||||
@@ -50,6 +50,22 @@ function readNullableInt(formData: FormData, field: string): number | null {
|
||||
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[] {
|
||||
const raw = readInputString(formData, "tags")
|
||||
|
||||
@@ -127,6 +143,11 @@ export default async function MediaAssetEditorPage({ params, searchParams }: Pag
|
||||
source: readNullableString(formData, "source"),
|
||||
copyright: readNullableString(formData, "copyright"),
|
||||
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),
|
||||
mimeType: readNullableString(formData, "mimeType"),
|
||||
width: readNullableInt(formData, "width"),
|
||||
@@ -320,6 +341,56 @@ export default async function MediaAssetEditorPage({ params, searchParams }: Pag
|
||||
</label>
|
||||
</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">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-neutral-600">MIME type</span>
|
||||
|
||||
@@ -5,10 +5,13 @@ import {
|
||||
createCategory,
|
||||
createGallery,
|
||||
createTag,
|
||||
deleteGrouping,
|
||||
linkArtworkToGrouping,
|
||||
listArtworks,
|
||||
listMediaAssets,
|
||||
listMediaFoundationGroups,
|
||||
updateArtwork,
|
||||
updateGrouping,
|
||||
} from "@cms/db"
|
||||
import { Button } from "@cms/ui/button"
|
||||
import { revalidatePath } from "next/cache"
|
||||
@@ -32,6 +35,30 @@ function readOptionalField(formData: FormData, key: string): string | 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 {
|
||||
if (Array.isArray(value)) {
|
||||
return value[0] ?? null
|
||||
@@ -89,6 +116,15 @@ async function createArtworkAction(formData: FormData) {
|
||||
dimensions: readOptionalField(formData, "dimensions"),
|
||||
framing: readOptionalField(formData, "framing"),
|
||||
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: (() => {
|
||||
const raw = readField(formData, "year")
|
||||
return raw ? Number(raw) : undefined
|
||||
@@ -102,6 +138,41 @@ async function createArtworkAction(formData: FormData) {
|
||||
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) {
|
||||
"use server"
|
||||
|
||||
@@ -117,23 +188,32 @@ async function createGroupAction(formData: FormData) {
|
||||
name,
|
||||
slug,
|
||||
description: readOptionalField(formData, "description"),
|
||||
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||
isVisible: readBooleanField(formData, "isVisible"),
|
||||
})
|
||||
} else if (type === "album") {
|
||||
await createAlbum({
|
||||
name,
|
||||
slug,
|
||||
description: readOptionalField(formData, "description"),
|
||||
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||
isVisible: readBooleanField(formData, "isVisible"),
|
||||
})
|
||||
} else if (type === "category") {
|
||||
await createCategory({
|
||||
name,
|
||||
slug,
|
||||
description: readOptionalField(formData, "description"),
|
||||
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||
isVisible: readBooleanField(formData, "isVisible"),
|
||||
})
|
||||
} else {
|
||||
await createTag({
|
||||
name,
|
||||
slug,
|
||||
description: readOptionalField(formData, "description"),
|
||||
sortOrder: readNonNegativeInt(formData, "sortOrder"),
|
||||
isVisible: readBooleanField(formData, "isVisible"),
|
||||
})
|
||||
}
|
||||
} catch {
|
||||
@@ -144,6 +224,47 @@ async function createGroupAction(formData: FormData) {
|
||||
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) {
|
||||
"use server"
|
||||
|
||||
@@ -290,6 +411,26 @@ export default async function PortfolioPage({
|
||||
placeholder="Availability"
|
||||
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>
|
||||
</form>
|
||||
</section>
|
||||
@@ -297,7 +438,7 @@ export default async function PortfolioPage({
|
||||
<section className="rounded-xl border border-neutral-200 p-6">
|
||||
<h2 className="text-xl font-medium">Create Group Entity</h2>
|
||||
<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
|
||||
name="groupType"
|
||||
defaultValue="gallery"
|
||||
@@ -319,6 +460,18 @@ export default async function PortfolioPage({
|
||||
placeholder="Slug (optional)"
|
||||
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>
|
||||
<textarea
|
||||
name="description"
|
||||
@@ -330,6 +483,89 @@ export default async function PortfolioPage({
|
||||
</form>
|
||||
</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">
|
||||
<h2 className="text-xl font-medium">Link Artwork To Group</h2>
|
||||
<div className="mt-4 grid gap-4 lg:grid-cols-2">
|
||||
@@ -447,14 +683,16 @@ export default async function PortfolioPage({
|
||||
<th className="py-2 pr-4">Title</th>
|
||||
<th className="py-2 pr-4">Slug</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">Groups</th>
|
||||
<th className="py-2 pr-4">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{artworks.length === 0 ? (
|
||||
<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.
|
||||
</td>
|
||||
</tr>
|
||||
@@ -464,11 +702,102 @@ export default async function PortfolioPage({
|
||||
<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">{artwork.isPublished ? "yes" : "no"}</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">{artwork.renditions.length}</td>
|
||||
<td className="py-3 pr-4 text-neutral-600">
|
||||
g:{artwork.galleryLinks.length} a:{artwork.albumLinks.length} c:
|
||||
{artwork.categoryLinks.length} t:{artwork.tagLinks.length}
|
||||
</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>
|
||||
))
|
||||
)}
|
||||
|
||||
@@ -149,6 +149,52 @@ export function MediaUploadForm() {
|
||||
</label>
|
||||
</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">
|
||||
<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" />
|
||||
|
||||
@@ -17,6 +17,17 @@ function formatLabelList(values: string[]) {
|
||||
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) {
|
||||
const [{ slug }, t] = await Promise.all([params, getTranslations("Portfolio")])
|
||||
const artwork = await getPublishedArtworkBySlug(slug)
|
||||
@@ -25,6 +36,8 @@ export default async function PublicArtworkPage({ params }: PublicArtworkPagePro
|
||||
notFound()
|
||||
}
|
||||
|
||||
const primaryMedia = artwork.renditions[0]?.mediaAsset ?? null
|
||||
|
||||
return (
|
||||
<section className="mx-auto w-full max-w-5xl space-y-6 px-6 py-16">
|
||||
<header className="space-y-2">
|
||||
@@ -76,6 +89,12 @@ export default async function PublicArtworkPage({ params }: PublicArtworkPagePro
|
||||
<p>
|
||||
<strong>{t("fields.availability")}:</strong> {artwork.availability || "-"}
|
||||
</p>
|
||||
<p>
|
||||
<strong>{t("fields.price")}:</strong>{" "}
|
||||
{artwork.isPriceVisible
|
||||
? formatArtworkPrice(artwork.priceAmountCents, artwork.priceCurrency)
|
||||
: "-"}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-2 text-sm">
|
||||
<p>
|
||||
@@ -94,6 +113,22 @@ export default async function PublicArtworkPage({ params }: PublicArtworkPagePro
|
||||
<strong>{t("fields.tags")}:</strong>{" "}
|
||||
{formatLabelList(artwork.tagLinks.map((entry) => entry.tag.name))}
|
||||
</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>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -84,10 +84,16 @@
|
||||
"dimensions": "Abmessungen",
|
||||
"year": "Jahr",
|
||||
"availability": "Verfügbarkeit",
|
||||
"price": "Preis",
|
||||
"galleries": "Galerien",
|
||||
"albums": "Alben",
|
||||
"categories": "Kategorien",
|
||||
"tags": "Tags"
|
||||
"tags": "Tags",
|
||||
"licenseType": "Lizenztyp",
|
||||
"licenseUrl": "Lizenz-URL",
|
||||
"usageContext": "Nutzungskontext",
|
||||
"location": "Ort",
|
||||
"capturedAt": "Aufgenommen am"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,10 +84,16 @@
|
||||
"dimensions": "Dimensions",
|
||||
"year": "Year",
|
||||
"availability": "Availability",
|
||||
"price": "Price",
|
||||
"galleries": "Galleries",
|
||||
"albums": "Albums",
|
||||
"categories": "Categories",
|
||||
"tags": "Tags"
|
||||
"tags": "Tags",
|
||||
"licenseType": "License type",
|
||||
"licenseUrl": "License URL",
|
||||
"usageContext": "Usage context",
|
||||
"location": "Location",
|
||||
"capturedAt": "Captured at"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,10 +84,16 @@
|
||||
"dimensions": "Dimensiones",
|
||||
"year": "Año",
|
||||
"availability": "Disponibilidad",
|
||||
"price": "Precio",
|
||||
"galleries": "Galerías",
|
||||
"albums": "Álbumes",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,10 +84,16 @@
|
||||
"dimensions": "Dimensions",
|
||||
"year": "Année",
|
||||
"availability": "Disponibilité",
|
||||
"price": "Prix",
|
||||
"galleries": "Galeries",
|
||||
"albums": "Albums",
|
||||
"categories": "Catégories",
|
||||
"tags": "Tags"
|
||||
"tags": "Tags",
|
||||
"licenseType": "Type de licence",
|
||||
"licenseUrl": "URL de licence",
|
||||
"usageContext": "Contexte d'utilisation",
|
||||
"location": "Lieu",
|
||||
"capturedAt": "Capturé le"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,14 @@ describe("media schemas", () => {
|
||||
const parsed = createMediaAssetInputSchema.parse({
|
||||
type: "artwork",
|
||||
title: "Artwork",
|
||||
licenseType: "CC BY",
|
||||
usageContext: "homepage hero",
|
||||
capturedAt: new Date("2026-01-02T10:30:00.000Z"),
|
||||
tags: ["tag-a"],
|
||||
})
|
||||
|
||||
expect(parsed.type).toBe("artwork")
|
||||
expect(parsed.licenseType).toBe("CC BY")
|
||||
expect(parsed.tags).toEqual(["tag-a"])
|
||||
})
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@ export const createMediaAssetInputSchema = z.object({
|
||||
source: z.string().max(500).optional(),
|
||||
copyright: z.string().max(500).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([]),
|
||||
storageKey: z.string().max(500).optional(),
|
||||
mimeType: z.string().max(180).optional(),
|
||||
@@ -38,6 +43,11 @@ export const updateMediaAssetInputSchema = z.object({
|
||||
source: z.string().max(500).nullable().optional(),
|
||||
copyright: z.string().max(500).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(),
|
||||
mimeType: z.string().max(180).nullable().optional(),
|
||||
width: z.number().int().positive().nullable().optional(),
|
||||
@@ -55,6 +65,25 @@ export const createArtworkInputSchema = z.object({
|
||||
year: z.number().int().min(1000).max(9999).optional(),
|
||||
framing: 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({
|
||||
@@ -65,6 +94,21 @@ export const createGroupingInputSchema = z.object({
|
||||
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({
|
||||
artworkId: z.string().uuid(),
|
||||
groupType: z.enum(["gallery", "album", "category", "tag"]),
|
||||
@@ -85,6 +129,9 @@ export type ArtworkRenditionSlot = z.infer<typeof artworkRenditionSlotSchema>
|
||||
export type CreateMediaAssetInput = z.infer<typeof createMediaAssetInputSchema>
|
||||
export type UpdateMediaAssetInput = z.infer<typeof updateMediaAssetInputSchema>
|
||||
export type CreateArtworkInput = z.infer<typeof createArtworkInputSchema>
|
||||
export type UpdateArtworkInput = z.infer<typeof updateArtworkInputSchema>
|
||||
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 AttachArtworkRenditionInput = z.infer<typeof attachArtworkRenditionInputSchema>
|
||||
|
||||
@@ -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;
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE "Artwork"
|
||||
ADD COLUMN "priceAmountCents" INTEGER,
|
||||
ADD COLUMN "priceCurrency" TEXT,
|
||||
ADD COLUMN "isPriceVisible" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -123,6 +123,11 @@ model MediaAsset {
|
||||
source String?
|
||||
copyright String?
|
||||
author String?
|
||||
licenseType String?
|
||||
licenseUrl String?
|
||||
usageContext String?
|
||||
location String?
|
||||
capturedAt DateTime?
|
||||
tags String[]
|
||||
storageKey String? @unique
|
||||
mimeType String?
|
||||
@@ -148,6 +153,9 @@ model Artwork {
|
||||
year Int?
|
||||
framing String?
|
||||
availability String?
|
||||
priceAmountCents Int?
|
||||
priceCurrency String?
|
||||
isPriceVisible Boolean @default(false)
|
||||
isPublished Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -217,6 +225,9 @@ model Tag {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
slug String @unique
|
||||
description String?
|
||||
sortOrder Int @default(0)
|
||||
isVisible Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
artworkLinks ArtworkTag[]
|
||||
|
||||
@@ -24,6 +24,7 @@ export {
|
||||
createGallery,
|
||||
createMediaAsset,
|
||||
createTag,
|
||||
deleteGrouping,
|
||||
deleteMediaAsset,
|
||||
getMediaAssetById,
|
||||
getMediaFoundationSummary,
|
||||
@@ -34,6 +35,8 @@ export {
|
||||
listMediaFoundationGroups,
|
||||
listPublishedArtworks,
|
||||
listPublishedPortfolioGroups,
|
||||
updateArtwork,
|
||||
updateGrouping,
|
||||
updateMediaAsset,
|
||||
} from "./media-foundation"
|
||||
export type { PublicNavigationItem } from "./pages-navigation"
|
||||
|
||||
@@ -3,7 +3,10 @@ import {
|
||||
createArtworkInputSchema,
|
||||
createGroupingInputSchema,
|
||||
createMediaAssetInputSchema,
|
||||
deleteGroupingInputSchema,
|
||||
linkArtworkGroupingInputSchema,
|
||||
updateArtworkInputSchema,
|
||||
updateGroupingInputSchema,
|
||||
updateMediaAssetInputSchema,
|
||||
} from "@cms/content"
|
||||
|
||||
@@ -96,7 +99,7 @@ export async function listMediaFoundationGroups() {
|
||||
orderBy: [{ sortOrder: "asc" }, { name: "asc" }],
|
||||
}),
|
||||
db.tag.findMany({
|
||||
orderBy: { name: "asc" },
|
||||
orderBy: [{ sortOrder: "asc" }, { name: "asc" }],
|
||||
}),
|
||||
])
|
||||
|
||||
@@ -146,6 +149,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) {
|
||||
const payload = createGroupingInputSchema.parse(input)
|
||||
|
||||
@@ -171,18 +184,76 @@ export async function createCategory(input: unknown) {
|
||||
}
|
||||
|
||||
export async function createTag(input: unknown) {
|
||||
const payload = createGroupingInputSchema
|
||||
.pick({
|
||||
name: true,
|
||||
slug: true,
|
||||
})
|
||||
.parse(input)
|
||||
const payload = createGroupingInputSchema.parse(input)
|
||||
|
||||
return db.tag.create({
|
||||
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) {
|
||||
const payload = linkArtworkGroupingInputSchema.parse(input)
|
||||
|
||||
@@ -325,7 +396,10 @@ export async function listPublishedPortfolioGroups() {
|
||||
},
|
||||
}),
|
||||
db.tag.findMany({
|
||||
orderBy: [{ name: "asc" }],
|
||||
where: {
|
||||
isVisible: true,
|
||||
},
|
||||
orderBy: [{ sortOrder: "asc" }, { name: "asc" }],
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
@@ -381,6 +455,7 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput =
|
||||
some: {
|
||||
tag: {
|
||||
slug: input.groupSlug,
|
||||
isVisible: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -484,6 +559,11 @@ export async function getPublishedArtworkBySlug(slug: string) {
|
||||
source: true,
|
||||
author: true,
|
||||
copyright: true,
|
||||
licenseType: true,
|
||||
licenseUrl: true,
|
||||
usageContext: true,
|
||||
location: true,
|
||||
capturedAt: true,
|
||||
tags: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user