'use client' import { useState, useTransition } from 'react' import { toast } from 'sonner' import type { PrStrategy } from '@prisma/client' import { updatePrStrategyAction } from '@/actions/products' import { Select, SelectContent, SelectItem, SelectTrigger, } from '@/components/ui/select' import { debugProps } from '@/lib/debug' interface PrStrategySelectProps { productId: string initialValue: PrStrategy } const STRATEGY_LABELS: Record = { SPRINT: 'Per sprint — één PR voor de hele sprint, klaar voor review aan eind. Per task een eigen claude-sessie.', STORY: 'Per story — auto-merge na CI groen, één PR per story. Per task een eigen claude-sessie.', SPRINT_BATCH: 'Sprint batch — één claude-sessie voor de hele sprint, sneller en behoudt context. Vereist alle tasks in de product-hoofdrepo.', } const VALID_VALUES: ReadonlyArray = ['SPRINT', 'STORY', 'SPRINT_BATCH'] export function PrStrategySelect({ productId, initialValue }: PrStrategySelectProps) { const [value, setValue] = useState(initialValue) const [isPending, startTransition] = useTransition() function handleChange(next: string | null) { if (!next || !VALID_VALUES.includes(next as PrStrategy)) return if (next === value) return const previous = value setValue(next as PrStrategy) startTransition(async () => { const result = await updatePrStrategyAction(productId, next as PrStrategy) if ('error' in result && result.error) { setValue(previous) toast.error(typeof result.error === 'string' ? result.error : 'Opslaan mislukt') } }) } return (
) }