From 60c90357439352732cd85e16280c736f11ff2332 Mon Sep 17 00:00:00 2001 From: Citali Date: Thu, 12 Feb 2026 23:05:39 +0100 Subject: [PATCH] feat(announcements): add locale audience targeting and published-home news --- TODO.md | 11 ++-- apps/admin/src/app/announcements/page.tsx | 53 +++++++++++++++++++ apps/web/src/app/[locale]/layout.tsx | 2 +- apps/web/src/app/[locale]/page.tsx | 6 +-- .../src/components/public-announcements.tsx | 5 +- packages/content/src/announcements.ts | 3 ++ .../migration.sql | 2 + packages/db/prisma/schema.prisma | 1 + packages/db/src/announcements.test.ts | 7 ++- packages/db/src/announcements.ts | 15 ++++++ 10 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 packages/db/prisma/migrations/20260213014500_announcement_locale_targeting/migration.sql diff --git a/TODO.md b/TODO.md index a36f80f..9075732 100644 --- a/TODO.md +++ b/TODO.md @@ -118,7 +118,7 @@ This file is the single source of truth for roadmap and delivery progress. page CRUD, navigation tree, reusable page blocks (forms/price cards/gallery embeds) - [~] [P1] `todo/mvp1-commissions-customers`: commission request intake + admin CRUD + kanban + customer entity/linking -- [~] [P1] `todo/mvp1-announcements-news`: +- [x] [P1] `todo/mvp1-announcements-news`: announcement management/rendering + news/blog CRUD and public rendering - [~] [P1] `todo/mvp1-public-rendering-integration`: public rendering for pages/navigation/media/portfolio/announcements and commissioning entrypoints @@ -153,7 +153,7 @@ This file is the single source of truth for roadmap and delivery progress. - [x] [P1] Customer-to-commission linkage and reuse workflow (no re-entry for recurring customers) - [x] [P1] Kanban workflow for commissions (new, scoped, in-progress, review, done) - [x] [P1] Header banner management (message, CTA, active window) -- [~] [P1] Announcements management (prominent site notices with schedule, priority, and audience targeting) +- [x] [P1] Announcements management (prominent site notices with schedule, priority, and audience targeting) - [~] [P2] News/blog editorial workflow (draft/review/publish, authoring metadata) ### Public App @@ -171,9 +171,9 @@ This file is the single source of truth for roadmap and delivery progress. ### News / Blog (Secondary Track) -- [~] [P1] News/blog content type (editorial content for artist updates and process posts) -- [~] [P1] Admin list/editor for news posts -- [~] [P1] Public news index + detail pages +- [x] [P1] News/blog content type (editorial content for artist updates and process posts) +- [x] [P1] Admin list/editor for news posts +- [x] [P1] Public news index + detail pages - [ ] [P2] Tag/category and basic archive support ### Testing @@ -369,6 +369,7 @@ This file is the single source of truth for roadmap and delivery progress. - [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] 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 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/admin/src/app/announcements/page.tsx b/apps/admin/src/app/announcements/page.tsx index 95129fd..1084ffd 100644 --- a/apps/admin/src/app/announcements/page.tsx +++ b/apps/admin/src/app/announcements/page.tsx @@ -14,6 +14,7 @@ import { requirePermissionForRoute } from "@/lib/route-guards" export const dynamic = "force-dynamic" type SearchParamsInput = Record +const SUPPORTED_LOCALES = ["de", "en", "es", "fr"] as const function readFirstValue(value: string | string[] | undefined): string | null { if (Array.isArray(value)) { @@ -49,6 +50,22 @@ function readNullableDate(formData: FormData, field: string): Date | null { return parsed } +function readLocaleSelections(formData: FormData, field: string): string[] { + const values = formData.getAll(field) + const locales = new Set() + + for (const value of values) { + if ( + typeof value === "string" && + SUPPORTED_LOCALES.includes(value as (typeof SUPPORTED_LOCALES)[number]) + ) { + locales.add(value) + } + } + + return Array.from(locales) +} + function readInt(formData: FormData, field: string, fallback = 100): number { const value = readInputString(formData, field) @@ -94,6 +111,7 @@ async function createAnnouncementAction(formData: FormData) { title: readInputString(formData, "title"), message: readInputString(formData, "message"), placement: readInputString(formData, "placement"), + targetLocales: readLocaleSelections(formData, "targetLocales"), priority: readInt(formData, "priority", 100), ctaLabel: readNullableString(formData, "ctaLabel"), ctaHref: readNullableString(formData, "ctaHref"), @@ -125,6 +143,7 @@ async function updateAnnouncementAction(formData: FormData) { title: readInputString(formData, "title"), message: readInputString(formData, "message"), placement: readInputString(formData, "placement"), + targetLocales: readLocaleSelections(formData, "targetLocales"), priority: readInt(formData, "priority", 100), ctaLabel: readNullableString(formData, "ctaLabel"), ctaHref: readNullableString(formData, "ctaHref"), @@ -277,6 +296,20 @@ export default async function AnnouncementsPage({ /> +
+

Target locales (empty = all locales)

+
+ {SUPPORTED_LOCALES.map((locale) => ( + + ))} +
+
+
+

Target locales (empty = all locales)

+
+ {SUPPORTED_LOCALES.map((locale) => ( + + ))} +
+