This commit is contained in:
oliver
2026-06-10 06:44:34 -03:00
parent 586eb87156
commit c5f2d299ee
4 changed files with 898 additions and 307 deletions
+28 -4
View File
@@ -33,7 +33,8 @@ Font: system font stack (`-apple-system`, `Segoe UI`, etc.)
## Webhook
**Base URL:** `https://brandize.app.n8n.cloud/webhook/e0268b0f-4935-49ba-bfdf-1c0ee01d3b9d`
**Base URL (scan):** `https://brandize.app.n8n.cloud/webhook/transfer`
**Base URL (batches):** `https://brandize.app.n8n.cloud/webhook/batch`
### GET — load users
Called once on page load to populate the user dropdown.
@@ -54,7 +55,7 @@ Authorization: Basic <base64>
3. `{ Name: "Oliver" }` — single object, Name is a string
### POST — submit scan
Called when the user presses Enter in the scan input.
Called automatically when the user types/stops typing for 100ms (debounced).
```
POST <base_url>
@@ -103,6 +104,28 @@ Two cases:
Errors appear in the **persistent status banner** (red, no auto-dismiss) and the scan input is selected so the user can re-scan or correct the code.
### GET — load batches
Called on page load and when the Batches tab becomes visible.
```
GET <batch_url>
Authorization: Basic <base64>
```
**Response shape:**
```json
[
{
"data": [
{ "id": 18599, "name": "BATCH/26-06-10/18599", "description": "mix dpd", "carrier": "DPD/AT", "state": "done" },
...
]
}
]
```
The Batches tab shows a searchable, filterable table with German headers (Chargenname, Transport, Status). Default filter resets to `state != "done"` ("Active") each time the tab opens. Columns are sortable — click Chargenname or Status to toggle ascending/descending. Sorting resets to name-asc when switching tabs.
### NDJSON / response format
n8n sometimes returns multiple items as NDJSON (one JSON object per line) instead of a proper JSON array. `parseJson(res)` handles all three formats:
1. Standard JSON array `[...]`
@@ -131,8 +154,9 @@ n8n sometimes returns multiple items as NDJSON (one JSON object per line) instea
On mobile (< 620 px): scan input goes full-width on its own row; user dropdown and clear button share the row below.
## Key behaviours
- **On load**: cookie credentials restored → GET webhook fires → dropdown populated → scan input auto-focused
- **Enter key**: trims input → duplicate check → clears input **immediately** → adds pending row → pushed onto FIFO queue → `drainQueue()` starts if idle
- **On load**: cookie credentials restored → GET webhooks fire (users + batches) → dropdown populated → scan input auto-focused
- **Scan auto-submit**: scanner input is debounced at 100ms — typing a barcode and pausing auto-submits without needing Enter
- **Scan auto-switches tab**: submitting a scan automatically switches to the Scan Log tab if the Batches tab is active
- **Clear button**: empties the table, clears the scan input, resets the scan counter
- **No user selected**: red toast + highlighted dropdown; does not submit
- **401 on any request**: modal prompts for credentials (pre-filled from cookie), saves to cookie, retries original call