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,
codeCheckFailed,
}) {
const { t } = useTranslation()
if (showLogs) {
return (
<>
{t('view_pdf')}
>
)
}
if (codeCheckFailed) {
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 = {
codeCheckFailed: PropTypes.bool,
showLogs: PropTypes.bool,
logEntries: PropTypes.object,
}
export default memo(PdfLogsButtonContent)