Compare commits

..

1 Commits

10 changed files with 93 additions and 12 deletions

11
TODO.md
View File

@@ -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) page CRUD, navigation tree, reusable page blocks (forms/price cards/gallery embeds)
- [~] [P1] `todo/mvp1-commissions-customers`: - [~] [P1] `todo/mvp1-commissions-customers`:
commission request intake + admin CRUD + kanban + customer entity/linking 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 announcement management/rendering + news/blog CRUD and public rendering
- [~] [P1] `todo/mvp1-public-rendering-integration`: - [~] [P1] `todo/mvp1-public-rendering-integration`:
public rendering for pages/navigation/media/portfolio/announcements and commissioning entrypoints 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] 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] Kanban workflow for commissions (new, scoped, in-progress, review, done)
- [x] [P1] Header banner management (message, CTA, active window) - [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) - [~] [P2] News/blog editorial workflow (draft/review/publish, authoring metadata)
### Public App ### Public App
@@ -171,9 +171,9 @@ This file is the single source of truth for roadmap and delivery progress.
### News / Blog (Secondary Track) ### News / Blog (Secondary Track)
- [~] [P1] News/blog content type (editorial content for artist updates and process posts) - [x] [P1] News/blog content type (editorial content for artist updates and process posts)
- [~] [P1] Admin list/editor for news posts - [x] [P1] Admin list/editor for news posts
- [~] [P1] Public news index + detail pages - [x] [P1] Public news index + detail pages
- [ ] [P2] Tag/category and basic archive support - [ ] [P2] Tag/category and basic archive support
### Testing ### 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] 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] 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] 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] 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`.

View File

