Skip to content

[PR #174 follow-up] Fix compare table runtime field mapping for product metrics#185

Merged
adm01-debug merged 1 commit into
claude/tsc-baseline-etapas-9-13from
codex/fix-high-priority-bug-in-comparetableview
May 23, 2026
Merged

[PR #174 follow-up] Fix compare table runtime field mapping for product metrics#185
adm01-debug merged 1 commit into
claude/tsc-baseline-etapas-9-13from
codex/fix-high-priority-bug-in-comparetableview

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 23, 2026

Motivation

  • The compare table read product metrics using snake_case fields (min_quantity, stock_status, is_kit) while some upstream code (e.g. mapPromobrindToProduct) emits camelCase (minQuantity, stockStatus, isKit), producing undefined values and incorrect comparison output (min qty, TCO, stock label, kit indicator).
  • Provide a minimal, runtime-safe fix in CompareTableView so comparisons are correct regardless of whether products contain snake_case or camelCase runtime fields.

Description

  • Added runtime-safe accessors getMinQuantity, getStockStatus and isKitProduct that read either the snake_case or camelCase variant of fields on Product.
  • Replaced direct field reads in the comparison rows with the accessors for minimum quantity, total cost (TCO), lead-time proxy, stock status label and kit indicator so UI renders correct values for both shapes.
  • Small component/JSX cleanups and formatting adjustments to keep rendering and styles consistent (no behavior changes beyond the field mapping fix).

Testing

  • Ran npx eslint src/components/compare/CompareTableView.tsx and pre-commit formatting hooks (prettier + eslint --fix) — all completed successfully.
  • No additional unit/typecheck failures were observed for the modified file in local lint/format checks.

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.

  • Bug Fixes
    • Added runtime-safe accessors to read min_quantity/minQuantity, stock_status/stockStatus, and is_kit/isKit.
    • Replaced direct field reads in CompareTableView so min qty, TCO, lead-time proxy/label, stock label, and kit indicator use the new accessors.
    • Minor JSX/style cleanups with no behavioral changes beyond the field mapping fix.

Written for commit 06064a5. Summary will update on new commits. Review in cubic

Copilot AI review requested due to automatic review settings May 23, 2026 23:46
@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
we-dream-big Ready Ready Preview, Comment May 23, 2026 11:47pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e19f7dbd-3108-4d35-a18a-1d7685b581eb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-high-priority-bug-in-comparetableview

Comment @coderabbitai help to get the list of available commands and usage tips.

@supabase
Copy link
Copy Markdown

supabase Bot commented May 23, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and is_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.

Comment on lines 121 to +126
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('|'))),
Comment on lines +24 to +27
import { StockRiskBadge } from './StockRiskBadge';
import { OtherSuppliersRow } from './OtherSuppliersRow';
import type { CompareVariantInfo } from '@/stores/useComparisonStore';
import type { Product } from '@/types/product';
@adm01-debug adm01-debug merged commit fbdfca4 into claude/tsc-baseline-etapas-9-13 May 23, 2026
10 checks passed
@adm01-debug adm01-debug deleted the codex/fix-high-priority-bug-in-comparetableview branch May 23, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants