mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-09-14 00:33:10 +00:00
refactor(bulk-actions): extract FloatingActionBar + actionTargets
Second step in the AdminBulkActions decomp. Two new files: - actionTargets.ts (27 lines): SUBSCRIPTION_LEVEL_ACTIONS set + isSubscriptionLevelAction(). The classification is the source of truth shared between FloatingActionBar (renders two grouped menus when multi-tariff is on) and the parent page (gates selection-count semantics + the active-paid count in delete-subscription). - FloatingActionBar.tsx (304 lines): the bottom-dock selection toolbar. Pure presentational — parent owns selection state and supplies onAction (opens the modal with the picked action type) + onToggleAllSubscriptions. The full 11-item action config (icons + label keys + colour classes) lives inside the file as a private ActionConfig array. Parent now imports FloatingActionBar + isSubscriptionLevelAction from the new modules; the inline ActionConfig interface is gone. AdminBulkActions.tsx: 1819 → 1517 lines (-302). Cumulative across the 2-step admin decomp: 2539 → 1517 (-1022, -40%).
This commit is contained in:
27
src/components/admin/bulkActions/actionTargets.ts
Normal file
27
src/components/admin/bulkActions/actionTargets.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { BulkActionType } from '../../../api/adminBulkActions';
|
||||
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
// Bulk-action target classification.
|
||||
//
|
||||
// Some actions operate on user-rows (assign promo group, add balance,
|
||||
// delete user); others operate on individual subscription-rows
|
||||
// (extend, cancel, change tariff, etc.). The set below is the source
|
||||
// of truth shared between FloatingActionBar (renders two grouped
|
||||
// menus when multi-tariff is on) and the parent page (gates the
|
||||
// selection-count semantics and the active-paid count in delete).
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export const SUBSCRIPTION_LEVEL_ACTIONS: Set<BulkActionType> = new Set([
|
||||
'extend_subscription',
|
||||
'add_days',
|
||||
'cancel_subscription',
|
||||
'activate_subscription',
|
||||
'change_tariff',
|
||||
'add_traffic',
|
||||
'set_devices',
|
||||
'delete_subscription',
|
||||
]);
|
||||
|
||||
export function isSubscriptionLevelAction(action: BulkActionType): boolean {
|
||||
return SUBSCRIPTION_LEVEL_ACTIONS.has(action);
|
||||
}
|
||||
Reference in New Issue
Block a user