fix: add missing per page change on sponsor form items#877
fix: add missing per page change on sponsor form items#877
Conversation
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
📝 WalkthroughWalkthroughThe 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
src/pages/sponsors-global/form-templates/form-template-item-list-page.jssrc/pages/sponsors/sponsor-form-item-list-page/index.jssrc/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/index.js
| const handlePerPageChange = (newPerPage) => { | ||
| getFormTemplateItems( | ||
| formTemplateId, | ||
| term, | ||
| DEFAULT_CURRENT_PAGE, | ||
| newPerPage, | ||
| order, | ||
| orderDir, | ||
| hideArchived | ||
| ); | ||
| }; |
There was a problem hiding this comment.
🧩 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/pagesRepository: 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 -20Repository: 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 -10Repository: fntechgit/summit-admin
Length of output: 268
🏁 Script executed:
cat -n src/actions/form-template-item-actions.js | head -50Repository: 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 -100Repository: 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 1Repository: fntechgit/summit-admin
Length of output: 329
🏁 Script executed:
rg -nP 'export.*getFormTemplateItems' src/actions/form-template-item-actions.js -A 30Repository: 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 5Repository: 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 2Repository: 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.jsRepository: 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.jsRepository: 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 2Repository: 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 1Repository: 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.jsRepository: 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 10Repository: 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 8Repository: 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.jsRepository: 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.jsRepository: 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).
ref: https://app.clickup.com/t/86b8bczw1
Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com
Summary by CodeRabbit
Release Notes