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