summaryrefslogtreecommitdiff
path: root/lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-07-04 04:32:04 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-07-04 04:32:04 +0000
commit0793ef1e3aa2232ce72debd57ba449a699e0c734 (patch)
treea6eb1efcb74396890cbba211ae7054a4bc02d82b /lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx
parentb9a109073d11262dd7ed84e25ff3cd0144c0c391 (diff)
(최겸) 0704 평가기준표 수정(create, detail, update 및 excel 기능)
Diffstat (limited to 'lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx')
-rw-r--r--lib/evaluation-criteria/table/reg-eval-criteria-table-toolbar-actions.tsx37
1 files changed, 25 insertions, 12 deletions
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 f066fa92..7594f07f 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,11 +14,9 @@ import {
} from '@/components/ui/alert-dialog';
import { Button } from '@/components/ui/button';
import { Download, Plus, Trash2, Upload } from 'lucide-react';
-import { exportRegEvalCriteriaToExcel, exportRegEvalCriteriaTemplate } from '../excel/reg-eval-criteria-excel-export';
-import { importRegEvalCriteriaExcel } from '../excel/reg-eval-criteria-excel-import';
-import { removeRegEvalCriteria } from '../service';
+import { removeRegEvalCriteria, generateRegEvalCriteriaTemplate, generateRegEvalCriteriaExcel, importRegEvalCriteriaExcel } from '../service';
import { toast } from 'sonner';
-import { type RegEvalCriteriaView } from '@/db/schema';
+import { type RegEvalCriteria } from '@/db/schema';
import { type Table } from '@tanstack/react-table';
import { ChangeEvent, useMemo, useRef, useState } from 'react';
@@ -26,7 +24,7 @@ import { ChangeEvent, useMemo, useRef, useState } from 'react';
/* TYPES */
interface RegEvalCriteriaTableToolbarActionsProps {
- table: Table<RegEvalCriteriaView>,
+ table: Table<RegEvalCriteria>,
onCreateCriteria: () => void,
onRefresh: () => void,
}
@@ -40,7 +38,7 @@ function RegEvalCriteriaTableToolbarActions(props: RegEvalCriteriaTableToolbarAc
const selectedRows = table.getFilteredSelectedRowModel().rows;
const hasSelection = selectedRows.length > 0;
const selectedIds = useMemo(() => {
- return [...new Set(selectedRows.map(row => row.original.criteriaId))];
+ return [...new Set(selectedRows.map(row => row.original.id))];
}, [selectedRows]);
const fileInputRef = useRef<HTMLInputElement>(null);
@@ -117,14 +115,20 @@ function RegEvalCriteriaTableToolbarActions(props: RegEvalCriteriaTableToolbarAc
}
};
- // Excel Export
+ // Excel Export (DB에서 1:n 관계 포함하여 전체 데이터 내보내기)
const handleExport = async () => {
try {
- await exportRegEvalCriteriaToExcel(table, {
- filename: 'Regular_Evaluation_Criteria',
- excludeColumns: ['select', 'actions'],
+ const buffer = await generateRegEvalCriteriaExcel();
+ const blob = new Blob([buffer], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
- toast.success('Excel 파일이 다운로드되었습니다.');
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = "평가_기준_전체.xlsx";
+ link.click();
+ URL.revokeObjectURL(url);
+ toast.success('Excel 파일이 다운로드되었습니다. (모든 평가내용 포함)');
} catch (error) {
console.error('Error in Exporting to Excel: ', error);
toast.error('Excel 내보내기 중 오류가 발생했습니다.');
@@ -134,7 +138,16 @@ function RegEvalCriteriaTableToolbarActions(props: RegEvalCriteriaTableToolbarAc
// Excel Template Download
const handleTemplateDownload = async () => {
try {
- await exportRegEvalCriteriaTemplate();
+ const buffer = await generateRegEvalCriteriaTemplate();
+ const blob = new Blob([buffer], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ });
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = "평가_기준_템플릿.xlsx";
+ link.click();
+ URL.revokeObjectURL(url);
toast.success('템플릿 파일이 다운로드되었습니다.');
} catch (error) {
console.error('Error in Template Download: ', error);