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) {| PBI | +PBI-code | +Titel | Tokens | -Kosten (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)}` : '—'} + | +
Geen sprint-data met token-registratie.
} @@ -15,24 +20,28 @@ export function SprintTokenHistoryTable({ rows, selectedSprintId }: Props) {| Sprint | +Sprint goal | Tokens | Kosten (USD) | -Jobs | +Aantal jobs |
|---|---|---|---|---|---|
| {r.sprintGoal} | -{r.totalTokens.toLocaleString()} | -${r.totalCostUsd.toFixed(4)} | -{r.jobCount} | -||
| {goal} | +{r.totalTokens.toLocaleString()} | +${r.totalCostUsd.toFixed(4)} | +{r.jobCount} | +
Geen dagdata voor deze sprint.
+ returnGeen dag-data beschikbaar
} return ( -