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>
This commit is contained in:
parent
bc91e3c169
commit
29ed4f2773
5 changed files with 69 additions and 2 deletions
13
stores/product-store.ts
Normal file
13
stores/product-store.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { create } from 'zustand'
|
||||
|
||||
interface ProductStore {
|
||||
currentProduct: { id: string; name: string } | null
|
||||
setCurrentProduct: (id: string, name: string) => void
|
||||
clearCurrentProduct: () => void
|
||||
}
|
||||
|
||||
export const useProductStore = create<ProductStore>((set) => ({
|
||||
currentProduct: null,
|
||||
setCurrentProduct: (id, name) => set({ currentProduct: { id, name } }),
|
||||
clearCurrentProduct: () => set({ currentProduct: null }),
|
||||
}))
|
||||
Loading…
Add table
Add a link
Reference in a new issue