Repository navigation
Admin search - #409
Admin search#409TimPham622 wants to merge 3 commits into
Conversation
cb73e61 to
8613e4b
Compare
| totalPages, | ||
| }; | ||
| }; | ||
| const queryAllMembers = async () => { |
There was a problem hiding this comment.
Running findMany() without a limit fetches every single member from the database on every page load and sends the entire table to the client component in the HTML/RSC payload. As the member table grows over time, this will significantly degrade page load times and client-side memory usage.
| const page = parseInt(searchParams?.page || '1', 10); | ||
| const { members, totalPages } = await queryMembers(page); | ||
| const [{ members, totalPages }, allMembers] = await Promise.all([ | ||
| queryMembers(page), |
There was a problem hiding this comment.
queryMembers(page) is a subset of queryAllMembers(), so it's querying the database twice for overlapping records and serializing duplicate data.
| <div className="w-full border-4 border-black bg-white px-8 py-8 text-black md:px-12 md:py-12"> | ||
| <MemberForm members={members} /> | ||
| <MemberForm members={members} allMembers={allMembers} /> | ||
| <PaginationControls currentPage={page} totalPages={totalPages} /> |
There was a problem hiding this comment.
Since there is no member table on this page, PaginationControls now only paginates the initial blank-query dropdown in Autocomplete. As soon as a user starts typing, it searches allMembers regardless of the current page. This makes PaginationControls confusing and redundant.
|
|
||
| const getMemberStr = (member: Member) => `${member.email} - ${member.firstName} ${member.lastName}`; | ||
|
|
||
| const getMemberSearchStr = (member: Member) => |
There was a problem hiding this comment.
The only difference between getMemberSearchStr and getMemberStr is omitting " - ". Substring matching (.includes(query)) on getMemberStr already matches email, first name, and last name equally well without needing a separate search string formatter.
Description
Improve the member search on the admin panel
Changes Made
update search so that it covers all members, regardless of the current page
changed memberform to use the full list when searching
Related Issues
Fixes #408
Additional Notes
Add any other notes or screenshots that might be helpful for the reviewers.