Skip to content

Feature/add table extra rows#235

Merged
smarcet merged 4 commits intomainfrom
feature/add-table-extra-rows
May 7, 2026
Merged

Feature/add table extra rows#235
smarcet merged 4 commits intomainfrom
feature/add-table-extra-rows

Conversation

@santipalenque
Copy link
Copy Markdown
Contributor

@santipalenque santipalenque commented May 5, 2026

https://app.clickup.com/t/86b9nf8g0

Summary by CodeRabbit

  • New Features

    • Added a discount row to tables that shows localized labels and formatted currency amounts.
    • Table row components gain optional display options to better control layout (e.g., showing code/label columns).
  • Chores

    • Version bumped to 5.0.19-beta.1.
    • Added new translation keys for table/discout/amount/notes display.

@santipalenque santipalenque requested a review from smarcet May 5, 2026 22:16
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5040ce0f-71ae-4915-9e04-2bcb2ef9e3b4

📥 Commits

Reviewing files that changed from the base of the PR and between b3cbd2e and 776fdc6.

📒 Files selected for processing (1)
  • src/components/index.js

📝 Walkthrough

Walkthrough

Adds a new DiscountRow component (rendered in MUI tables), updates NotesRow to accept an optional showCode label, exposes DiscountRow through extra-rows and top-level component barrels, adds related i18n keys, and bumps package version to 5.0.19-beta.1.

Changes

Discount Row Component & Integration

Layer / File(s) Summary
Translations / Version
src/i18n/en.json, package.json
Adds mui_table keys dis, discount, amount_due, note; bumps package version to 5.0.19-beta.1.
File Header & Imports
src/components/mui/table/extra-rows/DiscountRow.jsx
New file header and imports (React, i18n, MUI TableRow/TableCell, Typography, currencyAmountFromCents).
Core Component Implementation
src/components/mui/table/extra-rows/DiscountRow.jsx
New DiscountRow component: signature ({ discount, discountTotal, colGap = 2, trailing = 0 }); returns null if discountTotal is 0; renders TableRow with label cells, discount value, and negative formatted total; exported as default.
Related Component Enhancement
src/components/mui/table/extra-rows/NotesRow.jsx
Imports T from i18n-react, adds showCode = false prop, conditionally renders a translated label cell and adjusts colSpan.
Module Exports & Public API
src/components/mui/table/extra-rows/index.js, src/components/index.js
Adds export { default as DiscountRow } from "./DiscountRow"; and re-exports it as MuiDiscountRow in the top-level components barrel.

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly Related PRs

Suggested Reviewers

  • smarcet

Poem

🐰 A discount row hops into view,
With T translating labels true,
NotesRow learned a showCode trick,
Exports wired and version bumped too. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feature/add table extra rows' directly and specifically describes the main change: adding new extra row components (DiscountRow and NotesRow updates) to the table components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add-table-extra-rows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/components/mui/table/extra-rows/DiscountRow.jsx (1)

15-15: ⚡ Quick win

Use the package entrypoint instead of the internal dist path.

Line 15 imports from i18n-react/dist/i18n-react, while other files in the codebase use i18n-react. The documented public entrypoint is the package root; the dist subdirectory is not a supported public API path and should not be relied upon.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/table/extra-rows/DiscountRow.jsx` at line 15, The import
in DiscountRow.jsx currently uses the internal path
"i18n-react/dist/i18n-react"; update the import statement that brings in T
(i.e., the current T import) to use the package entrypoint "i18n-react" instead
so the code relies on the public API rather than an internal dist path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/mui/table/extra-rows/DiscountRow.jsx`:
- Line 24: In DiscountRow.jsx, validate and normalize the discountTotal before
formatting/printing: replace the current lone check (discountTotal === 0) with a
guard that treats null/undefined/non-numeric values as “no discount” and only
continues for finite non-zero numbers (e.g., use Number.isFinite(discountTotal)
or coerce via Number and check isFinite), then format the safe numeric value
when rendering; update the initial early-return in the DiscountRow component and
the place where discountTotal is passed to the formatter so invalid values never
reach the formatting call.

