Skip to content

fix: hide 0 discount, show items col, fix custom rate step#838

Open
santipalenque wants to merge 1 commit intomasterfrom
fix/sponsor-cart-qa-fixes
Open

fix: hide 0 discount, show items col, fix custom rate step#838
santipalenque wants to merge 1 commit intomasterfrom
fix/sponsor-cart-qa-fixes

Conversation

@santipalenque
Copy link

@santipalenque santipalenque commented Mar 24, 2026

https://app.clickup.com/t/86b90w3cw
https://app.clickup.com/t/86b90we8p
https://app.clickup.com/t/86b916bzq

Summary by CodeRabbit

  • New Features

    • Added an item count column to cart tables for improved visibility of cart contents.
  • Improvements

    • Enhanced custom rate field to support finer-grained adjustments with smaller increment steps.
    • Improved discount display by removing zero percent values from being shown.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

Updated numeric input precision for custom rate fields from whole numbers to two decimal places, added item count display to sponsor cart table with discount normalization, and enhanced cart reducer to track item quantities with singular/plural formatting.

Changes

Cohort / File(s) Summary
Numeric Input Precision
src/components/mui/FormItemTable/index.js
Changed custom_rate field step from 1 to 0.01 to allow finer-grained price adjustments.
Sponsor Cart Display & Data
src/pages/sponsors/sponsor-cart-tab/components/cart-view.js, src/reducers/sponsors/sponsor-page-cart-list-reducer.js
Introduced item_count field to cart forms with singular/plural labeling, normalized discount display (converting "0%" to empty string), and added corresponding table column for item visibility.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • smarcet

Poem

🐰 A hop through the decimals, prices align,
Item counts bloom where the cart numbers shine,
Discounts fade clean when they're zero, you see,
Precision and clarity—what could more be!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the three main changes: hiding 0% discount display, showing the items count column, and adjusting the custom rate increment step value.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 fix/sponsor-cart-qa-fixes

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

Copy link

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/reducers/sponsors/sponsor-page-cart-list-reducer.js (1)

54-57: ⚠️ Potential issue | 🟡 Minor

Inconsistent singular/plural handling compared to RECEIVE_SPONSOR_CART.

The mapForm function always uses "items" (plural), but RECEIVE_SPONSOR_CART at lines 92-94 correctly handles singular/plural. This will display "1 items" instead of "1 item" when there's exactly one item in RECEIVE_CART_AVAILABLE_FORMS.

Proposed fix
 const mapForm = (formData) => ({
   ...formData,
-  item_count: `${formData.items.length} items`
+  item_count: `${formData.items.length} ${formData.items.length === 1 ? "item" : "items"}`
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/reducers/sponsors/sponsor-page-cart-list-reducer.js` around lines 54 -
57, mapForm currently always sets item_count to `${formData.items.length}
items`, causing "1 items"; update mapForm to mirror the pluralization logic used
in RECEIVE_SPONSOR_CART/RECEIVE_CART_AVAILABLE_FORMS by computing const count =
formData.items.length and using `${count} ${count === 1 ? 'item' : 'items'}` for
item_count so singular/plural is correct.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/pages/sponsors/sponsor-cart-tab/components/cart-view.js`:
- Around line 86-89: cartData computation uses cart?.forms.map(...) which will
throw if cart exists but cart.forms is null/undefined; update the expression in
cartData (the cart?.forms.map call) to safely handle missing forms (e.g., guard
with cart?.forms?.map or default to an empty array before mapping) and keep the
same mapping logic that normalizes discount values (the discount field
transformation for each form).

---

Outside diff comments:
In `@src/reducers/sponsors/sponsor-page-cart-list-reducer.js`:
- Around line 54-57: mapForm currently always sets item_count to
`${formData.items.length} items`, causing "1 items"; update mapForm to mirror
the pluralization logic used in
RECEIVE_SPONSOR_CART/RECEIVE_CART_AVAILABLE_FORMS by computing const count =
formData.items.length and using `${count} ${count === 1 ? 'item' : 'items'}` for
item_count so singular/plural is correct.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ac53825-4b4c-4c34-baf4-56c50b2f90ad

📥 Commits

Reviewing files that changed from the base of the PR and between a90c64b and eaa49b0.

📒 Files selected for processing (3)
  • src/components/mui/FormItemTable/index.js
  • src/pages/sponsors/sponsor-cart-tab/components/cart-view.js
  • src/reducers/sponsors/sponsor-page-cart-list-reducer.js

Comment on lines +86 to +89
const cartData = cart?.forms.map((form) => ({
...form,
discount: form.discount === "0%" ? "" : form.discount
}));
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Potential runtime error if cart.forms is undefined.

cart?.forms.map(...) will throw if cart exists but cart.forms is undefined or null. Consider using optional chaining on forms as well.

Proposed fix
-  const cartData = cart?.forms.map((form) => ({
+  const cartData = cart?.forms?.map((form) => ({
     ...form,
     discount: form.discount === "0%" ? "" : form.discount
-  }));
+  })) ?? [];
📝 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 cartData = cart?.forms.map((form) => ({
...form,
discount: form.discount === "0%" ? "" : form.discount
}));
const cartData = cart?.forms?.map((form) => ({
...form,
discount: form.discount === "0%" ? "" : form.discount
})) ?? [];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors/sponsor-cart-tab/components/cart-view.js` around lines 86
- 89, cartData computation uses cart?.forms.map(...) which will throw if cart
exists but cart.forms is null/undefined; update the expression in cartData (the
cart?.forms.map call) to safely handle missing forms (e.g., guard with
cart?.forms?.map or default to an empty array before mapping) and keep the same
mapping logic that normalizes discount values (the discount field transformation
for each form).

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