Skip to content

Feature/add table extra rows#235

Open
santipalenque wants to merge 3 commits intomainfrom
feature/add-table-extra-rows
Open

Feature/add table extra rows#235
santipalenque wants to merge 3 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 discount row functionality to tables, displaying formatted currency amounts with localized labels and styling.
    • Enhanced table row components with optional configuration parameters for improved display flexibility.
  • Chores

    • Version bumped to 5.0.19-beta.1.
    • Expanded translation coverage for discount-related and table display labels.

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

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

This PR adds a new DiscountRow component to the Material-UI table system, enabling rendering of discount information within invoice/payment tables. The component is exported through the module hierarchy with accompanying i18n translations, and the existing NotesRow component is enhanced to support an optional code display label.

Changes

Discount Row Component & Integration

Layer / File(s) Summary
Core Component Implementation
src/components/mui/table/extra-rows/DiscountRow.jsx
New React component renders a styled table row displaying discount label, amount, and formatted total. Uses i18n keys mui_table.dis and mui_table.discount; conditionally skips rendering when discountTotal is zero.
Related Component Enhancement
src/components/mui/table/extra-rows/NotesRow.jsx
Adds optional showCode prop (default false) and i18n import; conditionally renders a translated label cell header when enabled, with dynamic column spanning.
Module Exports & Public API
src/components/mui/table/extra-rows/index.js, src/components/index.js
New DiscountRow export added to extra-rows barrel; re-exported as MuiDiscountRow in main components barrel alongside existing table row exports.
Internationalization
src/i18n/en.json
Four new translation keys added to mui_table object: dis, discount, amount_due, note.
Version Bump
package.json
Package version updated from 5.0.16 to 5.0.19-beta.1.

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly Related PRs

Suggested Reviewers

  • smarcet

Poem

🐰 A discount row hops into view,
With i18n magic and exports anew!
NotesRow flexes its showCode display,
Table components grow in a beta way. ✨

🚥 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.

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.

1 participant