Files
mercadodevida/work/artifacts/F-082/implementer.md
2026-08-20 06:04:22 +02:00

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 on onBlur and Enter, cancels on Escape.
    • SKU and EAN cells were already click-to-edit with the same pattern; left untouched.
    • Removed unused Product import.
  • project/apps/admin/src/features/products/components/sections/InventorySection.tsx

    • Added editingSku, editingEan, savingSku, savingEan, skuValue, eanValue to the row shape; initialise skuValue from variant.sku and eanValue from variant.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.
    • saveStock and savePrice signatures simplified (no productId arg; 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.

Validation

  • npx tsc --noEmit → exit 0
  • npx eslint on 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 reverts editValue/skuValue/eanValue from 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.