import getMeta from '@/utils/meta'
import { Trans, useTranslation } from 'react-i18next'
import { memo, useCallback, useEffect } from 'react'
import { useDetachCompileContext } from '@/shared/context/detach-compile-context'
import StartFreeTrialButton from '@/shared/components/start-free-trial-button'
import MaterialIcon from '@/shared/components/material-icon'
import { useStopOnFirstError } from '@/shared/hooks/use-stop-on-first-error'
import * as eventTracking from '@/infrastructure/event-tracking'
import PdfLogEntry from './pdf-log-entry'
function TimeoutMessageAfterPaywallDismissal() {
const {
startCompile,
lastCompileOptions,
setAnimateCompileDropdownArrow,
isProjectOwner,
} = useDetachCompileContext()
const { enableStopOnFirstError } = useStopOnFirstError({
eventSource: 'timeout-new',
})
const handleEnableStopOnFirstErrorClick = useCallback(() => {
enableStopOnFirstError()
startCompile({ stopOnFirstError: true })
setAnimateCompileDropdownArrow(true)
}, [enableStopOnFirstError, startCompile, setAnimateCompileDropdownArrow])
return (
{getMeta('ol-ExposedSettings').enableSubscriptions && (
)}
)
}
type CompileTimeoutProps = {
isProjectOwner: boolean
}
const CompileTimeout = memo(function CompileTimeout({
isProjectOwner,
}: CompileTimeoutProps) {
const { t } = useTranslation()
useEffect(() => {
eventTracking.sendMB('paywall-prompt', {
'paywall-type': 'compile-timeout',
'paywall-version': 'secondary',
})
}, [])
function onPaywallClick() {
eventTracking.sendMB('paywall-click', {
'paywall-type': 'compile-timeout',
'paywall-version': 'secondary',
})
}
return (
}
formattedContent={
getMeta('ol-ExposedSettings').enableSubscriptions && (
<>
{isProjectOwner ? (
{t('your_project_need_more_time_to_compile')}
{t('upgrade_to_unlock_more_time')}
) : (
{t('this_project_need_more_time_to_compile')}
{t('upgrade_to_unlock_more_time')}
)}
{isProjectOwner === false && (
,
]}
/>
)}
{isProjectOwner && (
{t('try_for_free')}
)}
>
)
}
// @ts-ignore
entryAriaLabel={t('your_compile_timed_out')}
level="error"
/>
)
})
type PreventTimeoutHelpMessageProps = {
lastCompileOptions: any
handleEnableStopOnFirstErrorClick: () => void
isProjectOwner: boolean
}
const PreventTimeoutHelpMessage = memo(function PreventTimeoutHelpMessage({
lastCompileOptions,
handleEnableStopOnFirstErrorClick,
isProjectOwner,
}: PreventTimeoutHelpMessageProps) {
const { t } = useTranslation()
return (
-
{t('large_or_high_resolution_images_taking_too_long_to_process')}
-
,
]}
/>
{!lastCompileOptions.stopOnFirstError && (
<>
{' '}
,
// eslint-disable-next-line react/jsx-key
,
]}
/>{' '}
>
)}
,
]}
/>
>
}
// @ts-ignore
entryAriaLabel={t('reasons_for_compile_timeouts')}
level="raw"
/>
)
})
export default memo(TimeoutMessageAfterPaywallDismissal)