dify/web/app/components/base/zendesk/index.tsx
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

36 lines
1.0 KiB
TypeScript

import { memo } from 'react'
import { IS_CE_EDITION, IS_PROD, ZENDESK_WIDGET_KEY } from '@/config'
import { headers } from '@/next/headers'
import Script from '@/next/script'
const Zendesk = async () => {
if (IS_CE_EDITION || !ZENDESK_WIDGET_KEY) return null
const nonce = IS_PROD ? ((await headers()).get('x-nonce') ?? '') : ''
/* v8 ignore next -- `nonce` is always a string (`''` or header value), so nullish fallback is unreachable in runtime. @preserve */
const scriptNonce = nonce ?? undefined
return (
<>
<Script
nonce={scriptNonce}
id="ze-snippet"
src={`https://static.zdassets.com/ekr/snippet.js?key=${ZENDESK_WIDGET_KEY}`}
data-testid="ze-snippet"
/>
<Script nonce={scriptNonce} id="ze-init" data-testid="ze-init">
{`
(function () {
window.addEventListener('load', function () {
if (window.zE)
window.zE('messenger', 'hide')
})
})()
`}
</Script>
</>
)
}
export default memo(Zendesk)