In `@src/components/mui/table/extra-rows/NotesRow.jsx`:
- Line 21: colSpan can become 0/negative/NaN when showCode is true or colCount
is missing; clamp it to a minimum of 1 before passing to TableCell. Update the
computation of colSpan (the constant named colSpan) to coerce colCount to a
number and use Math.max(1, ...) — e.g., derive a numericColCount from colCount
(parseInt/Number with fallback) and then set colSpan = Math.max(1, showCode ?
numericColCount - 1 : numericColCount) so TableCell always receives a valid
span.

---

Nitpick comments:
In `@src/components/mui/table/extra-rows/DiscountRow.jsx`:
- Line 15: The import in DiscountRow.jsx currently uses the internal path
"i18n-react/dist/i18n-react"; update the import statement that brings in T
(i.e., the current T import) to use the package entrypoint "i18n-react" instead
so the code relies on the public API rather than an internal dist path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69446b1b-c6e8-43a2-bce3-735fc30788a5

📥 Commits

Reviewing files that changed from the base of the PR and between 61be5aa and b3cbd2e.

📒 Files selected for processing (6)
  • package.json
  • src/components/index.js
  • src/components/mui/table/extra-rows/DiscountRow.jsx
  • src/components/mui/table/extra-rows/NotesRow.jsx
  • src/components/mui/table/extra-rows/index.js
  • src/i18n/en.json


const DiscountRow = ({ discount, discountTotal, colGap = 2, trailing = 0 }) => {

if (discountTotal === 0) return null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard discountTotal before formatting to prevent invalid output.

At Line 24, only === 0 is checked. If discountTotal is undefined/null/non-numeric, Line 51 can render an invalid amount. Normalize and validate first.

Proposed fix
-  if (discountTotal === 0) return null;
+  const normalizedDiscountTotal = Number(discountTotal);
+  if (!Number.isFinite(normalizedDiscountTotal) || normalizedDiscountTotal === 0) return null;
...
-          -{currencyAmountFromCents(discountTotal)}
+          -{currencyAmountFromCents(normalizedDiscountTotal)}

Also applies to: 51-51

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/table/extra-rows/DiscountRow.jsx` at line 24, In
DiscountRow.jsx, validate and normalize the discountTotal before
formatting/printing: replace the current lone check (discountTotal === 0) with a
guard that treats null/undefined/non-numeric values as “no discount” and only
continues for finite non-zero numbers (e.g., use Number.isFinite(discountTotal)
or coerce via Number and check isFinite), then format the safe numeric value
when rendering; update the initial early-return in the DiscountRow component and
the place where discountTotal is passed to the formatter so invalid values never
reach the formatting call.


const NotesRow = ({ colCount, note }) => (
const NotesRow = ({ colCount, note, showCode = false }) => {
const colSpan = showCode ? colCount - 1 : colCount;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clamp colSpan to a valid minimum to avoid invalid table layout.

At Line 21, colSpan can become 0, negative, or NaN (e.g., showCode=true with low/missing colCount). Clamp to at least 1 before passing it to TableCell.

Proposed fix
-  const colSpan = showCode ? colCount - 1 : colCount;
+  const computedColSpan = showCode ? colCount - 1 : colCount;
+  const colSpan = Math.max(1, Number(computedColSpan) || 1);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const colSpan = showCode ? colCount - 1 : colCount;
const computedColSpan = showCode ? colCount - 1 : colCount;
const colSpan = Math.max(1, Number(computedColSpan) || 1);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/mui/table/extra-rows/NotesRow.jsx` at line 21, colSpan can
become 0/negative/NaN when showCode is true or colCount is missing; clamp it to
a minimum of 1 before passing to TableCell. Update the computation of colSpan
(the constant named colSpan) to coerce colCount to a number and use Math.max(1,
...) — e.g., derive a numericColCount from colCount (parseInt/Number with
fallback) and then set colSpan = Math.max(1, showCode ? numericColCount - 1 :
numericColCount) so TableCell always receives a valid span.

Copy link
Copy Markdown
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

LGTM

@smarcet smarcet merged commit df36dc5 into main May 7, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants