"use client"; import React, { useState } from "react"; import { FileText, Download, Calendar, Folder, Search } from "lucide-react"; import { DashboardElement } from "@/components/admin/dashboard/types"; interface Document { id: string; name: string; category: "계약서" | "보험" | "세금계산서" | "기타"; size: string; uploadDate: string; url: string; description?: string; } // 목 데이터 (하드코딩 - 주석처리됨) // const mockDocuments: Document[] = [ // { // id: "1", // name: "2025년 1월 세금계산서.pdf", // category: "세금계산서", // size: "1.2 MB", // uploadDate: "2025-01-05", // url: "/documents/tax-invoice-202501.pdf", // description: "1월 매출 세금계산서", // }, // { // id: "2", // name: "차량보험증권_서울12가3456.pdf", // category: "보험", // size: "856 KB", // uploadDate: "2024-12-20", // url: "/documents/insurance-vehicle-1.pdf", // description: "1톤 트럭 종합보험", // }, // { // id: "3", // name: "운송계약서_ABC물류.pdf", // category: "계약서", // size: "2.4 MB", // uploadDate: "2024-12-15", // url: "/documents/contract-abc-logistics.pdf", // description: "ABC물류 연간 운송 계약", // }, // { // id: "4", // name: "2024년 12월 세금계산서.pdf", // category: "세금계산서", // size: "1.1 MB", // uploadDate: "2024-12-05", // url: "/documents/tax-invoice-202412.pdf", // }, // { // id: "5", // name: "화물배상책임보험증권.pdf", // category: "보험", // size: "720 KB", // uploadDate: "2024-11-30", // url: "/documents/cargo-insurance.pdf", // description: "화물 배상책임보험", // }, // { // id: "6", // name: "차고지 임대계약서.pdf", // category: "계약서", // size: "1.8 MB", // uploadDate: "2024-11-15", // url: "/documents/garage-lease-contract.pdf", // }, // ]; interface DocumentWidgetProps { element?: DashboardElement; } export default function DocumentWidget({ element }: DocumentWidgetProps) { // TODO: 실제 API 연동 필요 const [documents] = useState([]); const [filter, setFilter] = useState<"all" | Document["category"]>("all"); const [searchTerm, setSearchTerm] = useState(""); const filteredDocuments = documents.filter((doc) => { const matchesFilter = filter === "all" || doc.category === filter; const matchesSearch = searchTerm === "" || doc.name.toLowerCase().includes(searchTerm.toLowerCase()) || doc.description?.toLowerCase().includes(searchTerm.toLowerCase()); return matchesFilter && matchesSearch; }); const getCategoryIcon = (category: Document["category"]) => { switch (category) { case "계약서": return "📄"; case "보험": return "🛡️"; case "세금계산서": return "💰"; case "기타": return "📁"; } }; const getCategoryColor = (category: Document["category"]) => { switch (category) { case "계약서": return "bg-blue-100 text-blue-700"; case "보험": return "bg-green-100 text-green-700"; case "세금계산서": return "bg-amber-100 text-amber-700"; case "기타": return "bg-gray-100 text-gray-700"; } }; const handleDownload = (doc: Document) => { // 실제로는 백엔드 API 호출 alert(`다운로드: ${doc.name}\n(실제 구현 시 파일 다운로드 처리)`); }; const stats = { total: documents.length, contract: documents.filter((d) => d.category === "계약서").length, insurance: documents.filter((d) => d.category === "보험").length, tax: documents.filter((d) => d.category === "세금계산서").length, }; return (
{/* 헤더 */}

{element?.customTitle || "문서 관리"}

{/* 통계 */}
{stats.total}
전체
{stats.contract}
계약서
{stats.insurance}
보험
{stats.tax}
계산서
{/* 검색 */}
setSearchTerm(e.target.value)} className="w-full rounded border border-gray-300 py-2 pl-10 pr-3 text-sm focus:border-primary focus:outline-none" />
{/* 필터 */}
{(["all", "계약서", "보험", "세금계산서", "기타"] as const).map((f) => ( ))}
{/* 문서 리스트 */}
{filteredDocuments.length === 0 ? (
📭
문서가 없습니다
) : (
{filteredDocuments.map((doc) => (
{/* 아이콘 */}
{getCategoryIcon(doc.category)}
{/* 정보 */}
{doc.name}
{doc.description && (
{doc.description}
)}
{doc.category} {new Date(doc.uploadDate).toLocaleDateString()} {doc.size}
{/* 다운로드 버튼 */}
))}
)}
); }