diff --git a/components/behavior/FrustrationTrend.tsx b/components/behavior/FrustrationTrend.tsx
index 330b0a6..afb9b01 100644
--- a/components/behavior/FrustrationTrend.tsx
+++ b/components/behavior/FrustrationTrend.tsx
@@ -1,7 +1,22 @@
'use client'
-import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer, Cell } from 'recharts'
import { TrendUp } from '@phosphor-icons/react'
+import { Pie, PieChart } from 'recharts'
+
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from '@/components/ui/card'
+import {
+ ChartContainer,
+ ChartTooltip,
+ ChartTooltipContent,
+ type ChartConfig,
+} from '@/components/charts'
import type { FrustrationSummary } from '@/lib/api/stats'
interface FrustrationTrendProps {
@@ -16,131 +31,65 @@ function SkeletonCard() {
-
- {[120, 80, 140, 100].map((h, i) => (
-
- ))}
+
)
}
+const chartConfig = {
+ count: {
+ label: 'Count',
+ },
+ rage_clicks: {
+ label: 'Rage Clicks',
+ color: '#FD5E0F',
+ },
+ dead_clicks: {
+ label: 'Dead Clicks',
+ color: '#F59E0B',
+ },
+ prev_rage_clicks: {
+ label: 'Prev Rage Clicks',
+ color: '#78350F',
+ },
+ prev_dead_clicks: {
+ label: 'Prev Dead Clicks',
+ color: '#92400E',
+ },
+} satisfies ChartConfig
+
export default function FrustrationTrend({ summary, loading }: FrustrationTrendProps) {
if (loading || !summary) return
const hasData = summary.rage_clicks > 0 || summary.dead_clicks > 0 ||
summary.prev_rage_clicks > 0 || summary.prev_dead_clicks > 0
- const chartData = [
- {
- label: 'Rage',
- current: summary.rage_clicks,
- previous: summary.prev_rage_clicks,
- },
- {
- label: 'Dead',
- current: summary.dead_clicks,
- previous: summary.prev_dead_clicks,
- },
- ]
-
const totalCurrent = summary.rage_clicks + summary.dead_clicks
const totalPrevious = summary.prev_rage_clicks + summary.prev_dead_clicks
const totalChange = totalPrevious > 0
? Math.round(((totalCurrent - totalPrevious) / totalPrevious) * 100)
: null
- return (
-
-
-
- Frustration Trend
-
-
-
- Current vs. previous period comparison
-
+ const chartData = [
+ { type: 'rage_clicks', count: summary.rage_clicks, fill: 'var(--color-rage_clicks)' },
+ { type: 'dead_clicks', count: summary.dead_clicks, fill: 'var(--color-dead_clicks)' },
+ { type: 'prev_rage_clicks', count: summary.prev_rage_clicks, fill: 'var(--color-prev_rage_clicks)' },
+ { type: 'prev_dead_clicks', count: summary.prev_dead_clicks, fill: 'var(--color-prev_dead_clicks)' },
+ ]
- {hasData ? (
-
- {/* Summary line */}
-
-
- {totalCurrent.toLocaleString()}
-
-
- total signals
-
- {totalChange !== null && (
- 0
- ? 'text-red-600 dark:text-red-400'
- : totalChange < 0
- ? 'text-green-600 dark:text-green-400'
- : 'text-neutral-500 dark:text-neutral-400'
- }`}>
- {totalChange > 0 ? '+' : ''}{totalChange}%
-
- )}
- {totalChange === null && totalCurrent > 0 && (
-
- New
-
- )}
-
-
- {/* Chart */}
-
-
-
-
-
- [
- value.toLocaleString(),
- name === 'current' ? 'Current' : 'Previous',
- ]}
- />
-
- {chartData.map((_, i) => (
- |
- ))}
-
-
- {chartData.map((_, i) => (
- |
- ))}
-
-
-
-
-
- {/* Legend */}
-
+ if (!hasData) {
+ return (
+
+
+
+ Frustration Trend
+
- ) : (
+
+ Current vs. previous period comparison
+
@@ -152,7 +101,53 @@ export default function FrustrationTrend({ summary, loading }: FrustrationTrendP
Frustration trend data will appear here once rage clicks or dead clicks are detected across periods.
- )}
-
+
+ )
+ }
+
+ return (
+
+
+ Frustration Trend
+ Current vs. previous period
+
+
+
+
+ }
+ />
+
+
+
+
+
+
+ {totalChange !== null ? (
+ <>
+ {totalChange > 0 ? 'Up' : totalChange < 0 ? 'Down' : 'No change'} by {Math.abs(totalChange)}% vs previous period
+ >
+ ) : totalCurrent > 0 ? (
+ <>
+ {totalCurrent.toLocaleString()} new signals this period
+ >
+ ) : (
+ 'No frustration signals detected'
+ )}
+
+
+ {totalCurrent.toLocaleString()} total signals in current period
+
+
+
)
}