import { useTranslation } from 'react-i18next'
import Icon from '../../../shared/components/icon'
import PropTypes from 'prop-types'
import { memo } from 'react'
export function PdfLogsButtonContent({
showLogs,
logEntries,
autoCompileLintingError,
}) {
const { t } = useTranslation()
if (showLogs) {
return (
<>
{t('view_pdf')}
>
)
}
if (autoCompileLintingError) {
return (
<>
{t('code_check_failed')}
>
)
}
const count = logEntries?.errors?.length || logEntries?.warnings?.length
if (!count) {
return (
<>
{t('view_logs')}
>
)
}
return (
<>
{logEntries.errors?.length
? t('your_project_has_an_error', { count })
: t('view_warning', { count })}
{count > 1 && ` (${count > 99 ? '99+' : count})`}
>
)
}
PdfLogsButtonContent.propTypes = {
autoCompileLintingError: PropTypes.bool,
showLogs: PropTypes.bool,
logEntries: PropTypes.object,
}
export default memo(PdfLogsButtonContent)