Skip to content

Feature: new sponsor cart grid - #278

Merged
smarcet merged 14 commits into
mainfrom
feature/new-sponsor-cart-grid
Jul 10, 2026
Merged

Feature: new sponsor cart grid#278
smarcet merged 14 commits into
mainfrom
feature/new-sponsor-cart-grid

Conversation

@santipalenque

@santipalenque santipalenque commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

https://app.clickup.com/t/9014802374/86ban7rdx

Summary by CodeRabbit

  • New Features
    • Added expandable row details in the form table with an info/status indicator, inline notes, and a “Details” label.
  • Bug Fixes
    • Row expansion and indicator state now follow Formik validation (touched/errors) instead of separate notes/settings callbacks.
  • Improvements
    • Enhanced form inputs: required “*” markers, better label/slotProps handling, improved dropdown value coercion, and configurable checkbox margin.
  • Tests
    • Updated and expanded test coverage for expansion/details and validation-driven behavior.
  • Chores
    • Bumped the beta package version.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds expandable detail rows to FormItemTable, updates related field rendering and tests, extends several Formik inputs with required and slot prop support, and bumps the package version.

Changes

FormItemTable expandable rows refactor

Layer / File(s) Summary
Quantity driver logic
src/components/mui/FormItemTable/helpers.js, src/components/mui/FormItemTable/components/GlobalQuantityField.js, src/components/mui/FormItemTable/__tests__/GlobalQuantityField.test.js, src/components/mui/FormItemTable/__tests__/helpers.test.js
Adds a driving-quantity helper and uses it to control quantity read-only state and Formik updates.
Item field rendering updates
src/components/mui/FormItemTable/components/ItemTableField.js
Derives required state from field metadata, updates label shrinking, and coerces list option values to strings for several field types.
Expandable row content
src/components/mui/FormItemTable/components/ExpandedRowContent.js
Renders extra columns, item-specific meta fields, and an inline notes field inside a grid layout.
FormItemTable expansion flow and exports
src/components/mui/FormItemTable/index.js, src/components/index.js, src/i18n/en.json
Adds open row state, validation-driven expansion, details icon state, a collapse-based details column, a named export for ExpandedRowContent, and a new Details translation key.
FormItemTable tests
src/components/mui/FormItemTable/__tests__/FormItemTable.test.js
Removes notes/settings callback wiring and updates assertions to cover details icons, row expansion, validation-driven auto-expand behavior, and inline notes rendering.

Formik input prop support

Layer / File(s) Summary
Checkbox, select, datepicker, and timepicker props
src/components/mui/formik-inputs/mui-formik-checkbox.js, src/components/mui/formik-inputs/mui-formik-select-v2.js, src/components/mui/formik-inputs/mui-formik-datepicker.js, src/components/mui/formik-inputs/mui-formik-timepicker.js
Adds configurable checkbox margin, required support for select v2, and required-aware label rendering plus slot prop merging for the datepicker and timepicker.

Release version bump

Layer / File(s) Summary
Package version
package.json
Updates the package version field.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: smarcet

🚥 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 is concise and accurately describes the main change: introducing the new sponsor cart grid feature.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/new-sponsor-cart-grid

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/components/mui/formik-inputs/mui-formik-checkbox.js (1)

24-30: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Checkbox has no visual required indicator, unlike its sibling inputs in this PR.

MuiFormikSelectV2 shows required via FormControl required (asterisk through context), and MuiFormikDatepicker/MuiFormikTimepicker append " *" to the label when required is true. Here, required just flows through ...props onto <Checkbox> (valid HTML attribute, no visual effect), and FormControlLabel doesn't support a required prop, so a required checkbox field (e.g. ItemTableField's CheckBox case) renders with no required cue at all.

