"use client" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { FileText, Clock, CheckCircle, TrendingUp, Users, DollarSign, Calendar, BarChart3 } from "lucide-react" import { biddingStatusLabels, biddingTypeLabels } from "@/db/schema" interface BiddingsStatsCardsProps { total: number statusCounts: Record typeCounts: Record managerCounts: Record monthlyStats: Array<{ month: number; count: number }> } export function BiddingsStatsCards({ total, statusCounts, typeCounts, managerCounts, monthlyStats }: BiddingsStatsCardsProps) { // 이번 달 생성 건수 const currentMonth = new Date().getMonth() + 1 const thisMonthCount = monthlyStats.find(stat => stat.month === currentMonth)?.count || 0 // 지난 달 대비 증감 const lastMonthCount = monthlyStats.find(stat => stat.month === currentMonth - 1)?.count || 0 const monthlyGrowth = lastMonthCount > 0 ? ((thisMonthCount - lastMonthCount) / lastMonthCount * 100).toFixed(1) : '0' // 진행중인 입찰 수 (active 상태들) const activeStatuses = ['bidding_opened', 'bidding_closed', 'evaluation_of_bidding'] const activeBiddingsCount = activeStatuses.reduce((sum, status) => sum + (statusCounts[status] || 0), 0) // 완료된 입찰 수 const completedCount = statusCounts['vendor_selected'] || 0 // 가장 많은 담당자 const topManager = Object.entries(managerCounts).sort(([,a], [,b]) => b - a)[0] // 가장 많은 입찰 유형 const topBiddingType = Object.entries(typeCounts).sort(([,a], [,b]) => b - a)[0] return (
{/* 전체 입찰 수 */} 전체 입찰
{total.toLocaleString()}
{/*

이번 달 +{thisMonthCount}

*/}
{/* 진행중인 입찰 */} 진행중
{activeBiddingsCount}
{activeStatuses.map(status => ( statusCounts[status] > 0 && ( {biddingStatusLabels[status]}: {statusCounts[status]} ) ))}
{/* 완료된 입찰 */} 완료
{completedCount}

완료율 {total > 0 ? ((completedCount / total) * 100).toFixed(1) : 0}%

{/* 월별 증감 */} 월별 증감
= 0 ? 'text-green-600' : 'text-red-600'}> {Number(monthlyGrowth) >= 0 ? '+' : ''}{monthlyGrowth}%

지난 달 대비

) }