// components/FacebookPixel.js
"use client";

import { usePathname } from 'next/navigation'
import { useEffect } from 'react'

export const FB_PIXEL_ID = '707529750730580'

const FacebookPixel = () => {
  const pathname = usePathname()

  useEffect(() => {
    // Dynamic import with error handling
    import('react-facebook-pixel')
      .then((module) => {
        const ReactPixel = module.default
        ReactPixel.init(FB_PIXEL_ID)
        ReactPixel.pageView()
      })
      .catch((error) => {
        console.error('Facebook Pixel failed to load:', error)
      })
  }, [pathname])

  return null
}

export default FacebookPixel