# Nouveautés (feature announcements) — admin

The admin section where the product team writes, targets, previews, publishes and measures the
in-app announcements of new Fleet features. Specification: [SPEC.md](./SPEC.md) (V2, single release).

## Status

Built on **mock data**: `/api/admin/announcements` does not exist yet. Everything runs against a
contract mock that applies the backend's rules (field errors, locked fields, rounds, audience
counts on a fake Fleet population, growing statistics). Mock state is kept in the browser
(`localStorage`), so drafts survive a reload.

## Run it

`.env.local`:

```
NEXT_PUBLIC_ANNOUNCEMENTS_MOCK=true
# optional
NEXT_PUBLIC_FLEET_URL=https://myfleet.dadycar.fr
NEXT_PUBLIC_ANNOUNCEMENTS_POSTHOG_URL=
```

Then `npm run dev` and open `/admin/announcements` (sidebar: **Produit → Nouveautés**).
To reset the demo data, delete the `dadycar-admin:announcements-mock:v1` key in the browser's
local storage.

## Access

`announcements.manage` (write) and `announcements.publish` (publish, unpublish, reset, archive).
Until the backend seeds `announcements.*`, both fall back to `companies.manage`
(`ANNOUNCEMENTS_FALLBACK_PERMISSION`).

## Where things are

| Layer | Files |
|---|---|
| Types | `src/domain/entities/announcement.ts` |
| Repository contract | `src/domain/repositories/announcement.repository.ts` |
| API (real) | `src/infrastructure/repositories/announcement.repository.impl.ts` |
| Mock + fixtures | `announcement.repository.mock.ts`, `announcement.mock-data.ts` |
| Format rules as data | `src/shared/constants/announcements.ts` (`FORMAT_FIELDS`) |
| Validation, Paris time, rich text | `src/shared/lib/announcements.ts` |
| Pages | `src/app/(dashboard)/announcements/` (list, `new`, `[id]`) |
| Components | `src/presentation/components/announcements/` |
| Texts FR/EN | `announcements` block in `src/shared/i18n/messages-*.ts` |

## Connecting the backend

1. Implement the routes of SPEC.md §9 (and §14). Three routes are collection-level POSTs in the
   implementation, because they work on an unsaved audience: `POST /announcements/audience-count`,
   `POST /announcements/eligibility`, `POST /announcements/overlapping-modals`.
2. Reconcile the shapes with the backend document §4.5: only `announcement.ts` and
   `announcement.repository.impl.ts` should change, not the screens.
3. Set `NEXT_PUBLIC_ANNOUNCEMENTS_MOCK=false`, seed the two permissions.

## Screenshots

See `screenshots/`: list, editor with the main example (tooltip on « Bouton Zones »), modal
simulation, publish check with highlighted fields, audience and "why isn't it shown?",
overlapping modals warning, statistics, reset.
