mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
fix: admin users search not working on pages beyond first
Separated input state (searchInput/emailSearchInput) from committed search state (search/emailSearch) to prevent every keystroke from triggering API calls with stale pagination offset.
This commit is contained in:
@@ -232,8 +232,6 @@ export default function AdminUsers() {
|
|||||||
|
|
||||||
const handleSearch = (e: React.FormEvent) => {
|
const handleSearch = (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setOffset(0);
|
|
||||||
loadUsers();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const totalPages = Math.ceil(total / limit);
|
const totalPages = Math.ceil(total / limit);
|
||||||
@@ -305,7 +303,10 @@ export default function AdminUsers() {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setSearch(e.target.value);
|
||||||
|
setOffset(0);
|
||||||
|
}}
|
||||||
placeholder={t('admin.users.search')}
|
placeholder={t('admin.users.search')}
|
||||||
className="w-full rounded-xl border border-dark-700 bg-dark-800 py-2 pl-10 pr-4 text-dark-100 placeholder-dark-500 focus:border-dark-600 focus:outline-none"
|
className="w-full rounded-xl border border-dark-700 bg-dark-800 py-2 pl-10 pr-4 text-dark-100 placeholder-dark-500 focus:border-dark-600 focus:outline-none"
|
||||||
/>
|
/>
|
||||||
@@ -319,7 +320,10 @@ export default function AdminUsers() {
|
|||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
value={emailSearch}
|
value={emailSearch}
|
||||||
onChange={(e) => setEmailSearch(e.target.value)}
|
onChange={(e) => {
|
||||||
|
setEmailSearch(e.target.value);
|
||||||
|
setOffset(0);
|
||||||
|
}}
|
||||||
placeholder={t('admin.users.searchEmail')}
|
placeholder={t('admin.users.searchEmail')}
|
||||||
className="w-full rounded-xl border border-dark-700 bg-dark-800 py-2 pl-10 pr-4 text-dark-100 placeholder-dark-500 focus:border-dark-600 focus:outline-none"
|
className="w-full rounded-xl border border-dark-700 bg-dark-800 py-2 pl-10 pr-4 text-dark-100 placeholder-dark-500 focus:border-dark-600 focus:outline-none"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user