diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-21 07:54:26 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-21 07:54:26 +0000 |
| commit | 14f61e24947fb92dd71ec0a7196a6e815f8e66da (patch) | |
| tree | 317c501d64662d05914330628f867467fba78132 /lib/tech-vendor-possible-items/table/possible-items-table-toolbar-actions.tsx | |
| parent | 194bd4bd7e6144d5c09c5e3f5476d254234dce72 (diff) | |
(최겸)기술영업 RFQ 담당자 초대, 요구사항 반영
Diffstat (limited to 'lib/tech-vendor-possible-items/table/possible-items-table-toolbar-actions.tsx')
| -rw-r--r-- | lib/tech-vendor-possible-items/table/possible-items-table-toolbar-actions.tsx | 86 |
1 files changed, 32 insertions, 54 deletions
diff --git a/lib/tech-vendor-possible-items/table/possible-items-table-toolbar-actions.tsx b/lib/tech-vendor-possible-items/table/possible-items-table-toolbar-actions.tsx index 3628f87e..dc67221f 100644 --- a/lib/tech-vendor-possible-items/table/possible-items-table-toolbar-actions.tsx +++ b/lib/tech-vendor-possible-items/table/possible-items-table-toolbar-actions.tsx @@ -2,12 +2,13 @@ import * as React from "react";
import { type Table } from "@tanstack/react-table";
-import { Download, Upload, FileSpreadsheet, Trash2 } from "lucide-react";
+import { Download, Upload, FileSpreadsheet, Plus } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { useToast } from "@/hooks/use-toast";
-import { deleteTechVendorPossibleItems } from "@/lib/tech-vendor-possible-items/service";
+import { AddPossibleItemDialog } from "./add-possible-item-dialog";
+import { DeletePossibleItemsDialog } from "./delete-possible-items-dialog";
// Excel 함수들을 동적 import로만 사용하기 위해 타입만 import
type TechVendorPossibleItemsData = {
id: number;
@@ -16,6 +17,10 @@ type TechVendorPossibleItemsData = { vendorName: string;
techVendorType: string;
itemCode: string;
+ itemList: string | null;
+ workType: string | null;
+ shipTypes: string | null;
+ subItemList: string | null;
createdAt: Date;
updatedAt: Date;
};
@@ -28,44 +33,15 @@ export function PossibleItemsTableToolbarActions({ table,
}: PossibleItemsTableToolbarActionsProps) {
const { toast } = useToast();
- const [isPending, startTransition] = React.useTransition();
const selectedRows = table.getFilteredSelectedRowModel().rows;
const hasSelection = selectedRows.length > 0;
+ const selectedItems = selectedRows.map(row => row.original);
- const handleDelete = () => {
- if (!hasSelection) return;
-
- startTransition(async () => {
- const selectedIds = selectedRows.map((row) => row.original.id);
-
- try {
- const result = await deleteTechVendorPossibleItems(selectedIds);
-
- if (result.success) {
- toast({
- title: "성공",
- description: `${selectedIds.length}개의 아이템이 삭제되었습니다.`,
- });
- table.toggleAllRowsSelected(false);
- // 페이지 새로고침이나 데이터 다시 로드 필요
- window.location.reload();
- } else {
- toast({
- title: "오류",
- description: result.error || "삭제 중 오류가 발생했습니다.",
- variant: "destructive",
- });
- }
- } catch (error) {
- console.error("Delete error:", error);
- toast({
- title: "오류",
- description: "삭제 중 오류가 발생했습니다.",
- variant: "destructive",
- });
- }
- });
+ const handleSuccess = () => {
+ table.toggleAllRowsSelected(false);
+ // 페이지 새로고침이나 데이터 다시 로드 필요
+ window.location.reload();
};
const handleExport = async () => {
@@ -158,17 +134,27 @@ export function PossibleItemsTableToolbarActions({ return (
<div className="flex items-center gap-2">
- {hasSelection && (
- <Button
- variant="destructive"
- size="sm"
- onClick={handleDelete}
- disabled={isPending}
- >
- <Trash2 className="mr-2 h-4 w-4" />
- 삭제 ({selectedRows.length})
- </Button>
+ {hasSelection && (
+ <DeletePossibleItemsDialog
+ selectedItems={selectedItems}
+ onSuccess={handleSuccess}
+ />
)}
+ <AddPossibleItemDialog onSuccess={handleSuccess}>
+ <Button size="sm">
+ <Plus className="mr-2 h-4 w-4" />
+ 추가
+ </Button>
+ </AddPossibleItemDialog>
+
+ <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" />
@@ -183,14 +169,6 @@ export function PossibleItemsTableToolbarActions({ className="hidden"
/>
- <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={handleDownloadTemplate}>
<FileSpreadsheet className="mr-2 h-4 w-4" />
|
