diff --git a/app/(app)/insights/tokens/components/index.ts b/app/(app)/insights/tokens/components/index.ts new file mode 100644 index 0000000..feea440 --- /dev/null +++ b/app/(app)/insights/tokens/components/index.ts @@ -0,0 +1,3 @@ +export { TokenDayChart } from './token-day-chart' +export { SprintTokenHistoryTable } from './sprint-token-history-table' +export { PbiTokenTable } from './pbi-token-table' diff --git a/app/(app)/insights/tokens/components/pbi-token-table.tsx b/app/(app)/insights/tokens/components/pbi-token-table.tsx index 0d94ef2..eb62b3c 100644 --- a/app/(app)/insights/tokens/components/pbi-token-table.tsx +++ b/app/(app)/insights/tokens/components/pbi-token-table.tsx @@ -1,3 +1,6 @@ +'use client' + +import { useState, useMemo } from 'react' import type { PbiTokenRow } from '@/lib/insights/token-history' interface Props { @@ -5,6 +8,13 @@ interface Props { } export function PbiTokenTable({ rows }: Props) { + const [sortDesc, setSortDesc] = useState(true) + + const sorted = useMemo( + () => [...rows].sort((a, b) => sortDesc ? b.totalCostUsd - a.totalCostUsd : a.totalCostUsd - b.totalCostUsd), + [rows, sortDesc], + ) + if (rows.length === 0) { return

Geen PBI-data voor deze sprint.

} @@ -14,22 +24,31 @@ export function PbiTokenTable({ rows }: Props) { - + + - + - {rows.map(r => ( - - - - - - ))} + {sorted.map(r => { + const title = r.pbiTitle.length > 60 ? r.pbiTitle.slice(0, 57) + '…' : r.pbiTitle + return ( + + + + + + + ) + })}
PBIPBI-codeTitel TokensKosten (USD) setSortDesc(d => !d)} + > + Kosten (USD) {sortDesc ? '▾' : '▴'} +
- {r.pbiCode} - {r.pbiTitle} - {r.totalTokens.toLocaleString()}${r.totalCostUsd.toFixed(4)}
{r.pbiCode}{title}{r.totalTokens.toLocaleString()} + {r.totalCostUsd > 0 ? `$${r.totalCostUsd.toFixed(4)}` : '—'} +
diff --git a/app/(app)/insights/tokens/components/sprint-token-history-table.tsx b/app/(app)/insights/tokens/components/sprint-token-history-table.tsx index c6d56de..08ab21f 100644 --- a/app/(app)/insights/tokens/components/sprint-token-history-table.tsx +++ b/app/(app)/insights/tokens/components/sprint-token-history-table.tsx @@ -1,3 +1,6 @@ +'use client' + +import { useRouter } from 'next/navigation' import type { SprintTokenRow } from '@/lib/insights/token-history' interface Props { @@ -6,6 +9,8 @@ interface Props { } export function SprintTokenHistoryTable({ rows, selectedSprintId }: Props) { + const router = useRouter() + if (rows.length === 0) { return

Geen sprint-data met token-registratie.

} @@ -15,24 +20,28 @@ export function SprintTokenHistoryTable({ rows, selectedSprintId }: Props) { - + - + - {rows.map(r => ( - - - - - - - ))} + {rows.map(r => { + const goal = r.sprintGoal.length > 40 ? r.sprintGoal.slice(0, 37) + '…' : r.sprintGoal + return ( + router.push(`/insights/tokens?sprint=${r.sprintId}`)} + > + + + + + + ) + })}
SprintSprint goal Tokens Kosten (USD)JobsAantal jobs
{r.sprintGoal}{r.totalTokens.toLocaleString()}${r.totalCostUsd.toFixed(4)}{r.jobCount}
{goal}{r.totalTokens.toLocaleString()}${r.totalCostUsd.toFixed(4)}{r.jobCount}
diff --git a/app/(app)/insights/tokens/components/token-day-chart.tsx b/app/(app)/insights/tokens/components/token-day-chart.tsx index 8a95d1f..89f5182 100644 --- a/app/(app)/insights/tokens/components/token-day-chart.tsx +++ b/app/(app)/insights/tokens/components/token-day-chart.tsx @@ -1,6 +1,6 @@ 'use client' -import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer } from 'recharts' +import { LineChart, Line, XAxis, YAxis, Tooltip, CartesianGrid, ResponsiveContainer } from 'recharts' import type { DayTokenRow } from '@/lib/insights/token-history' interface Props { @@ -9,19 +9,20 @@ interface Props { export function TokenDayChart({ data }: Props) { if (data.length === 0) { - return

Geen dagdata voor deze sprint.

+ return

Geen dag-data beschikbaar

} return ( - + - (v as string).slice(5)} /> + + (v as string).slice(5).replace('-', '/')} /> `$${(v as number).toFixed(3)}`} /> - [`$${(v as number).toFixed(4)}`, 'Kosten (USD)']} /> + [`$${Number(v).toFixed(4)}`, 'Kosten']} />