"use client";
import React, { useState } from "react";
import { DragData, ElementType, ElementSubtype } from "./types";
import { ChevronDown, ChevronRight } from "lucide-react";
/**
* 대시보드 사이드바 컴포넌트
* - 드래그 가능한 차트/위젯 목록
* - 아코디언 방식으로 카테고리별 구분
*/
export function DashboardSidebar() {
const [expandedSections, setExpandedSections] = useState({
charts: true,
widgets: true,
operations: true,
});
// 섹션 토글
const toggleSection = (section: keyof typeof expandedSections) => {
setExpandedSections((prev) => ({ ...prev, [section]: !prev[section] }));
};
// 드래그 시작 처리
const handleDragStart = (e: React.DragEvent, type: ElementType, subtype: ElementSubtype) => {
const dragData: DragData = { type, subtype };
e.dataTransfer.setData("application/json", JSON.stringify(dragData));
e.dataTransfer.effectAllowed = "copy";
};
return (
{/* 차트 섹션 */}
{expandedSections.charts && (
)}
{/* 위젯 섹션 */}
{expandedSections.widgets && (
)}
{/* 운영/작업 지원 섹션 */}
{expandedSections.operations && (
{/* 정비 일정 관리 위젯 제거 - 커스텀 목록 카드로 대체 가능 */}
)}
);
}
interface DraggableItemProps {
icon: string;
title: string;
type: ElementType;
subtype: ElementSubtype;
className?: string;
onDragStart: (e: React.DragEvent, type: ElementType, subtype: ElementSubtype) => void;
}
/**
* 드래그 가능한 아이템 컴포넌트
*/
function DraggableItem({ icon, title, type, subtype, className = "", onDragStart }: DraggableItemProps) {
return (
onDragStart(e, type, subtype)}
>
{title}
);
}