import { useState, useMemo } from 'react' import { CheckSquare, Square, MinusSquare } from 'lucide-react' import type { CheckedAccount } from '../../types' import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, StatusBadge, Button, } from '../common' import { maskEmail, maskToken } from '../../utils/format' interface AccountTableProps { accounts: CheckedAccount[] selectedIds: number[] onSelectionChange: (ids: number[]) => void disabled?: boolean } export default function AccountTable({ accounts, selectedIds, onSelectionChange, disabled = false, }: AccountTableProps) { const [showTokens, setShowTokens] = useState(false) const activeAccounts = useMemo( () => accounts.filter((acc) => acc.status === 'active'), [accounts] ) const allSelected = selectedIds.length === accounts.length && accounts.length > 0 const someSelected = selectedIds.length > 0 && selectedIds.length < accounts.length const activeSelected = activeAccounts.every((acc) => selectedIds.includes(acc.id)) const handleSelectAll = () => { if (allSelected) { onSelectionChange([]) } else { onSelectionChange(accounts.map((acc) => acc.id)) } } const handleSelectActive = () => { onSelectionChange(activeAccounts.map((acc) => acc.id)) } const handleSelectNone = () => { onSelectionChange([]) } const handleToggle = (id: number) => { if (selectedIds.includes(id)) { onSelectionChange(selectedIds.filter((i) => i !== id)) } else { onSelectionChange([...selectedIds, id]) } } if (accounts.length === 0) { return null } return (