'use client'

import { useEffect } from 'react'
import { useProductStore } from '@/stores/product-store'

export function SetCurrentProduct({ id, name }: { id: string; name: string }) {
  const { setCurrentProduct, clearCurrentProduct } = useProductStore()

  useEffect(() => {
    setCurrentProduct(id, name)
    return () => clearCurrentProduct()
  }, [id, name, setCurrentProduct, clearCurrentProduct])

  return <span data-debug-id="set-current-product" data-debug-label="SetCurrentProduct — shared/set-current-product.tsx" hidden />
}
