diff --git a/__tests__/api/backlog-realtime.test.ts b/__tests__/api/backlog-realtime.test.ts index 4898cda..f9d0bfe 100644 --- a/__tests__/api/backlog-realtime.test.ts +++ b/__tests__/api/backlog-realtime.test.ts @@ -110,13 +110,13 @@ describe('shouldEmit scope filter (via backlog-store reducer)', () => { it('applyChange: story INSERT adds to storiesByPbi', () => { useBacklogStore.setState({ pbis: [], storiesByPbi: { 'pbi-1': [] }, tasksByStory: {} }) - const story = { id: 'story-1', code: 'ST-1', title: 'S', description: null, acceptance_criteria: null, priority: 2, status: 'OPEN', pbi_id: 'pbi-1', created_at: new Date() } + const story = { id: 'story-1', code: 'ST-1', title: 'S', description: null, acceptance_criteria: null, priority: 2, status: 'OPEN', pbi_id: 'pbi-1', sprint_id: null, created_at: new Date() } useBacklogStore.getState().applyChange('story', 'I', story) expect(useBacklogStore.getState().storiesByPbi['pbi-1']).toHaveLength(1) }) it('applyChange: story DELETE removes from correct pbi bucket', () => { - const story = { id: 'story-1', code: 'ST-1', title: 'S', description: null, acceptance_criteria: null, priority: 2, status: 'OPEN', pbi_id: 'pbi-1', created_at: new Date() } + const story = { id: 'story-1', code: 'ST-1', title: 'S', description: null, acceptance_criteria: null, priority: 2, status: 'OPEN', pbi_id: 'pbi-1', sprint_id: null, created_at: new Date() } useBacklogStore.setState({ pbis: [], storiesByPbi: { 'pbi-1': [story] }, tasksByStory: {} }) useBacklogStore.getState().applyChange('story', 'D', { id: 'story-1' }) expect(useBacklogStore.getState().storiesByPbi['pbi-1']).toHaveLength(0) diff --git a/__tests__/components/backlog/integration.test.tsx b/__tests__/components/backlog/integration.test.tsx index 928ccce..feab76c 100644 --- a/__tests__/components/backlog/integration.test.tsx +++ b/__tests__/components/backlog/integration.test.tsx @@ -62,7 +62,7 @@ const ALT_PBI_ID = 'pbi-2' const STORY_ID = 'story-1' const STORIES = [ - { id: STORY_ID, code: 'ST-1', title: 'Eerste story', description: null, acceptance_criteria: null, priority: 2, status: 'OPEN', pbi_id: PBI_ID, created_at: new Date() }, + { id: STORY_ID, code: 'ST-1', title: 'Eerste story', description: null, acceptance_criteria: null, priority: 2, status: 'OPEN', pbi_id: PBI_ID, sprint_id: null, created_at: new Date() }, ] const TASKS = [ { id: 'task-1', title: 'Eerste taak', description: null, priority: 2, status: 'TO_DO', sort_order: 1, story_id: STORY_ID, created_at: new Date() }, diff --git a/__tests__/realtime/payload-contract.test.ts b/__tests__/realtime/payload-contract.test.ts index b36bc09..3835903 100644 --- a/__tests__/realtime/payload-contract.test.ts +++ b/__tests__/realtime/payload-contract.test.ts @@ -21,6 +21,7 @@ const STORY: BacklogStory = { priority: 2, status: 'OPEN', pbi_id: 'pbi-1', + sprint_id: null, created_at: new Date('2024-01-01T00:00:00Z'), } diff --git a/actions/sprints.ts b/actions/sprints.ts index de096d3..1be5ef5 100644 --- a/actions/sprints.ts +++ b/actions/sprints.ts @@ -103,7 +103,7 @@ export async function createSprintAction(_prevState: unknown, formData: FormData } await setActiveSprintCookie(parsed.data.productId, sprint.id) - revalidatePath(`/products/${parsed.data.productId}`) + revalidatePath(`/products/${parsed.data.productId}`, 'layout') return { success: true, sprintId: sprint.id } } diff --git a/app/(app)/products/[id]/page.tsx b/app/(app)/products/[id]/page.tsx index a8e79e5..8731a53 100644 --- a/app/(app)/products/[id]/page.tsx +++ b/app/(app)/products/[id]/page.tsx @@ -61,6 +61,7 @@ export default async function ProductBacklogPage({ params, searchParams }: Props priority: true, status: true, pbi_id: true, + sprint_id: true, created_at: true, }, }), diff --git a/app/(app)/products/[id]/solo/page.tsx b/app/(app)/products/[id]/solo/page.tsx index 8af037d..83a1720 100644 --- a/app/(app)/products/[id]/solo/page.tsx +++ b/app/(app)/products/[id]/solo/page.tsx @@ -2,6 +2,7 @@ import { notFound, redirect } from 'next/navigation' import { getSession } from '@/lib/auth' import { getAccessibleProduct } from '@/lib/product-access' import { prisma } from '@/lib/prisma' +import { resolveActiveSprint } from '@/lib/active-sprint' import { getSprintSwitcherData } from '@/lib/sprint-switcher-data' import { SoloBoard } from '@/components/solo/solo-board' import { NoActiveSprint } from '@/components/solo/no-active-sprint' @@ -21,9 +22,10 @@ export default async function SoloProductPage({ params }: Props) { const product = await getAccessibleProduct(id, session.userId) if (!product) notFound() - const sprint = await prisma.sprint.findFirst({ - where: { product_id: id, status: 'OPEN' }, - }) + const active = await resolveActiveSprint(id) + const sprint = active + ? await prisma.sprint.findFirst({ where: { id: active.id, product_id: id } }) + : null const switcherData = await getSprintSwitcherData(id, { activeSprintId: sprint?.id ?? null }) @@ -126,6 +128,7 @@ export default async function SoloProductPage({ params }: Props) { {switcherBar}