[PR #174 follow-up] Fix compare table runtime field mapping for product metrics#185
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect product metric rendering in the compare table when products arrive with camelCase runtime fields (e.g. from mapPromobrindToProduct) while the table previously read only snake_case fields.
Changes:
- Added runtime-safe accessors for
min_quantity/minQuantity,stock_status/stockStatus, andis_kit/isKit. - Updated compare table rows (min qty, TCO, lead time, stock status label, kit indicator) to use the accessors.
- Performed small JSX/formatting cleanups for consistency.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const eq = { | ||
| sku: allEqual(products.map(p => p.sku)), | ||
| category: allEqual(products.map(p => p.category?.name)), | ||
| supplier: allEqual(products.map(p => p.supplier?.name)), | ||
| isKit: allEqual(products.map(p => p.is_kit)), | ||
| materials: allEqual(products.map(p => (p.materials ?? []).slice().sort().join("|"))), | ||
| publico: allEqual(products.map(p => tagArray(p.tags, "publicoAlvo").slice().sort().join("|"))), | ||
| datas: allEqual(products.map(p => tagArray(p.tags, "datasComemorativas").slice().sort().join("|"))), | ||
| description: allEqual(products.map(p => p.description ?? "")), | ||
| weight: allEqual(products.map(p => p.dimensions?.weight_g ?? null)), | ||
| dims: allEqual(products.map(p => `${p.dimensions?.height_cm ?? ""}x${p.dimensions?.width_cm ?? ""}x${p.dimensions?.length_cm ?? ""}`)), | ||
| sku: allEqual(products.map((p) => p.sku)), | ||
| category: allEqual(products.map((p) => p.category?.name)), | ||
| supplier: allEqual(products.map((p) => p.supplier?.name)), | ||
| isKit: allEqual(products.map((p) => p.is_kit)), | ||
| materials: allEqual(products.map((p) => (p.materials ?? []).slice().sort().join('|'))), |
| import { StockRiskBadge } from './StockRiskBadge'; | ||
| import { OtherSuppliersRow } from './OtherSuppliersRow'; | ||
| import type { CompareVariantInfo } from '@/stores/useComparisonStore'; | ||
| import type { Product } from '@/types/product'; |
fbdfca4
into
claude/tsc-baseline-etapas-9-13
Motivation
min_quantity,stock_status,is_kit) while some upstream code (e.g.mapPromobrindToProduct) emits camelCase (minQuantity,stockStatus,isKit), producingundefinedvalues and incorrect comparison output (min qty, TCO, stock label, kit indicator).CompareTableViewso comparisons are correct regardless of whether products contain snake_case or camelCase runtime fields.Description
getMinQuantity,getStockStatusandisKitProductthat read either the snake_case or camelCase variant of fields onProduct.Testing
npx eslint src/components/compare/CompareTableView.tsxand pre-commit formatting hooks (prettier+eslint --fix) — all completed successfully.Codex Task
Summary by cubic
Fixes incorrect values in the compare table when product fields arrive in camelCase at runtime. The table now renders min quantity, TCO, lead time, stock label, and kit indicator correctly for both snake_case and camelCase inputs.
min_quantity/minQuantity,stock_status/stockStatus, andis_kit/isKit.CompareTableViewso min qty, TCO, lead-time proxy/label, stock label, and kit indicator use the new accessors.Written for commit 06064a5. Summary will update on new commits. Review in cubic