Skip to content

fix: add missing per page change on sponsor form items#877

Open
tomrndom wants to merge 1 commit intomasterfrom
fix/sponsor-form-items-per-page
Open

fix: add missing per page change on sponsor form items#877
tomrndom wants to merge 1 commit intomasterfrom
fix/sponsor-form-items-per-page

Conversation

@tomrndom
Copy link
Copy Markdown

@tomrndom tomrndom commented Apr 16, 2026

ref: https://app.clickup.com/t/86b8bczw1

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

Release Notes

  • New Features
    • Added per-page pagination controls to form templates and sponsor forms interfaces. Users can now customize how many items appear per page. When changing the page size, the view resets to the first page while preserving all active search filters, sorting preferences, and archive visibility settings.

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@tomrndom tomrndom requested a review from smarcet April 16, 2026 02:20
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

The PR adds per-page pagination change handlers to three pages managing sponsor forms and form templates. When users change the items-per-page setting, these handlers reset pagination to the first page and re-fetch the data with the new page size while preserving existing filters and sort parameters.

Changes

Cohort / File(s) Summary
Form Template Pagination Handler
src/pages/sponsors-global/form-templates/form-template-item-list-page.js
Added handlePerPageChange callback that resets pagination to DEFAULT_CURRENT_PAGE and re-fetches form template items with the new page size, preserving formTemplateId, term, order, orderDir, and hideArchived. Wired handler to MuiTable via onPerPageChange prop.
Sponsor Form Item List Pagination Handler
src/pages/sponsors/sponsor-form-item-list-page/index.js
Added handlePerPageChange callback that resets to DEFAULT_CURRENT_PAGE and re-fetches sponsor form items with the new perPage value, while preserving order, orderDir, and hideArchived filters. Connected handler to MuiTableEditable via onPerPageChange prop.
Sponsor Forms Tab Pagination Handlers
src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/index.js
Added separate per-page change handlers for customized and managed sponsor form tables (handleCustomizedPerPageChange and handleManagedPerPageChange). Both reset pagination to DEFAULT_CURRENT_PAGE and re-fetch with updated page size, preserving sort and hideArchived filters. Updated both MuiTable instances with corresponding onPerPageChange callbacks. Also reformatted handleSaveFormFromTemplate to multi-line arrow function syntax.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • smarcet
  • caseylocker

Poem

🐰 Per-page handlers hopping 'cross the pages,
Resetting counts through all the stages,
Filters preserved with utmost care,
Fresh data flows through the air!

🚥 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 describes the main change: adding per-page change handlers to sponsor form item components.
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-form-items-per-page

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

