From 3f0fad18483a5c800c79c5e33946d9bb384c10e2 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Fri, 27 Jun 2025 06:52:38 +0000
Subject: (최겸) 협력업체 평가기준표 excel 기능 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../reg-eval-criteria-table-toolbar-actions.tsx    | 29 +++++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)

(limited to 'lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx')

diff --git a/lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx b/lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx
index b14cb22f..f066fa92 100644
--- a/lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx
+++ b/lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx
@@ -14,8 +14,9 @@ import {
 } from '@/components/ui/alert-dialog';
 import { Button } from '@/components/ui/button';
 import { Download, Plus, Trash2, Upload } from 'lucide-react';
-import { exportTableToExcel } from '@/lib/export';
-import { importRegEvalCriteriaExcel, removeRegEvalCriteria } from '../service';
+import { exportRegEvalCriteriaToExcel, exportRegEvalCriteriaTemplate } from '../excel/reg-eval-criteria-excel-export';
+import { importRegEvalCriteriaExcel } from '../excel/reg-eval-criteria-excel-import';
+import { removeRegEvalCriteria } from '../service';
 import { toast } from 'sonner';
 import { type RegEvalCriteriaView } from '@/db/schema';
 import { type Table } from '@tanstack/react-table';
@@ -117,9 +118,9 @@ function RegEvalCriteriaTableToolbarActions(props: RegEvalCriteriaTableToolbarAc
   };
 
   // Excel Export
-  const handleExport = () => {
+  const handleExport = async () => {
     try {
-      exportTableToExcel(table, {
+      await exportRegEvalCriteriaToExcel(table, {
         filename: 'Regular_Evaluation_Criteria',
         excludeColumns: ['select', 'actions'],
       });
@@ -130,6 +131,17 @@ function RegEvalCriteriaTableToolbarActions(props: RegEvalCriteriaTableToolbarAc
     }
   };
 
+  // Excel Template Download
+  const handleTemplateDownload = async () => {
+    try {
+      await exportRegEvalCriteriaTemplate();
+      toast.success('템플릿 파일이 다운로드되었습니다.');
+    } catch (error) {
+      console.error('Error in Template Download: ', error);
+      toast.error('템플릿 다운로드 중 오류가 발생했습니다.');
+    }
+  };
+
   return (
     <div className="flex items-center gap-2">
       <Button
@@ -201,6 +213,15 @@ function RegEvalCriteriaTableToolbarActions(props: RegEvalCriteriaTableToolbarAc
         <Download className="size-4" aria-hidden="true" />
         <span className="hidden sm:inline">Export</span>
       </Button>
+      <Button
+        variant="outline"
+        size="sm"
+        onClick={handleTemplateDownload}
+        className="gap-2"
+      >
+        <Download className="size-4" aria-hidden="true" />
+        <span className="hidden sm:inline">Template</span>
+      </Button>
     </div>
   );
 }
-- 
cgit v1.2.3

