From a2bea6326e61752e7a8edf1dfb6cbfe1d8107b72 Mon Sep 17 00:00:00 2001 From: Citali Date: Thu, 12 Feb 2026 23:08:25 +0100 Subject: [PATCH] feat(web): complete portfolio public filter and sort integration --- TODO.md | 17 +-- apps/web/src/app/[locale]/portfolio/page.tsx | 123 ++++++++++++++++++- apps/web/src/messages/de.json | 9 +- apps/web/src/messages/en.json | 9 +- apps/web/src/messages/es.json | 9 +- apps/web/src/messages/fr.json | 9 +- packages/db/src/media-foundation.ts | 11 +- 7 files changed, 169 insertions(+), 18 deletions(-) diff --git a/TODO.md b/TODO.md index 9075732..df789b4 100644 --- a/TODO.md +++ b/TODO.md @@ -120,7 +120,7 @@ This file is the single source of truth for roadmap and delivery progress. commission request intake + admin CRUD + kanban + customer entity/linking - [x] [P1] `todo/mvp1-announcements-news`: announcement management/rendering + news/blog CRUD and public rendering -- [~] [P1] `todo/mvp1-public-rendering-integration`: +- [x] [P1] `todo/mvp1-public-rendering-integration`: public rendering for pages/navigation/media/portfolio/announcements and commissioning entrypoints - [~] [P1] `todo/mvp1-e2e-happy-paths`: end-to-end scenarios for page publish, media flow, announcement display, commission flow @@ -158,14 +158,14 @@ This file is the single source of truth for roadmap and delivery progress. ### Public App -- [~] [P1] Dynamic page rendering from CMS page entities -- [~] [P1] Navigation rendering from managed menu structure -- [~] [P1] Media entity rendering with enrichment data -- [~] [P1] Portfolio views (gallery/album/category/tag) for artworks with filter and sort controls -- [~] [P1] Rendition-aware media delivery (thumbnail/card/full) per template slot -- [~] [P1] Translation-ready content model for public entities (pages/news/navigation labels) +- [x] [P1] Dynamic page rendering from CMS page entities +- [x] [P1] Navigation rendering from managed menu structure +- [x] [P1] Media entity rendering with enrichment data +- [x] [P1] Portfolio views (gallery/album/category/tag) for artworks with filter and sort controls +- [x] [P1] Rendition-aware media delivery (thumbnail/card/full) per template slot +- [x] [P1] Translation-ready content model for public entities (pages/news/navigation labels) - [ ] [P2] Artwork views and listing filters -- [~] [P1] Commission request submission flow +- [x] [P1] Commission request submission flow - [x] [P1] Header banner render logic and fallbacks - [x] [P1] Announcement render slots (homepage + optional global/top banner position) @@ -370,6 +370,7 @@ This file is the single source of truth for roadmap and delivery progress. - [2026-02-12] Users management baseline completed: admin `/users` now supports managed user creation, role changes (`admin/editor/manager`), status changes (ban/unban), and protected/system guardrails for role-change/delete/ban actions. - [2026-02-12] Commissions management completed: admin kanban cards now include inline detail editing (assignee/customer/budget/due date/notes), linked-artwork references via `linkedArtworkIds`, and creation/edit flows use assignable users instead of raw ID entry. - [2026-02-12] Announcements/news completed: announcements now support locale audience targeting (`targetLocales`) with public locale-aware rendering, and homepage news list now uses locale-aware published posts only. +- [2026-02-12] Public rendering integration completed: portfolio now supports locale-aware tag filters and explicit sort controls, while db/service sorting and rendition selection align public listing/detail media delivery. - [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`. diff --git a/apps/web/src/app/[locale]/portfolio/page.tsx b/apps/web/src/app/[locale]/portfolio/page.tsx index 1baeffe..31f5046 100644 --- a/apps/web/src/app/[locale]/portfolio/page.tsx +++ b/apps/web/src/app/[locale]/portfolio/page.tsx @@ -44,6 +44,33 @@ function resolveGroupFilter(searchParams: SearchParamsInput) { return null } +function resolveSort(searchParams: SearchParamsInput): "latest" | "title_asc" | "title_desc" { + const sort = readFirstValue(searchParams.sort) + + if (sort === "title_asc" || sort === "title_desc") { + return sort + } + + return "latest" +} + +function buildPortfolioQuery( + filter: ReturnType, + sort: ReturnType, +) { + const query: Record = {} + + if (filter) { + query[filter.groupType] = filter.groupSlug + } + + if (sort !== "latest") { + query.sort = sort + } + + return query +} + function findPreviewAsset( renditions: Array<{ slot: string @@ -67,6 +94,7 @@ function findPreviewAsset( export default async function PortfolioPage({ searchParams }: PortfolioPageProps) { const [resolvedSearchParams, t] = await Promise.all([searchParams, getTranslations("Portfolio")]) const activeFilter = resolveGroupFilter(resolvedSearchParams) + const activeSort = resolveSort(resolvedSearchParams) const [groups, artworks] = await Promise.all([ listPublishedPortfolioGroups(), @@ -75,8 +103,11 @@ export default async function PortfolioPage({ searchParams }: PortfolioPageProps ? { groupType: activeFilter.groupType, groupSlug: activeFilter.groupSlug, + sort: activeSort, } - : undefined, + : { + sort: activeSort, + }, ), ]) @@ -91,7 +122,10 @@ export default async function PortfolioPage({ searchParams }: PortfolioPageProps
{t("filters.clear")} @@ -100,7 +134,16 @@ export default async function PortfolioPage({ searchParams }: PortfolioPageProps {groups.galleries.map((group) => ( {t("filters.gallery")}: {group.name} @@ -110,7 +153,16 @@ export default async function PortfolioPage({ searchParams }: PortfolioPageProps {groups.albums.map((group) => ( {t("filters.album")}: {group.name} @@ -120,12 +172,73 @@ export default async function PortfolioPage({ searchParams }: PortfolioPageProps {groups.categories.map((group) => ( {t("filters.category")}: {group.name} ))} + + {groups.tags.map((group) => ( + + {t("filters.tag")}: {group.name} + + ))} +
+ +
+ + {t("sort.label")}: + + + {t("sort.latest")} + + + {t("sort.titleAsc")} + + + {t("sort.titleDesc")} +
diff --git a/apps/web/src/messages/de.json b/apps/web/src/messages/de.json index 2cf4ad0..0d59c73 100644 --- a/apps/web/src/messages/de.json +++ b/apps/web/src/messages/de.json @@ -77,7 +77,14 @@ "clear": "Filter zurücksetzen", "gallery": "Galerie", "album": "Album", - "category": "Kategorie" + "category": "Kategorie", + "tag": "Tag" + }, + "sort": { + "label": "Sortierung", + "latest": "Neueste", + "titleAsc": "Titel A-Z", + "titleDesc": "Titel Z-A" }, "fields": { "medium": "Medium", diff --git a/apps/web/src/messages/en.json b/apps/web/src/messages/en.json index ed5eb9c..dcb98b6 100644 --- a/apps/web/src/messages/en.json +++ b/apps/web/src/messages/en.json @@ -77,7 +77,14 @@ "clear": "Clear filters", "gallery": "Gallery", "album": "Album", - "category": "Category" + "category": "Category", + "tag": "Tag" + }, + "sort": { + "label": "Sort", + "latest": "Latest", + "titleAsc": "Title A-Z", + "titleDesc": "Title Z-A" }, "fields": { "medium": "Medium", diff --git a/apps/web/src/messages/es.json b/apps/web/src/messages/es.json index 490aeb6..2c3e198 100644 --- a/apps/web/src/messages/es.json +++ b/apps/web/src/messages/es.json @@ -77,7 +77,14 @@ "clear": "Limpiar filtros", "gallery": "Galería", "album": "Álbum", - "category": "Categoría" + "category": "Categoría", + "tag": "Etiqueta" + }, + "sort": { + "label": "Orden", + "latest": "Más recientes", + "titleAsc": "Título A-Z", + "titleDesc": "Título Z-A" }, "fields": { "medium": "Técnica", diff --git a/apps/web/src/messages/fr.json b/apps/web/src/messages/fr.json index 225ba7e..03c5ff9 100644 --- a/apps/web/src/messages/fr.json +++ b/apps/web/src/messages/fr.json @@ -77,7 +77,14 @@ "clear": "Réinitialiser les filtres", "gallery": "Galerie", "album": "Album", - "category": "Catégorie" + "category": "Catégorie", + "tag": "Tag" + }, + "sort": { + "label": "Tri", + "latest": "Plus récents", + "titleAsc": "Titre A-Z", + "titleDesc": "Titre Z-A" }, "fields": { "medium": "Médium", diff --git a/packages/db/src/media-foundation.ts b/packages/db/src/media-foundation.ts index 3ae8575..790be0b 100644 --- a/packages/db/src/media-foundation.ts +++ b/packages/db/src/media-foundation.ts @@ -9,15 +9,18 @@ import { updateGroupingInputSchema, updateMediaAssetInputSchema, } from "@cms/content" +import type { Prisma } from "@prisma/client" import { db } from "./client" type PublicArtworkGroupType = "gallery" | "album" | "category" | "tag" +type PublicArtworkSort = "latest" | "title_asc" | "title_desc" type ListPublishedArtworksInput = { groupType?: PublicArtworkGroupType groupSlug?: string limit?: number + sort?: PublicArtworkSort } export async function listMediaAssets(limit = 24) { @@ -431,6 +434,12 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput = const where: Record = { isPublished: true, } + const orderBy: Prisma.ArtworkOrderByWithRelationInput[] = + input.sort === "title_asc" + ? [{ title: "asc" }, { updatedAt: "desc" }] + : input.sort === "title_desc" + ? [{ title: "desc" }, { updatedAt: "desc" }] + : [{ updatedAt: "desc" }] if (input.groupType && input.groupSlug) { if (input.groupType === "gallery") { @@ -474,7 +483,7 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput = return db.artwork.findMany({ where, - orderBy: [{ updatedAt: "desc" }], + orderBy, take, include: { renditions: {