'use client'; import { useState } from 'react'; import { RefreshCw, Calendar, Building2 } from 'lucide-react'; import type { DashboardConfig } from '@/lib/pipeline-types'; import { DashboardSection } from './DashboardSection'; interface DynamicDashboardProps { pipelineId: string; config: DashboardConfig; businessId?: string; } // Time range options const TIME_RANGES = [ { value: '7d', label: 'Last 7 days' }, { value: '14d', label: 'Last 14 days' }, { value: '30d', label: 'Last 30 days' }, { value: '90d', label: 'Last 90 days' }, ]; /** * Dynamic dashboard that renders from a DashboardConfig. * * This component: * - Renders sections based on the config * - Provides time range and business filters * - Handles global refresh */ export function DynamicDashboard({ pipelineId, config, businessId: initialBusinessId, }: DynamicDashboardProps) { const [timeRange, setTimeRange] = useState(config.default_time_range || '30d'); const [businessId, setBusinessId] = useState(initialBusinessId); const [refreshKey, setRefreshKey] = useState(0); // Force refresh all widgets const handleRefresh = () => { setRefreshKey((prev) => prev + 1); }; return (
{/* Dashboard Header */}

{config.title}

{config.description && (

{config.description}

)}
{/* Controls */}
{/* Business Filter (placeholder) */} {businessId && (
{businessId}
)} {/* Time Range Selector */}
{/* Refresh Button */}
{/* Sections */} {config.sections.map((section) => ( ))}
); }