"use client"; import React from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Play, Pause, Edit, Trash2, RefreshCw, Clock, Database, ArrowRight, Globe, Calendar, Activity, Settings } from "lucide-react"; import { BatchConfig } from "@/lib/api/batch"; interface BatchCardProps { batch: BatchConfig; executingBatch: number | null; onExecute: (batchId: number) => void; onToggleStatus: (batchId: number, currentStatus: string) => void; onEdit: (batchId: number) => void; onDelete: (batchId: number, batchName: string) => void; getMappingSummary: (mappings: any[]) => string; } export default function BatchCard({ batch, executingBatch, onExecute, onToggleStatus, onEdit, onDelete, getMappingSummary }: BatchCardProps) { // 상태에 따른 색상 및 스타일 결정 const getStatusColor = () => { if (executingBatch === batch.id) return "bg-blue-50 border-blue-200"; if (batch.is_active === 'Y') return "bg-green-50 border-green-200"; return "bg-gray-50 border-gray-200"; }; const getStatusBadge = () => { if (executingBatch === batch.id) { return 실행 중; } return ( {batch.is_active === 'Y' ? '활성' : '비활성'} ); }; return ( {/* 헤더 섹션 */} {batch.batch_name} {getStatusBadge()} {batch.description || '\u00A0'} {/* 정보 섹션 */} {/* 스케줄 정보 */} {batch.cron_schedule} {/* 생성일 정보 */} {new Date(batch.created_date).toLocaleDateString('ko-KR')} {/* 매핑 정보 섹션 */} {batch.batch_mappings && batch.batch_mappings.length > 0 && ( 매핑 ({batch.batch_mappings.length}) {getMappingSummary(batch.batch_mappings)} )} {/* 액션 버튼 섹션 */} {/* 실행 버튼 */} onExecute(batch.id)} disabled={executingBatch === batch.id} className="flex items-center justify-center space-x-1 bg-blue-50 hover:bg-blue-100 text-blue-700 border-blue-200 text-xs h-6" > {executingBatch === batch.id ? ( ) : ( )} 실행 {/* 활성화/비활성화 버튼 */} onToggleStatus(batch.id, batch.is_active)} className={`flex items-center justify-center space-x-1 text-xs h-6 ${ batch.is_active === 'Y' ? 'bg-orange-50 hover:bg-orange-100 text-orange-700 border-orange-200' : 'bg-green-50 hover:bg-green-100 text-green-700 border-green-200' }`} > {batch.is_active === 'Y' ? ( ) : ( )} {batch.is_active === 'Y' ? '비활성' : '활성'} {/* 수정 버튼 */} onEdit(batch.id)} className="flex items-center justify-center space-x-1 bg-gray-50 hover:bg-gray-100 text-gray-700 border-gray-200 text-xs h-6" > 수정 {/* 삭제 버튼 */} onDelete(batch.id, batch.batch_name)} className="flex items-center justify-center space-x-1 bg-red-50 hover:bg-red-100 text-red-700 border-red-200 text-xs h-6" > 삭제 {/* 실행 중일 때 프로그레스 표시 */} {executingBatch === batch.id && ( 실행 중... )} ); }
{batch.description || '\u00A0'}