Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

838 B
Raw Blame
'use client'

import { useEffect } from 'react'
import {
  getAnalyticsConsentFromCookie,
  getAnalyticsConsentFromEvent,
  setAnalyticsConsent,
} from './consent-store'

export const COOKIEYES_CONSENT_UPDATE_EVENT = 'cookieyes_consent_update'

export function CookieYesConsentBridge() {
  useEffect(() => {
    setAnalyticsConsent(getAnalyticsConsentFromCookie(document.cookie))

    const handleConsentUpdate = (event: Event) => {
      if (!(event instanceof CustomEvent)) return

      const nextConsent = getAnalyticsConsentFromEvent(event.detail)
      if (nextConsent) setAnalyticsConsent(nextConsent)
    }

    document.addEventListener(COOKIEYES_CONSENT_UPDATE_EVENT, handleConsentUpdate)
    return () => {
      document.removeEventListener(COOKIEYES_CONSENT_UPDATE_EVENT, handleConsentUpdate)
    }
  }, [])

  return null
}