From 1110427907bbe9c11a378da4c1a233b83b5ca3b1 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Tue, 26 Aug 2025 12:09:39 +0000 Subject: (김준회) 구매정의서 구현 - PO (shi & vendor) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/po/vendor-table/vendor-po-toolbar-actions.tsx | 214 ++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 lib/po/vendor-table/vendor-po-toolbar-actions.tsx (limited to 'lib/po/vendor-table/vendor-po-toolbar-actions.tsx') diff --git a/lib/po/vendor-table/vendor-po-toolbar-actions.tsx b/lib/po/vendor-table/vendor-po-toolbar-actions.tsx new file mode 100644 index 00000000..800a9e40 --- /dev/null +++ b/lib/po/vendor-table/vendor-po-toolbar-actions.tsx @@ -0,0 +1,214 @@ +"use client" + +import * as React from "react" +import { type Table } from "@tanstack/react-table" +import { + EyeIcon, + EditIcon, + FileXIcon, + PrinterIcon, +} from "lucide-react" + +import { Button } from "@/components/ui/button" +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu" +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip" +import { toast } from "sonner" +import { VendorPO } from "./types" + +interface VendorPOToolbarActionsProps { + table: Table + selectedRows: number[] + onAction: (poId: number, action: string) => Promise + onViewItems?: (po: VendorPO) => void +} + +export function VendorPOToolbarActions({ + table, + selectedRows, + onAction, + onViewItems +}: VendorPOToolbarActionsProps) { + const hasSelectedRow = selectedRows.length === 1 + const selectedPO = hasSelectedRow ? + table.getRowModel().rows.find(row => selectedRows.includes(row.original.id))?.original + : null + + const handleToolbarAction = async (action: string) => { + if (!hasSelectedRow || !selectedPO) { + toast.error("먼저 PO를 선택해주세요.") + return + } + + // view-items 액션은 특별히 처리 + if (action === "view-items") { + if (onViewItems) { + onViewItems(selectedPO) + } + return + } + + await onAction(selectedPO.id, action) + } + + return ( +
+ {/* 주요 액션 버튼들 */} + + + + + + 선택된 PO에 대한 PCR을 생성합니다 + + + + + + + + + 상세품목 현황을 확인합니다 + + + + {/* 승인 관련 액션 */} + {selectedPO?.contractStatus !== "승인완료" && ( + + + + + + 선택된 계약을 승인합니다 + + + )} + + {selectedPO?.contractStatus === "승인완료" && ( + + + + + + 승인을 취소합니다 + + + )} + + {/* 더 많은 액션 드롭다운 */} + + + + + + 계약 관련 + + + handleToolbarAction("contract-detail")} + disabled={!hasSelectedRow} + > + + 계약상세 + + + handleToolbarAction("po-note")} + disabled={!hasSelectedRow} + > + + PO Note + + + handleToolbarAction("price-index")} + disabled={!hasSelectedRow} + > + + 연동표입력 + + + + + handleToolbarAction("reject-contract")} + disabled={!hasSelectedRow} + className="text-red-600 focus:text-red-600" + > + + 계약거절 + + + + + handleToolbarAction("print-contract")} + disabled={!hasSelectedRow} + > + + 계약서출력 + + + + + {/* 선택된 행 정보 표시 + {hasSelectedRow && selectedPO && ( +
+ 선택됨: + {selectedPO.contractNo} + ({selectedPO.contractName}) +
+ )} */} +
+ ) +} -- cgit v1.2.3