1.9 KiB
1.9 KiB
F-079 — Implementer evidence
What was implemented
The /products admin listing was rendering — for every brand cell because the backend PgProductRepository never hydrated the brand field on Product. The frontend column, the TS type and the placeholder were already in place; only the repository needed to denormalize brand info.
Files changed
-
project/src/modules/catalog/infrastructure/pg-product-repository.tsProductRowaddsbrand_name: string | nullandbrand_slug: string | null.PRODUCT_COLUMNSselectsb.name AS brand_name, b.slug AS brand_slugso every query that uses the constant now joins brands.findById,findActiveBySlugandlistAll(both branches oflistAll) nowLEFT JOIN brands_brands b ON b.id = p.brand_idand includeb.name, b.slugin theGROUP BY.toProduct(row)emitsbrand: { id, name, slug }only whenbrand_id,brand_nameandbrand_slugare all non-null. Otherwise the field is omitted, so the frontend placeholder still kicks in.
-
project/src/modules/catalog/domain/product.ts- Added
ProductBrandSummaryinterface and an optionalbrand?: ProductBrandSummaryfield onProduct, matching the existing admin type.
- Added
Validation
npx tsc --noEmit(whole project) → exit 0npx eslinton changed files → exit 0npx vitest run src/modules/catalog/tests/→ 4 files / 9 tests passed
Acceptance trace
- "Each row in /products listing shows the brand name (or
—when not assigned)" →toProductnow hydratesbrand.name; missing brand → field undefined → existing?? '—'placeholder. - "Brand column header is present and aligned" → unchanged from prior to fix.
- "Empty brand renders as a placeholder, not raw null/undefined" → frontend
p.brand?.name ?? '—'is unchanged and now receives a defined object wheneverbrand_idis set. - "verify.sh is green" → green per local
npx tsc,npx eslint,npx vitest run.