fix: adjust props on get sponsor user request table function#792
fix: adjust props on get sponsor user request table function#792
Conversation
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
📝 WalkthroughWalkthroughThree internal call sites of the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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/pages/sponsors/sponsor-users-list-page/components/request-table.js (1)
30-34:⚠️ Potential issue | 🟠 MajorInconsistent
getRequests()call - missing arguments.This call to
getRequests()passes no arguments, while the other three call sites were updated to pass(null, term, page, perPage, order, orderDir). After a delete operation, this likely should refresh the current page with proper pagination state.🐛 Proposed fix to align with updated signature
const handleRequestDelete = (itemId) => { + const { currentPage, perPage, order, orderDir } = requests; onRequestDelete(itemId).then(() => { - getRequests(); + getRequests(null, term, currentPage, perPage, order, orderDir); }); };
🤖 Fix all issues with AI agents
In `@src/pages/sponsors/sponsor-users-list-page/components/request-table.js`:
- Around line 11-24: The deletion handler currently calls getRequests() with no
arguments which clears the current search/pagination/sort state; update the
deletion flow to call getRequests(null, term, requests.currentPage,
requests.perPage, requests.order, requests.orderDir) so it preserves the current
term and requests state (keep null for companyId as used in
handleRequestsPageChange/handlePerPageChange/handleRequestsSort) and ensure you
reference the existing requests and term variables when invoking getRequests.
| const handleRequestsPageChange = (page) => { | ||
| const { perPage, order, orderDir } = requests; | ||
| getRequests(term, page, perPage, order, orderDir); | ||
| getRequests(null, term, page, perPage, order, orderDir); | ||
| }; | ||
|
|
||
| const handlePerPageChange = (newPerPage) => { | ||
| const { order, orderDir } = requests; | ||
| getRequests(term, 1, newPerPage, order, orderDir); | ||
| getRequests(null, term, 1, newPerPage, order, orderDir); | ||
| }; | ||
|
|
||
| const handleRequestsSort = (key, dir) => { | ||
| const { currentPage, perPage } = requests; | ||
| getRequests(term, currentPage, perPage, key, dir); | ||
| getRequests(null, term, currentPage, perPage, key, dir); | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for getRequests function/action definition across the repository
echo "=== Searching for getRequests definition ==="
rg -n 'getRequests\s*=' --type js -A 3
echo ""
echo "=== Searching for getRequests as export ==="
rg -n 'export.*getRequests' --type js -B 2 -A 5
echo ""
echo "=== Checking the request-table.js file to see all getRequests calls ==="
cat -n src/pages/sponsors/sponsor-users-list-page/components/request-table.js | head -40
echo ""
echo "=== Searching for where request-table.js is used and how getRequests is passed ==="
rg -n 'request-table' --type js -A 5 -B 5 | head -50Repository: fntechgit/summit-admin
Length of output: 3185
🏁 Script executed:
#!/bin/bash
# Search for getSponsorUserRequests function definition
echo "=== Searching for getSponsorUserRequests definition ==="
rg -n 'getSponsorUserRequests' --type js -A 10
echo ""
echo "=== Check sponsor-users-actions.js file ==="
fd sponsor-users-actions --type js -exec cat -n {} \;Repository: fntechgit/summit-admin
Length of output: 11079
🏁 Script executed:
#!/bin/bash
# Get the full sponsor-users-actions.js to see the complete function signature and defaults
echo "=== Reading sponsor-users-actions.js around getSponsorUserRequests ==="
cat -n src/actions/sponsor-users-actions.js | sed -n '71,100p'
echo ""
echo "=== Checking for DEFAULT_CURRENT_PAGE and DEFAULT_PER_PAGE constants ==="
head -n 70 src/actions/sponsor-users-actions.js | grep -n "DEFAULT_"
echo ""
echo "=== Checking the parent component context around RequestTable ==="
cat -n src/pages/sponsors/sponsor-users-list-page/index.js | sed -n '32,120p'Repository: fntechgit/summit-admin
Length of output: 4231
Fix getRequests() call at line 32 to preserve search context after deletion.
After deleting a request, line 32 calls getRequests() with no arguments, which resets the search term, page, and sort order to defaults. This should pass the current term and pagination/sort state to maintain the user's search context:
getRequests(null, term, requests.currentPage, requests.perPage, requests.order, requests.orderDir);The null values passed at lines 13, 18, and 23 correctly match the function signature where companyId defaults to null.
🤖 Prompt for AI Agents
In `@src/pages/sponsors/sponsor-users-list-page/components/request-table.js`
around lines 11 - 24, The deletion handler currently calls getRequests() with no
arguments which clears the current search/pagination/sort state; update the
deletion flow to call getRequests(null, term, requests.currentPage,
requests.perPage, requests.order, requests.orderDir) so it preserves the current
term and requests state (keep null for companyId as used in
handleRequestsPageChange/handlePerPageChange/handleRequestsSort) and ensure you
reference the existing requests and term variables when invoking getRequests.
ref: https://app.clickup.com/t/86b82fgft
Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com
Summary by CodeRabbit
Release Notes
No user-facing changes in this release. This is a maintenance update to internal code structure with no impact on functionality or user experience.