mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
fix: multi-tariff filter shows all users when >1 tariffs selected
Server only supports single tariff_id filter. When multiple tariffs are selected, apply client-side filtering to hide users who have no subscriptions matching any of the selected tariffs.
This commit is contained in:
@@ -1977,8 +1977,18 @@ export default function AdminBulkActions() {
|
|||||||
[t, formatWithCurrency, expandedRows, toggleExpandRow, getFilteredSubs],
|
[t, formatWithCurrency, expandedRows, toggleExpandRow, getFilteredSubs],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// When multiple tariffs are selected, filter users client-side
|
||||||
|
// (server only supports single tariff_id filter)
|
||||||
|
const filteredUsers = useMemo(() => {
|
||||||
|
if (tariffFilter.length <= 1) return users;
|
||||||
|
return users.filter((u) => {
|
||||||
|
const subs = u.subscriptions ?? [];
|
||||||
|
return subs.some((s) => s.tariff_id !== null && tariffFilter.includes(s.tariff_id));
|
||||||
|
});
|
||||||
|
}, [users, tariffFilter]);
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data: users,
|
data: filteredUsers,
|
||||||
columns,
|
columns,
|
||||||
state: { rowSelection },
|
state: { rowSelection },
|
||||||
onRowSelectionChange: setRowSelection,
|
onRowSelectionChange: setRowSelection,
|
||||||
|
|||||||
Reference in New Issue
Block a user