fix(sort-order): decouple sprint membership actions from sort_order

createSprintAction and addStoryToSprintAction no longer write sort_order
when adding stories to a sprint. sort_order is derived from code via
parseCodeNumber, so membership should only set sprint_id + status.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scrum4Me Agent 2026-05-14 16:06:43 +02:00
parent fec03dd257
commit 86692f8e31

View file

@ -440,7 +440,7 @@ export async function createSprintAction(_prevState: unknown, formData: FormData
...stories.map((s, i) =>
prisma.story.update({
where: { id: s.id },
data: { sprint_id: sprint.id, status: 'IN_SPRINT', sort_order: i + 1 },
data: { sprint_id: sprint.id, status: 'IN_SPRINT' },
}),
),
prisma.task.updateMany({
@ -531,14 +531,9 @@ export async function addStoryToSprintAction(sprintId: string, storyId: string)
if (!story) return { error: 'Story niet gevonden' }
if (story.product_id !== sprint.product_id) return { error: 'Story hoort niet bij deze Sprint' }
const last = await prisma.story.findFirst({
where: { sprint_id: sprintId },
orderBy: { sort_order: 'desc' },
})
await prisma.story.update({
where: { id: storyId },
data: { sprint_id: sprintId, status: 'IN_SPRINT', sort_order: (last?.sort_order ?? 0) + 1.0 },
data: { sprint_id: sprintId, status: 'IN_SPRINT' },
})
revalidatePath(`/products/${sprint.product_id}/sprint`)