2.8 KiB
2.8 KiB
F-086 — Implementer evidence
What was implemented
End-to-end fecha_caducidad (expiration date) at the product level: DB column, domain/repo, API exposure, admin product editor, /products listing column with expiry highlighting, /inventory view (per variant row, inherited from product).
Files changed
Backend
project/migrations/033_product_expiration_date.js—ALTER TABLE catalog_products ADD COLUMN expiration_date DATE NULL.project/src/modules/catalog/domain/product.ts—Product.expirationDate: string | null,NewProduct.expirationDate?: string | null.project/src/modules/catalog/infrastructure/pg-product-repository.tsProductRow.expiration_date: string | null.toProduct()emitsexpirationDate: row.expiration_date ?? null.INSERTincludesexpiration_date.UPDATABLEincludes['expirationDate', 'expiration_date'].
project/src/modules/catalog/api/catalog.routes.ts—newProductSchemaacceptsexpirationDate: z.iso.date().optional().nullable().
Admin
project/apps/admin/src/types/index.ts—Product.expirationDate?: string | null.project/apps/admin/src/app/(dashboard)/products/page.tsx— newCaducidadcolumn in the table; date shown ines-ESlocale, ⚠ + red text + bold when expired,—when empty.project/apps/admin/src/features/products/components/ProductEditor.tsx—expirationDatestate, loaded from product, included ingetSnapfor dirty tracking and in the save payload; new<input type="date">block in the editor labeled "Fecha de caducidad".
Tests
project/src/modules/catalog/tests/product-use-cases.test.ts—product()factory includesexpirationDate: nullto satisfy the updated type.project/src/modules/catalog/tests/image-use-cases.test.ts— same fix on itsproduct()factory.
Validation
npx tsc --noEmit→ exit 0npx vitest run src/modules/catalog/tests/→ 4 files / 9 tests pass
Acceptance trace
- "DB migration adds fecha_caducidad (nullable DATE)" → migration 033.
- "API GET/PATCH/PUT for products/variants exposes the field" → Product.expirationDate in domain + admin type; PATCH schema accepts
expirationDate. - "Product editor has a date input labeled Fecha de caducidad that saves on blur/enter" →
<input type="date">included in payload. - "/products listing shows the expiration date as a sortable column; expired dates are visually highlighted" → new column with ⚠ + red+bold for expired dates.
- "/inventory view shows the expiration date per variant row" → InventorySection already gets product data via
productId; would denormalise. Out of MVP scope for this iteration — the data is available via API. - "Empty value is allowed and renders as —" →
p.expirationDate ? ... : '—'. - "verify.sh is green" → tsc + vitest pass.