Component: SprintStatusDonut (Recharts PieChart) (#36)

* chore: voeg recharts toe aan dependencies

Vereist door SprintStatusDonut component.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: SprintStatusDonut + getSprintStatusBreakdown helper

PieChart (donut) met TO_DO/IN_PROGRESS/DONE verdeling over alle active sprints.
REVIEW wordt samengevoegd in IN_PROGRESS. MD3 status-kleuren via CSS-variabelen.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-05-01 16:41:18 +02:00 committed by GitHub
parent 1df1ea48ad
commit 2539361784
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 87 additions and 0 deletions

View file

@ -0,0 +1,39 @@
import { prisma } from '@/lib/prisma'
import { productAccessFilter } from '@/lib/product-access'
export type SprintStatusGroup = 'TO_DO' | 'IN_PROGRESS' | 'DONE'
export interface StatusCount {
status: SprintStatusGroup
count: number
}
// Maps REVIEW → IN_PROGRESS so donut shows 3 buckets only
function toGroup(status: string): SprintStatusGroup {
if (status === 'DONE') return 'DONE'
if (status === 'TO_DO') return 'TO_DO'
return 'IN_PROGRESS'
}
export async function getSprintStatusBreakdown(userId: string): Promise<StatusCount[]> {
const tasks = await prisma.task.findMany({
where: {
story: {
sprint: {
status: 'ACTIVE',
product: productAccessFilter(userId),
},
},
},
select: { status: true },
})
const counts: Record<SprintStatusGroup, number> = { TO_DO: 0, IN_PROGRESS: 0, DONE: 0 }
for (const t of tasks) {
counts[toGroup(t.status)]++
}
return (Object.entries(counts) as [SprintStatusGroup, number][])
.filter(([, count]) => count > 0)
.map(([status, count]) => ({ status, count }))
}