u
This commit is contained in:
53
TODO.md
Normal file
53
TODO.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# TODO — nächster Schritt (Brands / Artikelfelder)
|
||||
|
||||
**dashback** hat die HTTP-Routen geliefert (siehe `../dashback/TODO.md`). Alle Endpoints stehen. `companyId` kommt **immer aus der Auth-Session** (nicht aus `?companyId=`), gesteuert über `google_auth.setSelectedCompany`. Hier die UI bauen.
|
||||
|
||||
## Endpoints
|
||||
|
||||
| UI-Bedarf | HTTP | Request | Response |
|
||||
| --- | --- | --- | --- |
|
||||
| Brand-Liste | `GET /api/brand` | – | `{ brands: Brand[] }` |
|
||||
| Brand anlegen / updaten | `PUT /api/brand` | `{ name, gsprpinfo? }` | `{ brand: Brand }` |
|
||||
| Brand löschen | `DELETE /api/brand/:id` | – | `204` |
|
||||
| EANs setzen (replace-all) | `PUT /api/article/:sku/eans` | `{ eans: string[] }` | `{ article }` (Detail) |
|
||||
| Brand setzen / entfernen | `PUT /api/article/:sku/brand` | `{ brandId: number \| null }` | `{ article }` (Detail) |
|
||||
| Gewicht setzen | `PUT /api/article/:sku/weight` | `{ weight: number }` | `{ article }` (Detail) |
|
||||
| Kategorien setzen (replace-all) | `PUT /api/article/:sku/categories` | `{ categoryIds: number[] }` | `{ article }` (Detail) |
|
||||
| Detail liefert neue Felder | `GET /api/article/:sku` | – | `{ article }` mit `eans`, `categoryIds`, `weight`, `brand` |
|
||||
|
||||
`Brand` = `{ id, name, gsprpinfo \| null }`.
|
||||
|
||||
Alle PUT/PATCH-Endpoints der Artikel liefern dasselbe Shape wie `GET /api/article/:sku`.
|
||||
|
||||
## Umsetzung
|
||||
|
||||
### API-Client (`src/api/index.js`)
|
||||
- Alle Calls über den bestehenden Client (`credentials: 'include'`) — Frontend spricht nur HTTP, nie direkt den Store.
|
||||
- Neuen Methoden für: `brand.list` / `brand.upsert` / `brand.delete` und `article.setEansBySku` / `article.setBrandIdBySku` / `article.setWeightBySku` / `article.setCategoryIdsBySku`.
|
||||
- **Kein `companyId` in Request/Pfad/Query senden** — die Company kommt aus der Session.
|
||||
|
||||
### Brand-UI
|
||||
- **Liste**: lädt `GET /api/brand` und zeigt `name` (+ optional `gsprpinfo`).
|
||||
- **Anlegen/Updaten**: ein Formular (Name + optional GSPRP-Info). Upsert matcht per `name` — gleicher Name ⇒ Update, sonst Create. Leeres/fehlendes `name` ⇒ API `400 Invalid brand`.
|
||||
- **Löschen**: Bestätigung; `409 Brand in use` als Fehler anzeigen (Brand ist noch an Artikeln).
|
||||
- Hängt an `selectedCompanyId`: bei Company-Wechsel Liste neu laden / leeren.
|
||||
|
||||
### Artikel-Detail-Felder
|
||||
- **EANs**: Mehrfach-Eingabe (Liste). Replace-all: leere Liste löscht alle. `400 Invalid eans` bei leeren/duplizierten Einträgen.
|
||||
- **Brand**: Dropdown aus `GET /api/brand`; „Keine Brand“ ⇒ `brandId: null`. Deal nur mit Brands derselben Company (sonst `404 Brand not found`).
|
||||
- **Gewicht**: Zahlenfeld, `>= 0`. `400 Invalid weight` sonst.
|
||||
- **Kategorien**: Mehrfachauswahl aus der Category-Tree; nur Kategorien derselben Company (sonst `400 Invalid categoryIds`). Leere Liste entfernt alle.
|
||||
- Nach jedem Save das zurückgegebene Detail-Objekt in den Store übernehmen.
|
||||
|
||||
### Fehlerbehandlung
|
||||
- Fehler als Toast/Formular-Fehler abbilden:
|
||||
- `Brand in use` (409), `Invalid eans` / `Invalid weight` / `Invalid categoryIds` / `Invalid brand` (400)
|
||||
- `Brand not found` / `Article not found` (404)
|
||||
- `No company selected` (400) → Company-Wechsel-Flow
|
||||
- `Not authorized` (403)
|
||||
|
||||
## Referenz
|
||||
- API-Doku: `../dashback/docs/api/README.md` und `../dashback/docs/api/routes/`
|
||||
- `brand/list.md`, `brand/upsert.md`, `brand/delete.md`
|
||||
- `article/set-eans.md`, `article/set-brand.md`, `article/set-weight.md`, `article/set-categories.md`
|
||||
- Company-Scope: `google_auth.setSelectedCompany` (Store) — siehe `../dashdbschema/README.md`.
|
||||
Reference in New Issue
Block a user