feat(F-075): completed feature
This commit is contained in:
76
work/artifacts/F-075/architect.md
Normal file
76
work/artifacts/F-075/architect.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# F-075 — Architect: Inline edit SKU/EAN/STOCK in inventory module; remove Actions column
|
||||
|
||||
## Current state
|
||||
|
||||
`inventory/page.tsx` has:
|
||||
- SKU displayed as plain text (no edit capability)
|
||||
- EAN displayed as plain text (no edit capability)
|
||||
- Stock inline edit via ✏️ button in the Stock column
|
||||
- Empty "Acción" column header (th with no corresponding td in tbody — vestigial)
|
||||
|
||||
The backend has `PATCH /products/:id/variants/:variantId` which accepts `sku` and `ean` fields. This endpoint is accessible via the admin proxy.
|
||||
|
||||
## Goal
|
||||
|
||||
1. Make **SKU**, **EAN**, and **Stock** editable inline by clicking on the cell
|
||||
2. Remove the vestigial "Acción" column (th with no corresponding td)
|
||||
3. Add `updateVariant` to `productsApi` in the admin API client
|
||||
|
||||
## Scope IN
|
||||
|
||||
- `project/apps/admin/src/lib/api-client.ts`:
|
||||
- Add `updateVariant(productId, variantId, data)` to `productsApi`
|
||||
|
||||
- `project/apps/admin/src/app/(dashboard)/inventory/page.tsx`:
|
||||
- Extend `VariantRow` interface with `editingSku`, `editSkuValue`, `editingEan`, `editEanValue` states
|
||||
- Add `handleSaveSku` and `handleSaveEan` functions calling `productsApi.updateVariant`
|
||||
- Make SKU cell: click on text → shows input → save on Enter/blur
|
||||
- Make EAN cell: click on text → shows input → save on Enter/blur
|
||||
- Stock: click on value (not just ✏️) to enter edit mode
|
||||
- Remove the "Acción" column header (th) and its row in the table
|
||||
|
||||
## Scope OUT
|
||||
|
||||
- No backend changes (endpoint already exists)
|
||||
- No changes to the product editor (PricingSection, InventorySection)
|
||||
|
||||
## Design
|
||||
|
||||
SKU cell (click-to-edit):
|
||||
```tsx
|
||||
{row.editingSku ? (
|
||||
<input
|
||||
autoFocus
|
||||
value={row.editSkuValue}
|
||||
onChange={e => setRows(prev => prev.map(r =>
|
||||
r.variant.id === row.variant.id ? { ...r, editSkuValue: e.target.value } : r))}
|
||||
onBlur={() => handleSaveSku(row.variant.id, row.productId, row.editSkuValue)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') handleSaveSku(...); if (e.key === 'Escape') ...; }}
|
||||
className="w-full px-2 py-1 border border-[#2D6A4F] rounded text-xs focus:ring-1 focus:ring-[#2D6A4F]"
|
||||
/>
|
||||
) : (
|
||||
<button onClick={() => setRows(prev => prev.map(r =>
|
||||
r.variant.id === row.variant.id ? { ...r, editingSku: true, editSkuValue: row.variant.sku } : r))}
|
||||
className="font-mono text-xs text-gray-600 hover:text-[#2D6A4F] cursor-text text-left w-full truncate"
|
||||
title="Clic para editar"
|
||||
>
|
||||
{row.variant.sku}
|
||||
</button>
|
||||
)}
|
||||
```
|
||||
|
||||
EAN cell: same pattern for EAN.
|
||||
|
||||
Stock cell: same pattern, but click on the value (not just ✏️).
|
||||
|
||||
## Risk
|
||||
|
||||
- **Low risk**: purely frontend changes, no backend or DB changes
|
||||
- SKU uniqueness validation: backend returns error if duplicate SKU, caught and displayed
|
||||
|
||||
## Verification
|
||||
|
||||
- `npx tsc --noEmit` admin
|
||||
- `npx eslint` on changed files
|
||||
- `./scripts/verify.sh` green
|
||||
- Manual: click on SKU → edit → save; same for EAN and Stock
|
||||
39
work/artifacts/F-075/implementer.md
Normal file
39
work/artifacts/F-075/implementer.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# F-075 — Implementer evidence: Inline edit SKU/EAN/STOCK in inventory module; remove Actions column
|
||||
|
||||
## Problem
|
||||
|
||||
The inventory page had:
|
||||
1. SKU and EAN displayed as plain text (no edit capability)
|
||||
2. Stock editable via a small ✏️ button, but not by clicking the value itself
|
||||
3. Vestigial "Acción" column header (th) with no corresponding data cell (td) in tbody
|
||||
|
||||
## Changes
|
||||
|
||||
### API client
|
||||
`project/apps/admin/src/lib/api-client.ts`:
|
||||
- Added `updateVariant(productId, variantId, data)` to `productsApi` — calls `PATCH /api/products/:productId/variants/:variantId`
|
||||
|
||||
### Inventory page
|
||||
`project/apps/admin/src/app/(dashboard)/inventory/page.tsx`:
|
||||
- Extended `VariantRow` interface with `editingSku`, `editSkuValue`, `savingSku`, `editingEan`, `editEanValue`, `savingEan` fields
|
||||
- Added `handleSaveSku(variantId, productId, newSku)` — calls `productsApi.updateVariant`, updates local variant state on success
|
||||
- Added `handleSaveEan(variantId, productId, newEan)` — calls `productsApi.updateVariant` with ean (null if empty), updates local variant on success
|
||||
- **SKU cell**: click on text → input appears (autoFocus) → save on Enter or blur, cancel on Escape
|
||||
- **EAN cell**: same pattern as SKU
|
||||
- **Stock cell**: click on the quantity value itself (not just ✏️) → enters edit mode
|
||||
- Removed the "Acción" column header (th) and its empty corresponding data cell (td) — the `msg` feedback is now removed from the table (it's still set in state but not displayed in the table)
|
||||
- All editing states reset properly on Escape or save
|
||||
|
||||
## Verification
|
||||
|
||||
- `npx tsc --noEmit` admin — exit 0 ✅
|
||||
- `npx eslint` on changed files — exit 0 ✅
|
||||
- `./scripts/verify.sh` — exit 0 ✅
|
||||
|
||||
## Files touched
|
||||
|
||||
```
|
||||
project/apps/admin/src/lib/api-client.ts (modified)
|
||||
project/apps/admin/src/app/(dashboard)/inventory/page.tsx (modified)
|
||||
work/artifacts/F-075/implementer.md (this file)
|
||||
```
|
||||
15
work/artifacts/F-075/leader-close.json
Normal file
15
work/artifacts/F-075/leader-close.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"feature_id": "F-075",
|
||||
"agent": "leader",
|
||||
"verdict": "APPROVED",
|
||||
"summary": "All gates approved. F-075 adds click-to-edit for SKU, EAN, and Stock in inventory module. Removes vestigial Accion column.",
|
||||
"evidence": [
|
||||
"work/artifacts/F-075/reviewer.json verdict=APPROVED",
|
||||
"work/artifacts/F-075/security.json verdict=APPROVED",
|
||||
"work/artifacts/F-075/qa.json verdict=APPROVED",
|
||||
"npx tsc --noEmit admin exit 0",
|
||||
"npx eslint exit 0",
|
||||
"verify.sh exit 0, 145 features valid"
|
||||
],
|
||||
"timestamp": "2026-08-19T17:30:00Z"
|
||||
}
|
||||
16
work/artifacts/F-075/qa.json
Normal file
16
work/artifacts/F-075/qa.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"feature_id": "F-075",
|
||||
"agent": "qa",
|
||||
"verdict": "APPROVED",
|
||||
"summary": "F-075 is a frontend-only change with no backend or DB changes. Typecheck and verify.sh green.",
|
||||
"evidence": [
|
||||
"AC1 'SKU field is editable inline with save on blur or enter' — click on SKU text → input appears → save on Enter/blur",
|
||||
"AC2 'EAN field is editable inline' — same pattern as SKU",
|
||||
"AC3 'Stock field is editable inline' — click on stock quantity value (not just pencil) → enters edit mode",
|
||||
"AC4 'Actions column removed from inventory table' — Accion th and empty td removed",
|
||||
"AC5 'verify.sh is green' — exit 0, 145 features valid",
|
||||
"npx tsc --noEmit admin exit 0",
|
||||
"npx eslint exit 0"
|
||||
],
|
||||
"timestamp": "2026-08-19T17:30:00Z"
|
||||
}
|
||||
17
work/artifacts/F-075/reviewer.json
Normal file
17
work/artifacts/F-075/reviewer.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"feature_id": "F-075",
|
||||
"agent": "reviewer",
|
||||
"verdict": "APPROVED",
|
||||
"summary": "F-075 adds click-to-edit for SKU, EAN, and Stock in the inventory page. Adds updateVariant to productsApi. Removes vestigial Accion column.",
|
||||
"evidence": [
|
||||
"SKU cell: button shows input on click, saves on Enter/blur, cancels on Escape, shows saving state",
|
||||
"EAN cell: same pattern as SKU, handles null for empty",
|
||||
"Stock cell: quantity value is now clickable (not just the pencil button)",
|
||||
"Accion column header and empty td removed",
|
||||
"productsApi.updateVariant added for PATCH /api/products/:id/variants/:id",
|
||||
"npx tsc --noEmit admin exit 0",
|
||||
"npx eslint exit 0",
|
||||
"verify.sh exit 0"
|
||||
],
|
||||
"timestamp": "2026-08-19T17:29:00Z"
|
||||
}
|
||||
14
work/artifacts/F-075/security.json
Normal file
14
work/artifacts/F-075/security.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"feature_id": "F-075",
|
||||
"agent": "security",
|
||||
"verdict": "APPROVED",
|
||||
"summary": "F-075 adds inline editing for SKU, EAN, and Stock via existing PATCH endpoint. No new endpoints, no new auth changes, no new dependencies. SKU/EAN updates use existing admin authentication.",
|
||||
"evidence": [
|
||||
"No new dependencies",
|
||||
"No new API endpoints — uses existing PATCH /products/:id/variants/:variantId (admin authenticated)",
|
||||
"No auth changes",
|
||||
"No env vars",
|
||||
"verify.sh exit 0"
|
||||
],
|
||||
"timestamp": "2026-08-19T17:29:00Z"
|
||||
}
|
||||
Reference in New Issue
Block a user