import { Button } from 'react-bootstrap'
import styles from '@/styles/logger.module.css'
import { useWalletLogs, useDeleteWalletLogs } from '@/wallets/client/hooks'
import { useCallback, useEffect, useState, Fragment } from 'react'
import { timeSince } from '@/lib/time'
import classNames from 'classnames'
import { ModalClosedError } from '@/components/modal'
// TODO(wallet-v2):
// when we delete logs for a protocol, the cache is not updated
// so when we go to all wallet logs, we still see the deleted logs until the query is refetched
export function WalletLogs ({ protocol, className, debug }) {
const { logs, loadMore, hasMore, loading, clearLogs } = useWalletLogs(protocol, debug)
const deleteLogs = useDeleteWalletLogs(protocol, debug)
const onDelete = useCallback(async () => {
try {
await deleteLogs()
clearLogs()
} catch (err) {
if (err instanceof ModalClosedError) {
return
}
console.error('error deleting logs:', err)
}
}, [deleteLogs, clearLogs])
const embedded = !!protocol
return (
<>