Scrum4Me/components/shared/set-current-product.tsx
Madhura68 29ed4f2773 feat: show active product name in navbar, links to product page
Sub-layout sets product in Zustand store; NavBar reads it.
getAccessibleProduct wrapped with React cache to avoid double DB call.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 17:56:50 +02:00

15 lines
423 B
TypeScript

'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 null
}