import { useState } from 'react'
import { ChevronLeft, ChevronRight, Check, Copy, Play, Plus, Trash2 } from 'lucide-react'
import clsx from 'clsx'
export default function AccountsTable({
t,
accounts,
loadingAccounts,
testing,
testingAll,
batchProgress,
totalAccounts,
page,
pageSize,
totalPages,
resolveAccountIdentifier,
onTestAll,
onShowAddAccount,
onTestAccount,
onDeleteAccount,
onPrevPage,
onNextPage,
onPageSizeChange,
searchQuery,
onSearchChange,
}) {
const [copiedId, setCopiedId] = useState(null)
const copyId = (id) => {
navigator.clipboard.writeText(id).then(() => {
setCopiedId(id)
setTimeout(() => setCopiedId(null), 1500)
})
}
return (
{t('accountManager.accountsTitle')}
{t('accountManager.accountsDesc')}
{testingAll && batchProgress.total > 0 && (
{t('accountManager.testingAllAccounts')}
{batchProgress.current} / {batchProgress.total}
{batchProgress.results.length > 0 && (
{batchProgress.results.map((r, i) => (
{r.success ? '✓' : '✗'} {r.id}
))}
)}
)}
{loadingAccounts ? (
{t('actions.loading')}
) : accounts.length > 0 ? (
accounts.map((acc, i) => {
const id = resolveAccountIdentifier(acc)
return (
copyId(id)}
>
{id || '-'}
{copiedId === id
?
:
}
{acc.test_status === 'failed' ? t('accountManager.testStatusFailed') : (acc.test_status === 'ok' || acc.has_token) ? t('accountManager.sessionActive') : t('accountManager.reauthRequired')}
{acc.token_preview && (
{acc.token_preview}
)}
)
})
) : (
{searchQuery ? t('accountManager.searchNoResults') : t('accountManager.noAccounts')}
)}
{totalPages > 1 && (
{t('accountManager.pageInfo', { current: page, total: totalPages, count: totalAccounts })}
{page} / {totalPages}
)}
)
}