🤖 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-global/form-templates/form-template-item-list-page.js`:
- Around line 104-114: The handlePerPageChange handler passes newPerPage (a
string from MUI) directly into getFormTemplateItems causing type mismatches;
coerce newPerPage to a number before dispatching (e.g., parseInt/Number) and
pass that numeric value into getFormTemplateItems and as the rowsPerPage
equivalent so DEFAULT_CURRENT_PAGE, order, orderDir, and hideArchived calls
remain unchanged; update references in handlePerPageChange and any places that
consume its value to expect a Number (function: handlePerPageChange, call:
getFormTemplateItems).
🪄 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: 093e6518-1fe6-4981-9969-9ceb9e27d4a8

📥 Commits

Reviewing files that changed from the base of the PR and between 68ac5d1 and 230630c.

📒 Files selected for processing (3)
  • src/pages/sponsors-global/form-templates/form-template-item-list-page.js
  • src/pages/sponsors/sponsor-form-item-list-page/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/index.js

Comment on lines +104 to +114
const handlePerPageChange = (newPerPage) => {
getFormTemplateItems(
formTemplateId,
term,
DEFAULT_CURRENT_PAGE,
newPerPage,
order,
orderDir,
hideArchived
);
};
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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify callback source and current per-page handlers for potential string propagation.
rg -nP --type=js -C2 'handleChangeRowsPerPage\s*=\s*\(ev\)\s*=>\s*\{\s*onPerPageChange\(ev\.target\.value\)' src/components/mui
rg -nP --type=js -C2 'handlePerPageChange|handleManagedPerPageChange|handleCustomizedPerPageChange' src/pages

Repository: fntechgit/summit-admin

Length of output: 23932


🏁 Script executed:

cat -n src/components/mui/table/mui-table.js | sed -n '50,75p'

Repository: fntechgit/summit-admin

Length of output: 911


🏁 Script executed:

# Find the getFormTemplateItems action/reducer to see how perPage is used
rg -nP 'getFormTemplateItems|formTemplateItems' src --type=js -l | head -20

Repository: fntechgit/summit-admin

Length of output: 335


🏁 Script executed:

# Check action creators for form template items
fd -e js -p src | xargs grep -l "getFormTemplateItems" | head -10

Repository: fntechgit/summit-admin

Length of output: 268


🏁 Script executed:

cat -n src/actions/form-template-item-actions.js | head -50

Repository: fntechgit/summit-admin

Length of output: 2203


🏁 Script executed:

# Check how perPage is used in the reducer
cat -n src/reducers/sponsors_inventory/form-template-item-list-reducer.js | head -100

Repository: fntechgit/summit-admin

Length of output: 3524


🏁 Script executed:

# Search for API calls or functions that receive perPage to see if type matters
rg -nP 'perPage' src/actions/form-template-item-actions.js -A 3 -B 1

Repository: fntechgit/summit-admin

Length of output: 329


🏁 Script executed:

rg -nP 'export.*getFormTemplateItems' src/actions/form-template-item-actions.js -A 30

Repository: fntechgit/summit-admin

Length of output: 906


🏁 Script executed:

# Check how per_page is used in API calls across the codebase
rg -nP 'per_page' src/actions/form-template-item-actions.js -B 5 -A 5

Repository: fntechgit/summit-admin

Length of output: 352


🏁 Script executed:

# Check how perPage is used in the MUI table component
rg -nP 'perPage' src/components/mui/table/mui-table.js -B 2 -A 2

Repository: fntechgit/summit-admin

Length of output: 661


🏁 Script executed:

# Check if there are any arithmetic or comparison operations on perPage in the reducer or elsewhere
rg -nP 'perPage\s*[\+\-\*\/\%<>==!]|perPage\s*\?' src/reducers/sponsors_inventory/form-template-item-list-reducer.js

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

# Check the constants to confirm DEFAULT_PER_PAGE is numeric
rg -nP 'DEFAULT_PER_PAGE|TWENTY_PER_PAGE|FIFTY_PER_PAGE' src/utils/constants.js

Repository: fntechgit/summit-admin

Length of output: 179


🏁 Script executed:

# Check if there are any tests that verify the string-to-number handling
rg -nP 'handlePerPageChange|newPerPage' src/pages/sponsors-global/form-templates/__tests__/form-template-item-list-page.test.js -B 2 -A 2

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

# Verify the exact flow: check line 73-75 of mui-table.js more closely
cat -n src/components/mui/table/mui-table.js | sed -n '70,80p'

Repository: fntechgit/summit-admin

Length of output: 510


🏁 Script executed:

# Check if there's any type coercion happening in the reducer when storing perPage
cat -n src/reducers/sponsors_inventory/form-template-item-list-reducer.js | sed -n '42,68p'

Repository: fntechgit/summit-admin

Length of output: 839


🏁 Script executed:

# Check the actual TablePagination implementation to see if it expects numeric rowsPerPage
rg -nP 'rowsPerPage' src/components/mui/table/mui-table.js -B 1 -A 1

Repository: fntechgit/summit-admin

Length of output: 234


🏁 Script executed:

# Look for any normalization or parseInt/Number calls in similar handlers across the codebase
rg -nP 'Number\(|parseInt\(' src/pages/sponsors-global/form-templates/form-template-item-list-page.js

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

# Final verification: confirm the exact type that reaches perPage in reducer via payload
rg -nP 'REQUEST_FORM_TEMPLATE_ITEMS' src/actions/form-template-item-actions.js -B 5 -A 10

Repository: fntechgit/summit-admin

Length of output: 1694


🏁 Script executed:

# Verify that perPage is NOT included in the payload to the reducer
cat -n src/actions/form-template-item-actions.js | sed -n '112,121p'

Repository: fntechgit/summit-admin

Length of output: 505


🏁 Script executed:

# Check how the MUI TablePagination component behaves with string vs numeric rowsPerPage
rg -nP 'MuiTablePagination|TablePagination' src/components/mui/table/mui-table.js -B 2 -A 8

Repository: fntechgit/summit-admin

Length of output: 1436


🏁 Script executed:

# Check if there's any additional reducer action that updates perPage from the handler
rg -nP 'perPage' src/actions/form-template-item-actions.js

Repository: fntechgit/summit-admin

Length of output: 128


🏁 Script executed:

# Verify if perPage is passed in reducer payload by checking the createAction call
rg -nP 'createAction.*perPage|dispatch.*perPage' src/pages/sponsors-global/form-templates/form-template-item-list-page.js

Repository: fntechgit/summit-admin

Length of output: 48


Normalize newPerPage to a number before dispatching.

onPerPageChange receives ev.target.value from the MUI table callback, which is a string. Passing it directly causes type mismatches: the sort operation in mui-table.js (line 75) will fail when a string is added to a numeric array and sorted with arithmetic, and MUI's TablePagination component expects a numeric rowsPerPage prop.

Proposed patch
   const handlePerPageChange = (newPerPage) => {
+    const perPageValue = Number(newPerPage);
+    if (Number.isNaN(perPageValue)) return;
+
     getFormTemplateItems(
       formTemplateId,
       term,
       DEFAULT_CURRENT_PAGE,
-      newPerPage,
+      perPageValue,
       order,
       orderDir,
       hideArchived
     );
   };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors-global/form-templates/form-template-item-list-page.js`
around lines 104 - 114, The handlePerPageChange handler passes newPerPage (a
string from MUI) directly into getFormTemplateItems causing type mismatches;
coerce newPerPage to a number before dispatching (e.g., parseInt/Number) and
pass that numeric value into getFormTemplateItems and as the rowsPerPage
equivalent so DEFAULT_CURRENT_PAGE, order, orderDir, and hideArchived calls
remain unchanged; update references in handlePerPageChange and any places that
consume its value to expect a Number (function: handlePerPageChange, call:
getFormTemplateItems).

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