💡 Suggested fix for parity with sibling inputs
-const MuiFormikCheckbox = ({ name, label, margin = "normal", ...props }) => {
+const MuiFormikCheckbox = ({ name, label, margin = "normal", required, ...props }) => {
   const [field, meta] = useField({ name, type: "checkbox" });
+  const displayLabel = required ? `${label} *` : label;

   return (
     <FormControl
       fullWidth
       margin={margin}
       error={meta.touched && Boolean(meta.error)}
     >
       <FormControlLabel
         control={
           <Checkbox
             name={name}
             {...field}
             checked={field.value}
+            required={required}
             // eslint-disable-next-line react/jsx-props-no-spreading
             {...props}
           />
         }
-        label={label}
+        label={displayLabel}
       />
🤖 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/formik-inputs/mui-formik-checkbox.js` around lines 24 -
30, The required state is not rendered visually for MuiFormikCheckbox because
the `required` prop is only passed through `...props` to `<Checkbox>` and
`FormControlLabel` does not display it. Update `MuiFormikCheckbox` so the label
or container reflects `required` the same way as `MuiFormikSelectV2` and the
date/time pickers do, using the `required` prop from the component props and
ensuring the `ItemTableField` checkbox case shows a visible required cue.
🤖 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.

Nitpick comments:
In `@src/components/mui/formik-inputs/mui-formik-checkbox.js`:
- Around line 24-30: The required state is not rendered visually for
MuiFormikCheckbox because the `required` prop is only passed through `...props`
to `<Checkbox>` and `FormControlLabel` does not display it. Update
`MuiFormikCheckbox` so the label or container reflects `required` the same way
as `MuiFormikSelectV2` and the date/time pickers do, using the `required` prop
from the component props and ensuring the `ItemTableField` checkbox case shows a
visible required cue.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 23ae8d9a-8b61-4627-a054-626803fd0f1c

📥 Commits

Reviewing files that changed from the base of the PR and between 8f682d6 and c13f284.

📒 Files selected for processing (11)
  • package.json
  • src/components/index.js
  • src/components/mui/FormItemTable/__tests__/FormItemTable.test.js
  • src/components/mui/FormItemTable/components/ExpandedRowContent.js
  • src/components/mui/FormItemTable/components/ItemTableField.js
  • src/components/mui/FormItemTable/index.js
  • src/components/mui/formik-inputs/mui-formik-checkbox.js
  • src/components/mui/formik-inputs/mui-formik-datepicker.js
  • src/components/mui/formik-inputs/mui-formik-select-v2.js
  • src/components/mui/formik-inputs/mui-formik-timepicker.js
  • src/i18n/en.json

Comment thread src/components/mui/FormItemTable/index.js
Comment thread src/components/mui/FormItemTable/index.js Outdated
Comment thread src/components/mui/FormItemTable/__tests__/FormItemTable.test.js

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an expandable “Details” experience to the sponsor cart FormItemTable, moving per-item meta fields and notes into a collapsible row area and updating several Formik/MUI input wrappers to better support required indicators and label behavior.

Changes:

  • Introduces per-row expand/collapse UI with a new “Details” column and expanded-row content container.
  • Improves form field rendering for required state and label shrinking across select/date/time/checkbox inputs.
  • Updates i18n strings, exports, tests, and bumps package version.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/i18n/en.json Adds “Details” translation key for the new table column.
src/components/mui/FormItemTable/index.js Reworks table layout to support expandable rows and details status icon; updates props to use touched/errors.
src/components/mui/FormItemTable/components/ItemTableField.js Enhances per-field props (required/shrink) and normalizes option values to strings.
src/components/mui/FormItemTable/components/ExpandedRowContent.js New component rendering extra/meta fields + inline notes in the expanded area.
src/components/mui/FormItemTable/tests/FormItemTable.test.js Updates tests to reflect new table structure and details behavior.
src/components/mui/formik-inputs/mui-formik-timepicker.js Adds required label handling and allows external slotProps passthrough.
src/components/mui/formik-inputs/mui-formik-select-v2.js Adds required support and forces InputLabel to shrink.
src/components/mui/formik-inputs/mui-formik-datepicker.js Adds required label handling and external slotProps passthrough.
src/components/mui/formik-inputs/mui-formik-checkbox.js Makes checkbox margin configurable (supports compact layouts).
src/components/index.js Exposes ExpandedRowContent from the library entrypoint.
package.json Bumps package version to 5.0.38-beta.2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/mui/FormItemTable/index.js
Comment thread src/components/mui/FormItemTable/index.js Outdated
Comment thread src/components/mui/FormItemTable/index.js
Comment thread src/components/mui/FormItemTable/index.js
Comment thread src/components/mui/FormItemTable/components/ItemTableField.js
Comment thread src/components/mui/FormItemTable/__tests__/FormItemTable.test.js

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@santipalenque please review

@santipalenque

Copy link
Copy Markdown
Contributor Author

done @smarcet

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (3)
src/components/mui/FormItemTable/index.js (3)

63-83: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard touched before indexing it.

Line 82 can throw when errors is populated but touched is still undefined/null. The component already treats touched as nullable elsewhere, so this path should too.

Proposed fix
   useEffect(() => {
-    if (!errors || Object.keys(errors).length === 0) return;
+    if (!errors || !touched || Object.keys(errors).length === 0) return;
     setOpenRows((prev) => {
       const updates = {};
       data.forEach((row) => {
🤖 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/FormItemTable/index.js` around lines 63 - 83, The
`useEffect` in `FormItemTable` indexes `touched[key]` even though `touched` can
be null/undefined, which can throw when errors exist before touched is
initialized. Update the `hasVisibleError` check to guard `touched` before
reading from it, matching the nullable handling used elsewhere in this
component. Keep the fix local to the `useEffect` path that builds `expandedKeys`
and evaluates visible errors.

202-276: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Expose the controlled details state on both toggle buttons.

Both buttons toggle the details region, but Line 210 and Line 266 only provide a static label. Add aria-expanded and aria-controls so assistive tech can report the current state and target.

Proposed fix
             const disabled = !isItemAvailable(row, currentApplicableRate);
             const isOpen = !!openRows[row.form_item_id];
+            const detailsId = `form-item-${row.form_item_id}-details`;
...
                       size="small"
                       aria-label="Toggle row details"
+                      aria-expanded={isOpen}
+                      aria-controls={detailsId}
                       onClick={() => toggleRow(row.form_item_id)}
...
                       size="small"
                       aria-label="Toggle row details"
+                      aria-expanded={isOpen}
+                      aria-controls={detailsId}
                       onClick={() => toggleRow(row.form_item_id)}
...
-                  <TableCell colSpan={totalColumns} sx={{ padding: 0 }}>
+                  <TableCell id={detailsId} colSpan={totalColumns} sx={{ padding: 0 }}>
🤖 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/FormItemTable/index.js` around lines 202 - 276, The two
row toggle IconButton controls in FormItemTable currently only have a static
aria-label, so update both the expand/collapse button and the info button to
expose the controlled details state. Use the existing isOpen and
toggleRow(row.form_item_id) logic to add aria-expanded and a shared
aria-controls value that points to the corresponding ExpandedRowContent/Collapse
region, so assistive tech can announce the current state and target.

55-88: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include data in the auto-expand effect dependencies.

The effect builds expandedKeys from data/extraColumns, but only reruns on errors and touched. If rows change while validation state already exists, newly invalid rows can stay collapsed.

🤖 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/FormItemTable/index.js` around lines 55 - 88, The
auto-expand logic in the useEffect inside FormItemTable only depends on errors
and touched, but it also derives expandedKeys from data and extraColumns. Add
the missing data dependency (and anything derived from it if needed, such as
extraColumns) so the effect reruns when rows change and newly invalid rows are
opened correctly.
🤖 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.

Outside diff comments:
In `@src/components/mui/FormItemTable/index.js`:
- Around line 63-83: The `useEffect` in `FormItemTable` indexes `touched[key]`
even though `touched` can be null/undefined, which can throw when errors exist
before touched is initialized. Update the `hasVisibleError` check to guard
`touched` before reading from it, matching the nullable handling used elsewhere
in this component. Keep the fix local to the `useEffect` path that builds
`expandedKeys` and evaluates visible errors.
- Around line 202-276: The two row toggle IconButton controls in FormItemTable
currently only have a static aria-label, so update both the expand/collapse
button and the info button to expose the controlled details state. Use the
existing isOpen and toggleRow(row.form_item_id) logic to add aria-expanded and a
shared aria-controls value that points to the corresponding
ExpandedRowContent/Collapse region, so assistive tech can announce the current
state and target.
- Around line 55-88: The auto-expand logic in the useEffect inside FormItemTable
only depends on errors and touched, but it also derives expandedKeys from data
and extraColumns. Add the missing data dependency (and anything derived from it
if needed, such as extraColumns) so the effect reruns when rows change and newly
invalid rows are opened correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cd5e230e-e687-4869-8e45-14d2487f7cff

📥 Commits

Reviewing files that changed from the base of the PR and between c13f284 and 55c4841.

📒 Files selected for processing (3)
  • package.json
  • src/components/mui/FormItemTable/components/ItemTableField.js
  • src/components/mui/FormItemTable/index.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • src/components/mui/FormItemTable/components/ItemTableField.js

@smarcet
smarcet self-requested a review July 1, 2026 18:20
Comment thread src/components/mui/FormItemTable/index.js Outdated
@smarcet
smarcet self-requested a review July 1, 2026 19:23

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment thread src/components/mui/FormItemTable/index.js
Comment thread src/components/mui/FormItemTable/index.js Outdated
Comment thread src/components/mui/FormItemTable/components/ExpandedRowContent.js
@smarcet

smarcet commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

@santipalenque hasDrivingQuantityField locks the row's global quantity field (and defaults the row open) whenever it finds an Item-class metafield of type Quantity:

const hasItemLevel = (row.meta_fields ?? []).some(
  (mf) => mf.class_field === SPONSOR_FORMS_METAFIELD_CLASS.ITEM && mf.type === "Quantity"
);
return hasFormLevel || hasItemLevel;

But calculateQuantity in index.js only ever derives the computed value from extraColumns (Form-class fields) — it never reads Item-class fields, which I think is correct, since only Form-class quantities are meant to drive the row's quantity.

So for a row that has an Item-class Quantity field but no Form-class one, the global quantity input ends up forced readOnly/greyed out, nothing ever computes a value into it, and the user has no way to set it manually either — the row is stuck with whatever initialValues happened to provide.

Since only Form-class fields should drive the row quantity, I'd just drop the hasItemLevel branch from hasDrivingQuantityField so it matches what calculateQuantity actually does.

Could we add a regression test for this in helpers.test.js (there's no coverage for hasDrivingQuantityField at all right now)? Something like:

describe("hasDrivingQuantityField", () => {
  test("returns false for a row whose only Quantity field is Item-class", () => {
    const row = {
      form_item_id: 1,
      meta_fields: [
        { type_id: 1, class_field: "Item", type: "Quantity" }
      ]
    };
    expect(hasDrivingQuantityField(row, [])).toBe(false);
  });

  test("returns true when a Form-class Quantity field exists", () => {
    const row = { form_item_id: 1, meta_fields: [] };
    const extraColumns = [{ type_id: 1, class_field: "Form", type: "Quantity" }];
    expect(hasDrivingQuantityField(row, extraColumns)).toBe(true);
  });
});

(note: helpers.test.js currently mocks ../../../../utils/constants down to just MILLISECONDS_IN_SECOND, so the mock would need SPONSOR_FORMS_METAFIELD_CLASS: { FORM: "Form", ITEM: "Item" } added too for this to import cleanly.)

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@santipalenque
santipalenque force-pushed the feature/new-sponsor-cart-grid branch from 7b4c2b3 to da94665 Compare July 8, 2026 19:53
@smarcet
smarcet self-requested a review July 10, 2026 14:09

@smarcet smarcet left a comment

Copy link
Copy Markdown
Collaborator

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 89d513d into main Jul 10, 2026
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.

4 participants