From 25b916d040a512cd5248dff319d727ae144d0652 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 15 Sep 2025 03:24:12 +0000 Subject: (최겸) 구매 PCR 개발(po -> pcr, ecc pcr-confirm test 필) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pcr/table/pcr-table-toolbar-actions.tsx | 120 ++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 lib/pcr/table/pcr-table-toolbar-actions.tsx (limited to 'lib/pcr/table/pcr-table-toolbar-actions.tsx') diff --git a/lib/pcr/table/pcr-table-toolbar-actions.tsx b/lib/pcr/table/pcr-table-toolbar-actions.tsx new file mode 100644 index 00000000..3e2394fb --- /dev/null +++ b/lib/pcr/table/pcr-table-toolbar-actions.tsx @@ -0,0 +1,120 @@ +"use client" + +import * as React from "react" +import { Button } from "@/components/ui/button" +import { Loader2, RefreshCw, Download, CheckCircle, XCircle } from "lucide-react" +import type { Table } from "@tanstack/react-table" +import { CreatePcrDialog } from "./create-pcr-dialog" +import { ApproveRejectPcrDialog } from "./approve-reject-pcr-dialog" +import { PcrPoData } from "@/lib/pcr/types" + +interface PcrTableToolbarActionsProps { + selection: Table + onRefresh: () => void + isEvcpPage?: boolean + isPartnersPage?: boolean + currentVendorId?: number +} + +export function PcrTableToolbarActions({ + selection, + onRefresh, + isEvcpPage = false, + isPartnersPage = false, + currentVendorId, +}: PcrTableToolbarActionsProps) { + const [approveDialogOpen, setApproveDialogOpen] = React.useState(false) + const [rejectDialogOpen, setRejectDialogOpen] = React.useState(false) + const [selectedPcr, setSelectedPcr] = React.useState(null) + + // 선택된 행들 가져오기 + const selectedRows = selection.getSelectedRowModel().rows + const selectedPcrData = selectedRows.length === 1 ? (selectedRows[0].original as PcrPoData) : null + + // 승인/거절 가능 여부 확인 + // const canApproveOrReject = selectedPcrData && selectedPcrData.pcrApprovalStatus === '승인대기' + const canApproveOrReject = selectedPcrData // 임시로 주석 처리하여 테스트 + + + + const handleExport = () => { + // 추후 구현 + console.log("Export functionality to be implemented") + } + + const handleApprove = () => { + if (selectedPcrData) { + setSelectedPcr(selectedPcrData) + setApproveDialogOpen(true) + } + } + + const handleReject = () => { + if (selectedPcrData) { + setSelectedPcr(selectedPcrData) + setRejectDialogOpen(true) + } + } + + const handleActionSuccess = () => { + // 액션 성공 시 선택 해제 + selection.resetRowSelection() + // revalidatePath로 인해 자동으로 페이지 새로고침됨 + } + + return ( +
+ + {/* 승인 버튼 */} + + + {/* 거절 버튼 */} + + + {/* PCR 생성 다이얼로그 - Partners 페이지에서는 표시하지 않음 */} + {!isPartnersPage && ( + + )} + + {/* 승인 다이얼로그 */} + + + {/* 거절 다이얼로그 */} + +
+ ) +} -- cgit v1.2.3