import { state } from '../core/state';
import { renderHwDashboard } from './Dashboard/HwDashboard';
import { renderSwDashboard } from './Dashboard/SwDashboard';

/**
 * 대시보드 렌더링 통합 허브
 */
export function renderDashboard(mainContent: HTMLElement) {
  if (!mainContent) return;
  mainContent.innerHTML = '';

  // 기존 차트 리소스 해제
  if (state.activeCharts) {
    state.activeCharts.forEach((c: any) => {
      if (c && typeof c.destroy === 'function') c.destroy();
    });
  }
  state.activeCharts = [];

  if (state.activeCategory === 'hw') {
    renderHwDashboard(mainContent);
  } else if (state.activeCategory === 'sw') {
    renderSwDashboard(mainContent);
  } else {
    mainContent.innerHTML = `<div class="dashboard-section-title" style="padding:2rem;">운영 서비스 대시보드는 준비 중입니다.</div>`;
  }
}
