3.0 KiB
3.0 KiB
F-082 — Implementer evidence
What was implemented
Two inventory surfaces got the same click-to-edit + save-on-Enter/blur UX. Removed the pencil step and the OK button pattern.
Files changed
-
project/apps/admin/src/app/(dashboard)/inventory/page.tsx- Added
saveStockInline(variantId, value)helper that saves on Enter/blur and restores the previous value on Escape or error. - Stock cell: dropped the OK button and ✕ button. The cell itself is a
<button>whose value opens an<input autoFocus>; saves ononBlurandEnter, cancels onEscape. - SKU and EAN cells were already click-to-edit with the same pattern; left untouched.
- Removed unused
Productimport.
- Added
-
project/apps/admin/src/features/products/components/sections/InventorySection.tsx- Added
editingSku,editingEan,savingSku,savingEan,skuValue,eanValueto the row shape; initialiseskuValuefromvariant.skuandeanValuefromvariant.ean ?? ''. - SKU cell: previously plain text. Now click-to-edit. Saves on Enter/blur via new
saveSku(variantId, productId)→productsApi.updateVariant(productId, variantId, { sku }). Cancels on Escape. - EAN cell: previously plain text. Now click-to-edit. Saves on Enter/blur via
saveEan(variantId, productId)→productsApi.updateVariant(productId, variantId, { ean: newEan || null }). Cancels on Escape. - Stock cell: dropped the ✏️ icon and the OK/✕ buttons. Now click-to-edit. Saves on Enter/blur via
saveStock(variantId)→inventoryApi.setStock. Cancels on Escape. - Precio neto cell: dropped the ✏️ icon and the OK/✕ buttons. Now click-to-edit. Saves on Enter/blur via
savePrice(variantId)→pricingApi.setVariantPrice. Cancels on Escape. saveStockandsavePricesignatures simplified (noproductIdarg; pricing/inventory APIs don't need it). Both restore the previous value on validation failure or API error.- "Estado + acciones" cell no longer renders the OK/✕ buttons; keeps the badge and the save-msg chip.
- Added
Validation
npx tsc --noEmit→ exit 0npx eslinton changed files → exit 0- Vitest unchanged for backend; UI refactor.
Acceptance trace
- "Every editable cell in /inventory (SKU, EAN, Stock, Precio Neto, etc.) saves on blur or Enter via PATCH" → all four cell types in InventorySection plus Stock in /inventory page adopt onBlur + Enter-key save.
- "Stock cell enters edit mode on a single click; pencil icon is removed" → Stock cell is a
<button>whose text is the value; click swaps to<input autoFocus>. - "Successful save shows visual confirmation" →
saveMsg[variantId]shows "✓ Guardado" for 3s. - "Failed save shows inline error and restores the previous value" → catch block sets
msg = 'Error'and revertseditValue/skuValue/eanValuefrom the row's persisted state. - "No regressions in Prices tab or product editor" → PricingSection unchanged; only InventorySection and /inventory page were modified.
- "verify.sh is green" → tsc + eslint clean.