Voegt components/dialogs/product-dialog.tsx toe op basis van het entity-dialog-patroon. Gebruikt react-hook-form + zodResolver voor client-side validatie. Roept createProductAction/updateProductAction aan en werkt stores/products-store.ts optimistisch bij. Demo-modus disabled alle velden + submit-knop via DemoTooltip. 7 tests groen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
825 B
TypeScript
29 lines
825 B
TypeScript
import { create } from 'zustand'
|
|
|
|
export interface ProductSummary {
|
|
id: string
|
|
name: string
|
|
code: string | null
|
|
description: string | null
|
|
repo_url: string | null
|
|
definition_of_done: string
|
|
auto_pr: boolean
|
|
}
|
|
|
|
interface ProductsStore {
|
|
products: ProductSummary[]
|
|
setProducts: (products: ProductSummary[]) => void
|
|
addProduct: (product: ProductSummary) => void
|
|
updateProduct: (id: string, patch: Partial<ProductSummary>) => void
|
|
}
|
|
|
|
export const useProductsStore = create<ProductsStore>((set) => ({
|
|
products: [],
|
|
setProducts: (products) => set({ products }),
|
|
addProduct: (product) =>
|
|
set((state) => ({ products: [...state.products, product] })),
|
|
updateProduct: (id, patch) =>
|
|
set((state) => ({
|
|
products: state.products.map((p) => (p.id === id ? { ...p, ...patch } : p)),
|
|
})),
|
|
}))
|