1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
"use client";
import * as React from "react";
import { type Table } from "@tanstack/react-table";
// import { Plus } from "lucide-react";
// import { Button } from "@/components/ui/button";
// import { Input } from "@/components/ui/input"; // 주석처리 (Excel 기능 사용 안함)
// import { useToast } from "@/hooks/use-toast"; // 주석처리 (Excel 기능 사용 안함)
// import { AddPossibleItemDialog } from "./add-possible-item-dialog";
// import { DeletePossibleItemsDialog } from "./delete-possible-items-dialog";
// 새로운 스키마에 맞는 타입 import
import type { TechVendorPossibleItemsData } from "../service";
interface PossibleItemsTableToolbarActionsProps {
table: Table<TechVendorPossibleItemsData>;
}
export function PossibleItemsTableToolbarActions({
// table,
}: PossibleItemsTableToolbarActionsProps) {
// const { toast } = useToast(); // 주석처리 (Excel 기능 사용 안함)
// const selectedRows = table.getFilteredSelectedRowModel().rows;
// const hasSelection = selectedRows.length > 0;
// const selectedItems = selectedRows.map(row => row.original);
// const handleSuccess = () => {
// table.toggleAllRowsSelected(false);
// // 페이지 새로고침이나 데이터 다시 로드 필요
// window.location.reload();
// };
// Excel Export 함수 주석처리 (새 스키마에서 사용하지 않음)
// const handleExport = async () => {
// try {
// const { exportTechVendorPossibleItemsToExcel } = await import("./excel-export");
// const result = await exportTechVendorPossibleItemsToExcel(table.getFilteredRowModel().rows.map(row => row.original));
//
// if (result.success) {
// toast({
// title: "성공",
// description: "Excel 파일이 다운로드되었습니다.",
// });
// } else {
// toast({
// title: "오류",
// description: result.error || "내보내기 중 오류가 발생했습니다.",
// variant: "destructive",
// });
// }
// } catch (error) {
// console.error("Export error:", error);
// toast({
// title: "오류",
// description: "내보내기 중 오류가 발생했습니다.",
// variant: "destructive",
// });
// }
// };
// Excel Import 함수 주석처리 (새 스키마에서 사용하지 않음)
// const handleImport = async (event: React.ChangeEvent<HTMLInputElement>) => {
// const file = event.target.files?.[0];
// if (!file) return;
// try {
// const { importTechVendorPossibleItemsFromExcel } = await import("./excel-import");
// const result = await importTechVendorPossibleItemsFromExcel(file);
//
// if (result.success) {
// toast({
// title: "성공",
// description: `${result.successCount}개의 아이템이 가져와졌습니다.`,
// });
// // 페이지 새로고침이나 데이터 다시 로드 필요
// window.location.reload();
// } else {
// toast({
// title: "가져오기 완료",
// description: `${result.successCount}개 성공, ${result.failedRows.length}개 실패`,
// variant: result.successCount > 0 ? "default" : "destructive",
// });
// }
// } catch (error) {
// console.error("Import error:", error);
// toast({
// title: "오류",
// description: "가져오기 중 오류가 발생했습니다.",
// variant: "destructive",
// });
// }
// // Reset input
// event.target.value = "";
// };
// Excel Template 함수 주석처리 (새 스키마에서 사용하지 않음)
// const handleDownloadTemplate = async () => {
// try {
// const { exportTechVendorPossibleItemsTemplate } = await import("./excel-template");
// const result = await exportTechVendorPossibleItemsTemplate();
// if (result.success) {
// toast({
// title: "성공",
// description: "템플릿 파일이 다운로드되었습니다.",
// });
// } else {
// toast({
// title: "오류",
// description: result.error || "템플릿 다운로드 중 오류가 발생했습니다.",
// variant: "destructive",
// });
// }
// } catch (error) {
// console.error("Template download error:", error);
// toast({
// title: "오류",
// description: "템플릿 다운로드 중 오류가 발생했습니다.",
// variant: "destructive",
// });
// }
// };
return (
<div className="flex items-center gap-2">
{/* {hasSelection && ( */}
{/* // <DeletePo ssibleItemsDialog
// selectedItems={selectedItems}
// onSuccess={handleSuccess}
// />
// )}
// <AddPossibleItemDialog onSuccess={handleSuccess}>
// <Button size="sm">
// <Plus className="mr-2 h-4 w-4" />
// 추가
// </Button>
// </AddPossibleItemDialog>
{/* Excel 관련 버튼들 주석처리 (새 스키마에서 사용하지 않음) */}
{/* <Button
variant="outline"
size="sm"
onClick={() => document.getElementById("import-file")?.click()}
>
<Upload className="mr-2 h-4 w-4" />
Import
</Button>
<Button variant="outline" size="sm" onClick={handleExport}>
<Download className="mr-2 h-4 w-4" />
Export
</Button>
<Input
id="import-file"
type="file"
accept=".xlsx,.xls"
onChange={handleImport}
className="hidden"
/>
<Button variant="outline" size="sm" onClick={handleDownloadTemplate}>
<FileSpreadsheet className="mr-2 h-4 w-4" />
Download Template
</Button> */}
</div>
);
}
|