@@ -14,6 +14,7 @@ import { requirePermissionForRoute } from "@/lib/route-guards"
export const dynamic = "force-dynamic" export const dynamic = "force-dynamic"
type SearchParamsInput = Record<string, string | string[] | undefined> type SearchParamsInput = Record<string, string | string[] | undefined>
const SUPPORTED_LOCALES = ["de", "en", "es", "fr"] as const
function readFirstValue(value: string | string[] | undefined): string | null { function readFirstValue(value: string | string[] | undefined): string | null {
if (Array.isArray(value)) { if (Array.isArray(value)) {
@@ -49,6 +50,22 @@ function readNullableDate(formData: FormData, field: string): Date | null {
return parsed return parsed
} }
function readLocaleSelections(formData: FormData, field: string): string[] {
const values = formData.getAll(field)
const locales = new Set<string>()
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 { function readInt(formData: FormData, field: string, fallback = 100): number {
const value = readInputString(formData, field) const value = readInputString(formData, field)
@@ -94,6 +111,7 @@ async function createAnnouncementAction(formData: FormData) {
title: readInputString(formData, "title"), title: readInputString(formData, "title"),
message: readInputString(formData, "message"), message: readInputString(formData, "message"),
placement: readInputString(formData, "placement"), placement: readInputString(formData, "placement"),
targetLocales: readLocaleSelections(formData, "targetLocales"),
priority: readInt(formData, "priority", 100), priority: readInt(formData, "priority", 100),
ctaLabel: readNullableString(formData, "ctaLabel"), ctaLabel: readNullableString(formData, "ctaLabel"),
ctaHref: readNullableString(formData, "ctaHref"), ctaHref: readNullableString(formData, "ctaHref"),
@@ -125,6 +143,7 @@ async function updateAnnouncementAction(formData: FormData) {
title: readInputString(formData, "title"), title: readInputString(formData, "title"),
message: readInputString(formData, "message"), message: readInputString(formData, "message"),
placement: readInputString(formData, "placement"), placement: readInputString(formData, "placement"),
targetLocales: readLocaleSelections(formData, "targetLocales"),
priority: readInt(formData, "priority", 100), priority: readInt(formData, "priority", 100),
ctaLabel: readNullableString(formData, "ctaLabel"), ctaLabel: readNullableString(formData, "ctaLabel"),
ctaHref: readNullableString(formData, "ctaHref"), ctaHref: readNullableString(formData, "ctaHref"),
@@ -277,6 +296,20 @@ export default async function AnnouncementsPage({
/> />
</label> </label>
</div> </div>
<div className="space-y-1">
<p className="text-xs text-neutral-600">Target locales (empty = all locales)</p>
<div className="flex flex-wrap gap-3">
{SUPPORTED_LOCALES.map((locale) => (
<label
key={`create-locale-${locale}`}
className="inline-flex items-center gap-2 text-sm"
>
<input name="targetLocales" type="checkbox" value={locale} className="size-4" />
{locale.toUpperCase()}
</label>
))}
</div>
</div>
<div className="grid gap-3 md:grid-cols-2"> <div className="grid gap-3 md:grid-cols-2">
<label className="space-y-1"> <label className="space-y-1">
<span className="text-xs text-neutral-600">Starts at</span> <span className="text-xs text-neutral-600">Starts at</span>
@@ -390,6 +423,26 @@ export default async function AnnouncementsPage({
/> />
</label> </label>
</div> </div>
<div className="mt-3 space-y-1">
<p className="text-xs text-neutral-600">Target locales (empty = all locales)</p>
<div className="flex flex-wrap gap-3">
{SUPPORTED_LOCALES.map((locale) => (
<label
key={`${announcement.id}-locale-${locale}`}
className="inline-flex items-center gap-2 text-sm"
>
<input
name="targetLocales"
type="checkbox"
value={locale}
defaultChecked={announcement.targetLocales.includes(locale)}
className="size-4"
/>
{locale.toUpperCase()}
</label>
))}
</div>
</div>
<div className="mt-3 flex flex-wrap items-center justify-between gap-3"> <div className="mt-3 flex flex-wrap items-center justify-between gap-3">
<label className="inline-flex items-center gap-2 text-sm text-neutral-700"> <label className="inline-flex items-center gap-2 text-sm text-neutral-700">
<input <input

View File

@@ -52,7 +52,7 @@ export default async function LocaleLayout({ children, params }: LocaleLayoutPro
<NextIntlClientProvider locale={locale}> <NextIntlClientProvider locale={locale}>
<Providers> <Providers>
<PublicHeaderBanner banner={banner} /> <PublicHeaderBanner banner={banner} />
<PublicAnnouncements placement="global_top" /> <PublicAnnouncements placement="global_top" locale={locale} />
<PublicSiteHeader /> <PublicSiteHeader />
<main>{children}</main> <main>{children}</main>
<PublicSiteFooter /> <PublicSiteFooter />

View File

@@ -1,4 +1,4 @@
import { getPublishedPageBySlugForLocale, listPosts } from "@cms/db" import { getPublishedPageBySlugForLocale, listPostsForLocale } from "@cms/db"
import { getTranslations } from "next-intl/server" import { getTranslations } from "next-intl/server"
import { PublicAnnouncements } from "@/components/public-announcements" import { PublicAnnouncements } from "@/components/public-announcements"
import { PublicPageView } from "@/components/public-page-view" import { PublicPageView } from "@/components/public-page-view"
@@ -15,14 +15,14 @@ export default async function HomePage({ params }: HomePageProps) {
const [homePage, posts, t] = await Promise.all([ const [homePage, posts, t] = await Promise.all([
getPublishedPageBySlugForLocale("home", locale), getPublishedPageBySlugForLocale("home", locale),
listPosts(), listPostsForLocale(locale),
getTranslations("Home"), getTranslations("Home"),
]) ])
return ( return (
<section> <section>
{homePage ? <PublicPageView page={homePage} /> : null} {homePage ? <PublicPageView page={homePage} /> : null}
<PublicAnnouncements placement="homepage" /> <PublicAnnouncements placement="homepage" locale={locale} />
<section className="mx-auto flex w-full max-w-6xl flex-col gap-6 px-6 py-6 pb-16"> <section className="mx-auto flex w-full max-w-6xl flex-col gap-6 px-6 py-6 pb-16">
<header className="space-y-3"> <header className="space-y-3">

View File

@@ -3,6 +3,7 @@ import Link from "next/link"
type PublicAnnouncementsProps = { type PublicAnnouncementsProps = {
placement: "global_top" | "homepage" placement: "global_top" | "homepage"
locale?: string
} }
function AnnouncementCard({ announcement }: { announcement: PublicAnnouncement }) { function AnnouncementCard({ announcement }: { announcement: PublicAnnouncement }) {
@@ -22,8 +23,8 @@ function AnnouncementCard({ announcement }: { announcement: PublicAnnouncement }
) )
} }
export async function PublicAnnouncements({ placement }: PublicAnnouncementsProps) { export async function PublicAnnouncements({ placement, locale }: PublicAnnouncementsProps) {
const announcements = await listActiveAnnouncements(placement) const announcements = await listActiveAnnouncements(placement, new Date(), locale)
if (announcements.length === 0) { if (announcements.length === 0) {
return null return null

View File

@@ -1,11 +1,13 @@
import { z } from "zod" import { z } from "zod"
export const announcementPlacementSchema = z.enum(["global_top", "homepage"]) export const announcementPlacementSchema = z.enum(["global_top", "homepage"])
export const announcementLocaleSchema = z.enum(["de", "en", "es", "fr"])
export const createAnnouncementInputSchema = z.object({ export const createAnnouncementInputSchema = z.object({
title: z.string().min(1).max(180), title: z.string().min(1).max(180),
message: z.string().min(1).max(500), message: z.string().min(1).max(500),
placement: announcementPlacementSchema.default("global_top"), placement: announcementPlacementSchema.default("global_top"),
targetLocales: z.array(announcementLocaleSchema).default([]),
priority: z.number().int().min(0).default(100), priority: z.number().int().min(0).default(100),
ctaLabel: z.string().max(120).nullable().optional(), ctaLabel: z.string().max(120).nullable().optional(),
ctaHref: z.string().max(500).nullable().optional(), ctaHref: z.string().max(500).nullable().optional(),
@@ -19,6 +21,7 @@ export const updateAnnouncementInputSchema = z.object({
title: z.string().min(1).max(180).optional(), title: z.string().min(1).max(180).optional(),
message: z.string().min(1).max(500).optional(), message: z.string().min(1).max(500).optional(),
placement: announcementPlacementSchema.optional(), placement: announcementPlacementSchema.optional(),
targetLocales: z.array(announcementLocaleSchema).optional(),
priority: z.number().int().min(0).optional(), priority: z.number().int().min(0).optional(),
ctaLabel: z.string().max(120).nullable().optional(), ctaLabel: z.string().max(120).nullable().optional(),
ctaHref: z.string().max(500).nullable().optional(), ctaHref: z.string().max(500).nullable().optional(),

View File

@@ -0,0 +1,2 @@
ALTER TABLE "Announcement"
ADD COLUMN "targetLocales" TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[];

View File

@@ -405,6 +405,7 @@ model Announcement {
title String title String
message String message String
placement String placement String
targetLocales String[] @default([])
priority Int @default(100) priority Int @default(100)
ctaLabel String? ctaLabel String?
ctaHref String? ctaHref String?

View File

@@ -41,13 +41,18 @@ describe("announcements service", () => {
it("queries only visible announcements in the given placement", async () => { it("queries only visible announcements in the given placement", async () => {
mockDb.announcement.findMany.mockResolvedValue([]) mockDb.announcement.findMany.mockResolvedValue([])
await listActiveAnnouncements("homepage") await listActiveAnnouncements("homepage", new Date("2026-02-12T10:00:00.000Z"), "en")
expect(mockDb.announcement.findMany).toHaveBeenCalledTimes(1) expect(mockDb.announcement.findMany).toHaveBeenCalledTimes(1)
expect(mockDb.announcement.findMany.mock.calls[0]?.[0]).toMatchObject({ expect(mockDb.announcement.findMany.mock.calls[0]?.[0]).toMatchObject({
where: { where: {
placement: "homepage", placement: "homepage",
isVisible: true, isVisible: true,
AND: [
{
OR: [{ targetLocales: { isEmpty: true } }, { targetLocales: { has: "en" } }],
},
],
}, },
}) })
}) })

View File

@@ -13,6 +13,7 @@ export type PublicAnnouncement = {
ctaLabel: string | null ctaLabel: string | null
ctaHref: string | null ctaHref: string | null
placement: string placement: string
targetLocales: string[]
priority: number priority: number
} }
@@ -50,13 +51,26 @@ export async function deleteAnnouncement(id: string) {
export async function listActiveAnnouncements( export async function listActiveAnnouncements(
placement: AnnouncementPlacement, placement: AnnouncementPlacement,
now = new Date(), now = new Date(),
locale?: string,
): Promise<PublicAnnouncement[]> { ): Promise<PublicAnnouncement[]> {
const localeFilter =
locale && locale.length > 0
? {
AND: [
{
OR: [{ targetLocales: { isEmpty: true } }, { targetLocales: { has: locale } }],
},
],
}
: undefined
const announcements = await db.announcement.findMany({ const announcements = await db.announcement.findMany({
where: { where: {
placement, placement,
isVisible: true, isVisible: true,
OR: [{ startsAt: null }, { startsAt: { lte: now } }], OR: [{ startsAt: null }, { startsAt: { lte: now } }],
AND: [{ OR: [{ endsAt: null }, { endsAt: { gte: now } }] }], AND: [{ OR: [{ endsAt: null }, { endsAt: { gte: now } }] }],
...(localeFilter ?? {}),
}, },
orderBy: [{ priority: "asc" }, { createdAt: "desc" }], orderBy: [{ priority: "asc" }, { createdAt: "desc" }],
select: { select: {
@@ -66,6 +80,7 @@ export async function listActiveAnnouncements(
ctaLabel: true, ctaLabel: true,
ctaHref: true, ctaHref: true,
placement: true, placement: true,
targetLocales: true,
priority: true, priority: true,
}, },
}) })