'use client'; import React from 'react'; import { ClubMetrics } from './types'; interface MetricCardProps { label: string; value: string | number; unit?: string; badge?: React.ReactNode; subtextLeft?: React.ReactNode; subtextRight?: React.ReactNode; disclaimer?: string; sparklineVariant?: 'secondary' | 'error' | 'primary'; showSparkline?: boolean; isUnavailable?: boolean; } export function MetricCard({ label, value, unit, badge, subtextLeft, subtextRight, disclaimer, sparklineVariant = 'secondary', showSparkline = false, isUnavailable = false, }: MetricCardProps) { const sparklineColors = { secondary: { stroke: 'text-secondary', fill: '#38bdf8', path: 'M0 24 L25 18 L50 20 L75 10 L100 4' }, error: { stroke: 'text-error', fill: '#f87171', path: 'M0 15 L25 18 L50 10 L75 22 L100 8' }, primary: { stroke: 'text-primary', fill: '#0088ff', path: 'M0 26 L30 20 L60 14 L100 8' }, }; const selectedSpark = sparklineColors[sparklineVariant] || sparklineColors.secondary; return (
{/* Top Header Row */}
{label} {badge}
{/* Primary Numerical Value & Sparkline */}
{isUnavailable ? '--' : value} {unit && !isUnavailable && ( {unit} )}
{showSparkline && !isUnavailable && ( )}
{/* Footer Subtext */}
{subtextLeft &&
{subtextLeft}
} {subtextRight &&
{subtextRight}
}
{disclaimer && ( {disclaimer} )}
); } export function ExecutiveMetrics({ metrics }: { metrics: ClubMetrics }) { return (
{/* 1. MEMBERS */} {metrics.membersActivePercent}% ACTIVE ) : ( ROSTER ) } subtextLeft={ metrics.membersDeltaMonth != null ? ( +{metrics.membersDeltaMonth} this month ) : ( Total Roster ) } subtextRight={ metrics.roadMarshalsCount != null ? ( {metrics.roadMarshalsCount} Road Marshals ) : ( Active members ) } /> {/* 2. PENDING APPLICATIONS */} 0 ? ( REQUIRES REVIEW ) : ( ALL CLEARED ) } subtextLeft={ metrics.pendingApplications > 0 ? ( Requires review ) : ( No pending ) } subtextRight={Awaiting founder review} /> {/* 3. UPCOMING RIDES */} {metrics.upcomingRidesCount > 0 ? 'SCHEDULED' : 'NONE'} } subtextLeft={ {metrics.confirmedRidersTotal} riders confirmed } subtextRight={Next: {metrics.nextRideDate ?? 'None'}} /> {/* 4. CLUB MILES THIS MONTH */} Completed Club Rides only ) : ( UNAVAILABLE ) } subtextLeft={ {metrics.completedClubRidesCount} completed Club Rides } subtextRight={Eligible rides only} disclaimer="Calculated from eligible completed Club Rides. Private rider mileage is not automatically included." />
); }