diff --git a/components/behavior/FrustrationSummaryCards.tsx b/components/behavior/FrustrationSummaryCards.tsx new file mode 100644 index 0000000..d1bd8a2 --- /dev/null +++ b/components/behavior/FrustrationSummaryCards.tsx @@ -0,0 +1,119 @@ +'use client' + +import type { FrustrationSummary } from '@/lib/api/stats' + +interface FrustrationSummaryCardsProps { + data: FrustrationSummary | null + loading: boolean +} + +function pctChange(current: number, previous: number): number | null { + if (previous === 0 && current === 0) return null + if (previous === 0) return 100 + return Math.round(((current - previous) / previous) * 100) +} + +function ChangeIndicator({ change }: { change: number | null }) { + if (change === null) return null + const isUp = change > 0 + const isDown = change < 0 + return ( + + {isUp ? '+' : ''}{change}% + + ) +} + +function SkeletonCard() { + return ( +
+ Rage Clicks +
++ {data.rage_unique_elements} unique elements +
++ Dead Clicks +
++ {data.dead_unique_elements} unique elements +
++ Most Frustrated Page +
+ {topPage ? ( + <> ++ {topPage} +
++ {topPageTotal.toLocaleString()} total signals +
+ > + ) : ( ++ No data in this period +
+ )} +