mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
31 lines
894 B
TypeScript
31 lines
894 B
TypeScript
import { useCallback, useEffect, useState } from 'react'
|
|
import AiPaywallNotification from '@/shared/components/ai-paywall-notification'
|
|
import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
|
|
import useEventListener from '@/shared/hooks/use-event-listener'
|
|
|
|
export default function ErrorAssistantAiPaywallNotification() {
|
|
const { showLogs } = useCompileContext()
|
|
const [hasTriggered, setHasTriggered] = useState(false)
|
|
|
|
useEventListener(
|
|
'aiAssist:showPaywall',
|
|
useCallback((event: CustomEvent<{ origin?: string }>) => {
|
|
if (event.detail?.origin === 'suggest-fix') {
|
|
setHasTriggered(true)
|
|
}
|
|
}, [])
|
|
)
|
|
|
|
useEffect(() => {
|
|
if (!showLogs) {
|
|
setHasTriggered(false)
|
|
}
|
|
}, [showLogs])
|
|
|
|
if (!hasTriggered) {
|
|
return null
|
|
}
|
|
|
|
return <AiPaywallNotification featureLocation="errorAssist" />
|
|
}
|