feat: Todo altijd gekoppeld aan product backlog
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b541379964
commit
cb7eb36fbb
9 changed files with 128 additions and 46 deletions
|
|
@ -14,11 +14,20 @@ async function getSession() {
|
|||
export async function createTodoAction(_prevState: unknown, formData: FormData) {
|
||||
const session = await getSession()
|
||||
if (!session.userId) return { error: 'Niet ingelogd' }
|
||||
if (session.isDemo) return { error: 'Niet beschikbaar in demo-modus' }
|
||||
|
||||
const title = (formData.get('title') as string)?.trim()
|
||||
if (!title) return { error: 'Titel is verplicht' }
|
||||
const productId = (formData.get('productId') as string)?.trim()
|
||||
|
||||
await prisma.todo.create({ data: { user_id: session.userId, title } })
|
||||
if (!title) return { error: 'Titel is verplicht' }
|
||||
if (!productId) return { error: 'Product is verplicht' }
|
||||
|
||||
const product = await prisma.product.findFirst({
|
||||
where: { id: productId, user_id: session.userId, archived: false },
|
||||
})
|
||||
if (!product) return { error: 'Product niet gevonden' }
|
||||
|
||||
await prisma.todo.create({ data: { user_id: session.userId, product_id: productId, title } })
|
||||
revalidatePath('/todos')
|
||||
return { success: true }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue