2026-01-30 13:41:32 +01:00
|
|
|
'use client'
|
|
|
|
|
|
Observer platform overhaul: Nivo charts, round-type stats, UX improvements
Phase 1: Fix 6 backend data bugs in analytics.ts (roundName filtering,
unscored projects, criteria scores, activeRoundCount scoping, email
privacy leaks in juror consistency + workload)
Phase 2-3: Migrate all 9 chart components from Recharts to Nivo
(@nivo/bar, @nivo/line, @nivo/pie, @nivo/scatterplot) with shared brand
theme, scoreGradient colors, and STATUS_COLORS map. Fixes scatter plot
outlier coloring and pie chart label visibility bugs.
Phase 4: Add round-type-aware stats (getRoundTypeStats backend +
RoundTypeStatsCards component) showing appropriate metrics per round
type (intake/filtering/evaluation/submission/mentoring/live/deliberation).
Phase 5: UX improvements — Stage→Round terminology, clickable dashboard
round links, URL-based round selection (?round=), round type indicators
in selectors, accessible Toggle-based cross-round comparison, sortable
project table columns (title/score/evaluations), brand score colors on
dashboard bar chart with aria labels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 21:44:38 +01:00
|
|
|
import { ResponsiveBar, type ComputedDatum } from '@nivo/bar'
|
2026-01-30 13:41:32 +01:00
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
Observer platform overhaul: Nivo charts, round-type stats, UX improvements
Phase 1: Fix 6 backend data bugs in analytics.ts (roundName filtering,
unscored projects, criteria scores, activeRoundCount scoping, email
privacy leaks in juror consistency + workload)
Phase 2-3: Migrate all 9 chart components from Recharts to Nivo
(@nivo/bar, @nivo/line, @nivo/pie, @nivo/scatterplot) with shared brand
theme, scoreGradient colors, and STATUS_COLORS map. Fixes scatter plot
outlier coloring and pie chart label visibility bugs.
Phase 4: Add round-type-aware stats (getRoundTypeStats backend +
RoundTypeStatsCards component) showing appropriate metrics per round
type (intake/filtering/evaluation/submission/mentoring/live/deliberation).
Phase 5: UX improvements — Stage→Round terminology, clickable dashboard
round links, URL-based round selection (?round=), round type indicators
in selectors, accessible Toggle-based cross-round comparison, sortable
project table columns (title/score/evaluations), brand score colors on
dashboard bar chart with aria labels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 21:44:38 +01:00
|
|
|
import { nivoTheme } from './chart-theme'
|
2026-01-30 13:41:32 +01:00
|
|
|
|
|
|
|
|
interface JurorWorkloadData {
|
|
|
|
|
id: string
|
|
|
|
|
name: string
|
|
|
|
|
assigned: number
|
|
|
|
|
completed: number
|
|
|
|
|
completionRate: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface JurorWorkloadProps {
|
|
|
|
|
data: JurorWorkloadData[]
|
|
|
|
|
}
|
|
|
|
|
|
Observer platform overhaul: Nivo charts, round-type stats, UX improvements
Phase 1: Fix 6 backend data bugs in analytics.ts (roundName filtering,
unscored projects, criteria scores, activeRoundCount scoping, email
privacy leaks in juror consistency + workload)
Phase 2-3: Migrate all 9 chart components from Recharts to Nivo
(@nivo/bar, @nivo/line, @nivo/pie, @nivo/scatterplot) with shared brand
theme, scoreGradient colors, and STATUS_COLORS map. Fixes scatter plot
outlier coloring and pie chart label visibility bugs.
Phase 4: Add round-type-aware stats (getRoundTypeStats backend +
RoundTypeStatsCards component) showing appropriate metrics per round
type (intake/filtering/evaluation/submission/mentoring/live/deliberation).
Phase 5: UX improvements — Stage→Round terminology, clickable dashboard
round links, URL-based round selection (?round=), round type indicators
in selectors, accessible Toggle-based cross-round comparison, sortable
project table columns (title/score/evaluations), brand score colors on
dashboard bar chart with aria labels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 21:44:38 +01:00
|
|
|
type WorkloadBarDatum = {
|
|
|
|
|
juror: string
|
|
|
|
|
completed: number
|
|
|
|
|
remaining: number
|
|
|
|
|
completionRate: number
|
|
|
|
|
fullName: string
|
|
|
|
|
}
|
2026-01-30 13:41:32 +01:00
|
|
|
|
Observer platform overhaul: Nivo charts, round-type stats, UX improvements
Phase 1: Fix 6 backend data bugs in analytics.ts (roundName filtering,
unscored projects, criteria scores, activeRoundCount scoping, email
privacy leaks in juror consistency + workload)
Phase 2-3: Migrate all 9 chart components from Recharts to Nivo
(@nivo/bar, @nivo/line, @nivo/pie, @nivo/scatterplot) with shared brand
theme, scoreGradient colors, and STATUS_COLORS map. Fixes scatter plot
outlier coloring and pie chart label visibility bugs.
Phase 4: Add round-type-aware stats (getRoundTypeStats backend +
RoundTypeStatsCards component) showing appropriate metrics per round
type (intake/filtering/evaluation/submission/mentoring/live/deliberation).
Phase 5: UX improvements — Stage→Round terminology, clickable dashboard
round links, URL-based round selection (?round=), round type indicators
in selectors, accessible Toggle-based cross-round comparison, sortable
project table columns (title/score/evaluations), brand score colors on
dashboard bar chart with aria labels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 21:44:38 +01:00
|
|
|
export function JurorWorkloadChart({ data }: JurorWorkloadProps) {
|
2026-02-20 13:42:31 +01:00
|
|
|
if (!data?.length) return null
|
|
|
|
|
|
2026-01-30 13:41:32 +01:00
|
|
|
const totalAssigned = data.reduce((sum, d) => sum + d.assigned, 0)
|
|
|
|
|
const totalCompleted = data.reduce((sum, d) => sum + d.completed, 0)
|
|
|
|
|
const overallRate =
|
|
|
|
|
totalAssigned > 0 ? Math.round((totalCompleted / totalAssigned) * 100) : 0
|
|
|
|
|
|
Observer platform overhaul: Nivo charts, round-type stats, UX improvements
Phase 1: Fix 6 backend data bugs in analytics.ts (roundName filtering,
unscored projects, criteria scores, activeRoundCount scoping, email
privacy leaks in juror consistency + workload)
Phase 2-3: Migrate all 9 chart components from Recharts to Nivo
(@nivo/bar, @nivo/line, @nivo/pie, @nivo/scatterplot) with shared brand
theme, scoreGradient colors, and STATUS_COLORS map. Fixes scatter plot
outlier coloring and pie chart label visibility bugs.
Phase 4: Add round-type-aware stats (getRoundTypeStats backend +
RoundTypeStatsCards component) showing appropriate metrics per round
type (intake/filtering/evaluation/submission/mentoring/live/deliberation).
Phase 5: UX improvements — Stage→Round terminology, clickable dashboard
round links, URL-based round selection (?round=), round type indicators
in selectors, accessible Toggle-based cross-round comparison, sortable
project table columns (title/score/evaluations), brand score colors on
dashboard bar chart with aria labels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 21:44:38 +01:00
|
|
|
const sortedData = [...data].sort(
|
|
|
|
|
(a, b) => b.completionRate - a.completionRate,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const chartData: WorkloadBarDatum[] = sortedData.map((d) => ({
|
|
|
|
|
juror: d.name.length > 25 ? d.name.substring(0, 25) + '...' : d.name,
|
|
|
|
|
completed: d.completed,
|
|
|
|
|
remaining: d.assigned - d.completed,
|
|
|
|
|
completionRate: d.completionRate,
|
|
|
|
|
fullName: d.name,
|
|
|
|
|
}))
|
|
|
|
|
|
2026-01-30 13:41:32 +01:00
|
|
|
return (
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle className="flex items-center justify-between">
|
|
|
|
|
<span>Juror Workload</span>
|
|
|
|
|
<span className="text-sm font-normal text-muted-foreground">
|
|
|
|
|
{overallRate}% overall completion
|
|
|
|
|
</span>
|
|
|
|
|
</CardTitle>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
Observer platform overhaul: Nivo charts, round-type stats, UX improvements
Phase 1: Fix 6 backend data bugs in analytics.ts (roundName filtering,
unscored projects, criteria scores, activeRoundCount scoping, email
privacy leaks in juror consistency + workload)
Phase 2-3: Migrate all 9 chart components from Recharts to Nivo
(@nivo/bar, @nivo/line, @nivo/pie, @nivo/scatterplot) with shared brand
theme, scoreGradient colors, and STATUS_COLORS map. Fixes scatter plot
outlier coloring and pie chart label visibility bugs.
Phase 4: Add round-type-aware stats (getRoundTypeStats backend +
RoundTypeStatsCards component) showing appropriate metrics per round
type (intake/filtering/evaluation/submission/mentoring/live/deliberation).
Phase 5: UX improvements — Stage→Round terminology, clickable dashboard
round links, URL-based round selection (?round=), round type indicators
in selectors, accessible Toggle-based cross-round comparison, sortable
project table columns (title/score/evaluations), brand score colors on
dashboard bar chart with aria labels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 21:44:38 +01:00
|
|
|
<div
|
|
|
|
|
style={{ height: `${Math.max(300, data.length * 35)}px` }}
|
|
|
|
|
>
|
|
|
|
|
<ResponsiveBar
|
|
|
|
|
data={chartData}
|
|
|
|
|
keys={['completed', 'remaining']}
|
|
|
|
|
indexBy="juror"
|
|
|
|
|
layout="horizontal"
|
|
|
|
|
theme={nivoTheme}
|
|
|
|
|
colors={['#053d57', '#e5e7eb']}
|
|
|
|
|
borderRadius={2}
|
|
|
|
|
enableLabel={true}
|
|
|
|
|
label={(d: ComputedDatum<WorkloadBarDatum>) => {
|
|
|
|
|
if (d.id === 'completed') {
|
|
|
|
|
return `${d.data.completionRate}%`
|
|
|
|
|
}
|
|
|
|
|
return ''
|
|
|
|
|
}}
|
|
|
|
|
labelSkipWidth={40}
|
|
|
|
|
labelTextColor={(d) => {
|
|
|
|
|
const datum = d as unknown as { data: ComputedDatum<WorkloadBarDatum> }
|
|
|
|
|
return datum.data.id === 'completed' ? '#ffffff' : '#374151'
|
|
|
|
|
}}
|
|
|
|
|
margin={{ top: 10, right: 30, bottom: 30, left: 160 }}
|
|
|
|
|
padding={0.25}
|
|
|
|
|
groupMode="stacked"
|
|
|
|
|
tooltip={({ id, value, data: rowData }) => (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
background: '#ffffff',
|
|
|
|
|
padding: '8px 12px',
|
|
|
|
|
borderRadius: '8px',
|
|
|
|
|
boxShadow: '0 4px 12px rgba(0,0,0,0.1)',
|
|
|
|
|
border: '1px solid #e5e7eb',
|
|
|
|
|
fontSize: 12,
|
2026-01-30 13:41:32 +01:00
|
|
|
}}
|
Observer platform overhaul: Nivo charts, round-type stats, UX improvements
Phase 1: Fix 6 backend data bugs in analytics.ts (roundName filtering,
unscored projects, criteria scores, activeRoundCount scoping, email
privacy leaks in juror consistency + workload)
Phase 2-3: Migrate all 9 chart components from Recharts to Nivo
(@nivo/bar, @nivo/line, @nivo/pie, @nivo/scatterplot) with shared brand
theme, scoreGradient colors, and STATUS_COLORS map. Fixes scatter plot
outlier coloring and pie chart label visibility bugs.
Phase 4: Add round-type-aware stats (getRoundTypeStats backend +
RoundTypeStatsCards component) showing appropriate metrics per round
type (intake/filtering/evaluation/submission/mentoring/live/deliberation).
Phase 5: UX improvements — Stage→Round terminology, clickable dashboard
round links, URL-based round selection (?round=), round type indicators
in selectors, accessible Toggle-based cross-round comparison, sortable
project table columns (title/score/evaluations), brand score colors on
dashboard bar chart with aria labels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 21:44:38 +01:00
|
|
|
>
|
|
|
|
|
<strong>{rowData.fullName}</strong>
|
|
|
|
|
<br />
|
|
|
|
|
{id === 'completed' ? 'Completed' : 'Remaining'}: {value}
|
|
|
|
|
<br />
|
|
|
|
|
Completion: {rowData.completionRate}%
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
legends={[
|
|
|
|
|
{
|
|
|
|
|
dataFrom: 'keys',
|
|
|
|
|
anchor: 'bottom',
|
|
|
|
|
direction: 'row',
|
|
|
|
|
translateY: 30,
|
|
|
|
|
itemsSpacing: 20,
|
|
|
|
|
itemWidth: 100,
|
|
|
|
|
itemHeight: 18,
|
|
|
|
|
symbolSize: 12,
|
|
|
|
|
symbolShape: 'square',
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
animate={true}
|
|
|
|
|
/>
|
2026-01-30 13:41:32 +01:00
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)
|
|
|
|
|
}
|