diff --git a/frontend/app/(main)/admin/batchmng/page.tsx b/frontend/app/(main)/admin/batchmng/page.tsx index cee17c38..184ae578 100644 --- a/frontend/app/(main)/admin/batchmng/page.tsx +++ b/frontend/app/(main)/admin/batchmng/page.tsx @@ -4,7 +4,6 @@ import React, { useState, useEffect } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; -import { Badge } from "@/components/ui/badge"; import { Table, TableBody, @@ -16,15 +15,8 @@ import { import { Plus, Search, - Play, - Pause, - Edit, - Trash2, RefreshCw, - Clock, - Database, - ArrowRight, - Globe + Database } from "lucide-react"; import { toast } from "sonner"; import { useRouter } from "next/navigation"; @@ -33,6 +25,7 @@ import { BatchConfig, BatchMapping, } from "@/lib/api/batch"; +import BatchCard from "@/components/admin/BatchCard"; export default function BatchManagementPage() { const router = useRouter(); @@ -185,7 +178,7 @@ export default function BatchManagementPage() { }; return ( -
+
{/* 헤더 */}
@@ -203,7 +196,7 @@ export default function BatchManagementPage() { {/* 검색 및 필터 */} - +
@@ -254,100 +247,21 @@ export default function BatchManagementPage() { )}
) : ( -
+
{batchConfigs.map((batch) => ( -
- {/* 배치 기본 정보 */} -
-
-
-

{batch.batch_name}

- - {batch.is_active === 'Y' ? '활성' : '비활성'} - -
- {batch.description && ( -

{batch.description}

- )} -
-
- - {batch.cron_schedule} -
-
- 생성일: {new Date(batch.created_date).toLocaleDateString()} -
-
-
- - {/* 액션 버튼들 */} -
- - - - - - - -
-
- - {/* 매핑 정보 */} - {batch.batch_mappings && batch.batch_mappings.length > 0 && ( -
-

- 매핑 정보 ({batch.batch_mappings.length}개) -

-
- {getMappingSummary(batch.batch_mappings)} -
-
- )} -
+ { + console.log("🖱️ 비활성화/활성화 버튼 클릭:", { batchId, currentStatus }); + toggleBatchStatus(batchId, currentStatus); + }} + onEdit={(batchId) => router.push(`/admin/batchmng/edit/${batchId}`)} + onDelete={deleteBatch} + getMappingSummary={getMappingSummary} + /> ))}
)} diff --git a/frontend/components/admin/BatchCard.tsx b/frontend/components/admin/BatchCard.tsx new file mode 100644 index 00000000..ed8dd94e --- /dev/null +++ b/frontend/components/admin/BatchCard.tsx @@ -0,0 +1,185 @@ +"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)} +
+
+ )} + + {/* 액션 버튼 섹션 */} +
+ {/* 실행 버튼 */} + + + {/* 활성화/비활성화 버튼 */} + + + {/* 수정 버튼 */} + + + {/* 삭제 버튼 */} + +
+ + {/* 실행 중일 때 프로그레스 표시 */} + {executingBatch === batch.id && ( +
+
+ + 실행 중... +
+
+
+
+
+ )} +
+
+ ); +}