fix: bulk actions frontend — selectedUserIds mapping, debounce cleanup

- Fix selectedUserIds: was mapping row keys as array indices instead
  of using them directly as user IDs (getRowId returns String(user.id))
- Add useEffect cleanup for search debounce timer on unmount
This commit is contained in:
Fringg
2026-04-24 04:24:33 +03:00
parent 1772d9632e
commit ebe9d9be48

View File

@@ -719,6 +719,11 @@ export default function AdminBulkActions() {
}, 400);
};
// Cleanup debounce on unmount
useEffect(() => {
return () => clearTimeout(searchTimerRef.current);
}, []);
const handleSearchSubmit = (e: React.FormEvent) => {
e.preventDefault();
clearTimeout(searchTimerRef.current);
@@ -753,9 +758,9 @@ export default function AdminBulkActions() {
const selectedUserIds = useMemo(() => {
return Object.keys(rowSelection)
.filter((k) => rowSelection[k])
.map((idx) => users[Number(idx)]?.id)
.filter(Boolean);
}, [rowSelection, users]);
.map(Number)
.filter((id) => id > 0);
}, [rowSelection]);
const handleOpenAction = (type: BulkActionType) => {
setModal({ open: true, action: type, loading: false, result: null });