From a9575387c3a765a1a65ebc179dae16a21af6eb25 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 12 Sep 2025 08:01:02 +0000 Subject: (임수민) 일반 계약 템플릿 구현 및 basic contract 필터 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../general-contract-template-toolbar-actions.tsx | 131 +++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 lib/general-contract-template/template/general-contract-template-toolbar-actions.tsx (limited to 'lib/general-contract-template/template/general-contract-template-toolbar-actions.tsx') diff --git a/lib/general-contract-template/template/general-contract-template-toolbar-actions.tsx b/lib/general-contract-template/template/general-contract-template-toolbar-actions.tsx new file mode 100644 index 00000000..03818109 --- /dev/null +++ b/lib/general-contract-template/template/general-contract-template-toolbar-actions.tsx @@ -0,0 +1,131 @@ +"use client" + +import * as React from "react" +import { useRouter } from "next/navigation" +import { Trash2, FileText } from "lucide-react" +import { toast } from "sonner" + +import { Button } from "@/components/ui/button" +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" +import { disposeTemplates } from "../actions" +import { AddGeneralContractTemplateDialog } from "./add-general-contract-template-dialog" + +interface GeneralContractTemplateToolbarActionsProps { + selectedRows?: any[] + onSelectionChange?: (selectedRows: any[]) => void +} + +export function GeneralContractTemplateToolbarActions({ + selectedRows = [], + onSelectionChange +}: GeneralContractTemplateToolbarActionsProps) { + const router = useRouter() + const [isModifyOpen, setIsModifyOpen] = React.useState(false) + const [isDisposeOpen, setIsDisposeOpen] = React.useState(false) + const [isContractStatusOpen, setIsContractStatusOpen] = React.useState(false) + + // 폐기 버튼 클릭 + const handleDispose = () => { + if (selectedRows.length === 0) { + toast.error("폐기할 문서를 선택해주세요.") + return + } + + setIsDisposeOpen(true) + } + + // 계약현황 버튼 클릭 + const handleContractStatus = () => { + if (selectedRows.length === 0) { + toast.error("확인할 문서를 선택해주세요.") + return + } + + if (selectedRows.length > 1) { + toast.error("한 번에 하나의 문서만 확인할 수 있습니다.") + return + } + + // 일반계약관리 페이지로 이동 + router.push(`/evcp/general-contracts`) + } + + // 실제 폐기 처리 + const handleConfirmDispose = async () => { + try { + // 폐기할 템플릿 ID들 추출 + const templateIds = selectedRows.map(row => row.id) + + // Server Action 호출 + const result = await disposeTemplates(templateIds) + + toast.success(result.message) + setIsDisposeOpen(false) + + // 페이지 새로고침 또는 테이블 업데이트 + window.location.reload() + } catch (error) { + console.error('폐기 처리 오류:', error) + toast.error(error instanceof Error ? error.message : "폐기 처리 중 오류가 발생했습니다.") + } + } + + return ( + <> +
+ {/* 신규등록: 다이얼로그 사용 */} + + + {/* 계약현황 버튼 */} + + + {/* 폐기 버튼 */} + +
+ + {/* 폐기 확인 다이얼로그 */} + + + + 문서 폐기 확인 + + 선택된 {selectedRows.length}개의 문서를 폐기하시겠습니까? +
+ 폐기된 문서는 복구할 수 없습니다. +
+
+
+ + +
+
+
+ + ) +} -- cgit v1.2.3