FE-8 [PK-48] Admin UI #16

Merged
forge-admin merged 1 commit from feature/PK-48-admin-ui into main 2026-05-17 00:04:50 +00:00
Owner

FE-8 Admin UI: CRUD + orders + mark paid + inbox

Closes PK-48.

FE-8 Admin UI: CRUD + orders + mark paid + inbox Closes [PK-48](https://multica/issue/b2735088-816e-4d5b-8dc3-72ed925c79a7).
Pridava `/admin/*` sekciu napojenu na BE-7 admin endpointy.

Routing:
- `(public)/` route group prebal SiteHeader/SiteFooter; root `layout.tsx`
  je teraz holy a admin nededi verejny chrome.
- `/admin/login` mimo `(authed)/` (gate ho preskakuje); `/admin/(authed)/...`
  pre vsetky chranene stranky.

Auth gate:
- `(authed)/layout.tsx` cita `/api/auth/me`. Bez session redirect na
  `/admin/login`. Prihlaseny non-admin user dostane 403 panel (nie redirect)
  s emailom + odhlasit.

CRUD stranky:
- Products: list (search + category filter + include_inactive toggle),
  new + edit form (vsetky polia zo schemy, image URLs textarea, multi-select
  akcii), soft delete cez DeactivateProductButton + confirm modal.
- Categories: inline create + edit + delete (delete confirm + chyby z BE
  ako toast).
- Promotions: inline create + edit + delete; datetime-local pre starts_at/
  ends_at; type percent vs fixed.
- Stock: inline edit, PUT po blur (alebo Enter), optimistic UI s rollback
  pri 4xx/5xx; Escape vrati povodnu hodnotu.

Orders:
- List s status filter (pending/paid/shipped/cancelled).
- Detail s polozkami, sumarom (subtotal/shipping/VAT/total), adresou,
  poznamkou a casovou osou.
- OrderActions: Mark paid (confirm modal ukazuje order id, VS, sumu a
  email zakaznika), Mark shipped, Cancel — kazda akcia v confirm dialogu,
  refresh + toast po BE odpovedi.

Inbox:
- List s neprecitanymi highlightnutymi, per-item "Oznacit precitane",
  bulk "Oznacit vsetko" cez `/api/admin/inbox/read-all`. Renderer pre
  typy `order_paid`, `order_shipped`, `order_cancelled`, `stock_adjusted`.

Tech:
- Server actions (`fe/src/lib/admin/actions.ts`) pre formulare (Next 14
  app router) — forms cez `useFormState` + `useFormStatus`, server-side
  forwarding session cookie cez `headers()`.
- Client `fetch` + `router.refresh()` pre inline mutacie (stock, orders,
  inbox); BE chyby sa zobrazia ako toast.
- Sidebar: bordova hlavicka, neutralne polozky; tabulky bez brand-flair-u.
- Nove globalne stavy nie su pridane; len lokalny state v komponentoch.

Routes:
- `/admin` dashboard (unread inbox + pending orders count)
- `/admin/login`
- `/admin/products`, `/admin/products/new`, `/admin/products/<id>`
- `/admin/categories`, `/admin/promotions`, `/admin/stock`
- `/admin/orders`, `/admin/orders/<id>`
- `/admin/inbox`

Verifikacia:
- `npm run lint` a `npm run typecheck` v `fe/` prejdu cisto.
- E2E smoke (BE + FE lokalne, seed user `admin@masox.sk`): admin dashboard
  rendruje, products/orders zoznam (30 produktov, 4 orders zo seedu),
  mark-paid prepne stav + zapise audit do inboxu, stock PUT zmeni qty,
  bez cookies → 307 na login, customer (non-admin) → 403 panel.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forge-admin/masox-eshop!16
No description provided.