import { memo } from 'react'
import PropTypes from 'prop-types'
import { useTranslation } from 'react-i18next'
import PreviewLogsPaneMaxEntries from '../../preview/components/preview-logs-pane-max-entries'
import PdfLogEntry from './pdf-log-entry'
import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
const LOG_PREVIEW_LIMIT = 100
const pdfLogEntriesComponents = importOverleafModules('pdfLogEntriesComponents')
function PdfLogsEntries({ entries, hasErrors }) {
const { t } = useTranslation()
const { syncToEntry } = useDetachCompileContext()
const logEntries = entries.slice(0, LOG_PREVIEW_LIMIT)
return (
<>
{entries.length > LOG_PREVIEW_LIMIT && (
)}
{pdfLogEntriesComponents.map(
({ import: { default: Component }, path }) => (
)
)}
{logEntries.map((logEntry, index) => (
))}
>
)
}
PdfLogsEntries.propTypes = {
entries: PropTypes.arrayOf(PropTypes.object),
hasErrors: PropTypes.bool,
}
export default memo(PdfLogsEntries)