/** * StandardThreeWidgetFooter - Enhanced 3-Column Layout with Standardized Widgets * * This component provides a consistent 3-widget footer layout: * - Widget 1: Page Progress (page-specific, passed as prop) * - Widget 2: Module Stats (standardized via useModuleStats hook) * - Widget 3: Workflow Completion (standardized via useWorkflowStats hook) * * Use this component for consistent data across all Planner and Writer module pages. */ import React from 'react'; import { Card } from '../ui/card/Card'; import { Link } from 'react-router-dom'; import { LightBulbIcon, ChevronRightIcon } from '@heroicons/react/24/solid'; import WorkflowCompletionWidget from './WorkflowCompletionWidget'; import StandardizedModuleWidget, { ModuleType } from './StandardizedModuleWidget'; // ============================================================================ // TYPE DEFINITIONS (moved from ThreeWidgetFooter.tsx) // ============================================================================ /** Submodule color type - matches headerMetrics accentColor */ export type SubmoduleColor = 'blue' | 'green' | 'amber' | 'purple'; /** Widget 1: Page Progress - metrics in 2x2 grid + progress bar + hint */ export interface PageProgressWidget { title: string; metrics: Array<{ label: string; value: string | number; percentage?: string }>; progress: { value: number; label: string; color?: SubmoduleColor }; hint?: string; /** The submodule's accent color - progress bar uses this */ submoduleColor?: SubmoduleColor; /** Optional credits consumed for AI functions on this page */ creditsConsumed?: number; /** Contextual status insight - guidance message based on current state */ statusInsight?: string; } /** Widget 2: Module Stats - Pipeline flow with arrows and progress bars */ export interface ModulePipelineRow { fromLabel: string; fromValue: number; fromHref?: string; actionLabel: string; toLabel: string; toValue: number; toHref?: string; progress: number; // 0-100 /** Color for this pipeline row's progress bar */ color?: SubmoduleColor; } export interface ModuleStatsWidget { title: string; pipeline: ModulePipelineRow[]; links: Array<{ label: string; href: string }>; } // ============================================================================ // TYPE DEFINITIONS // ============================================================================ export interface StandardThreeWidgetFooterProps { pageProgress: PageProgressWidget; /** @deprecated Use `module` prop instead for standardized data. This is kept for backward compatibility. */ moduleStats?: ModuleStatsWidget; /** Module type for standardized module stats widget */ module?: ModuleType; submoduleColor?: SubmoduleColor; /** Show credits consumption in workflow widget */ showCredits?: boolean; /** Analytics href for the workflow widget */ analyticsHref?: string; className?: string; } // ============================================================================ // COLOR UTILITIES // ============================================================================ const getProgressBarStyle = (color: SubmoduleColor = 'blue'): React.CSSProperties => { const colorMap: Record = { blue: 'var(--color-primary)', green: 'var(--color-success)', amber: 'var(--color-warning)', purple: 'var(--color-info)', }; return { backgroundColor: colorMap[color] }; }; // ============================================================================ // WIDGET 1: PAGE PROGRESS // ============================================================================ function PageProgressCard({ widget, submoduleColor = 'blue' }: { widget: PageProgressWidget; submoduleColor?: SubmoduleColor }) { const progressColor = widget.submoduleColor || widget.progress.color || submoduleColor; return ( {/* Header */}

{widget.title}

{/* 2x2 Metrics Grid */}
{widget.metrics.slice(0, 4).map((metric, idx) => (
{metric.label}
{typeof metric.value === 'number' ? metric.value.toLocaleString() : metric.value} {metric.percentage && ( ({metric.percentage}) )}
))}
{/* Progress Bar */}
{widget.progress.label} {widget.progress.value}%
{/* Credits consumed (for AI function pages) */} {widget.creditsConsumed !== undefined && widget.creditsConsumed > 0 && (
Credits Consumed {widget.creditsConsumed.toLocaleString()}
)} {/* Hint with icon */} {widget.hint && (
{widget.hint}
)} {/* Status Insight - contextual guidance */} {widget.statusInsight && (

Next:{' '} {widget.statusInsight}

)} ); } // ============================================================================ // WIDGET 2: MODULE STATS // ============================================================================ function ModuleStatsCard({ widget }: { widget: ModuleStatsWidget }) { return ( {/* Header */}

{widget.title}

{/* Pipeline Rows */}
{widget.pipeline.map((row, idx) => (
{/* Row header: FromLabel Value ► ToLabel Value */}
{/* From side */}
{row.fromHref ? ( {row.fromLabel} ) : ( {row.fromLabel} )} {row.fromValue}
{/* Arrow icon */} {/* To side */}
{row.toHref ? ( {row.toLabel} ) : ( {row.toLabel} )} {row.toValue}
{/* Progress bar */}
))}
{/* Navigation Links */}
{widget.links.map((link, idx) => ( {link.label} ))}
); } // ============================================================================ // MAIN COMPONENT // ============================================================================ export default function StandardThreeWidgetFooter({ pageProgress, moduleStats, module, submoduleColor = 'blue', showCredits = true, analyticsHref = '/account/usage', className = '', }: StandardThreeWidgetFooterProps) { // Determine which module to show - prefer explicit module prop const moduleType: ModuleType = module || (moduleStats?.title?.toLowerCase().includes('planner') ? 'planner' : 'writer'); return (
{/* * Widget widths adjusted per requirements: * - Widget 1 (Page Progress): 28.3% (reduced by 5%) * - Widget 2 (Module Stats): 28.3% (reduced by 5%) * - Widget 3 (Workflow Completion): 43.4% (increased by 10%) * Using fr units to prevent overflow */}
{/* Use standardized module widget for consistent data */}
); } // Export sub-components export { PageProgressCard, ModuleStatsCard };