From a3525f8bdfcf849cc1716fab81cb8facadbe9a8e Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 27 Oct 2025 10:03:06 +0000
Subject: (최겸) 구매 협력업체 관리(PQ/실사관리, 정기평가 협력업체 제출 상세
 dialog 개발,
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/pq/pq-criteria/pq-table-toolbar-actions.tsx | 48 ++++++++++++++++++-------
 1 file changed, 35 insertions(+), 13 deletions(-)

(limited to 'lib/pq/pq-criteria/pq-table-toolbar-actions.tsx')

diff --git a/lib/pq/pq-criteria/pq-table-toolbar-actions.tsx b/lib/pq/pq-criteria/pq-table-toolbar-actions.tsx
index f168b83d..cdc4f813 100644
--- a/lib/pq/pq-criteria/pq-table-toolbar-actions.tsx
+++ b/lib/pq/pq-criteria/pq-table-toolbar-actions.tsx
@@ -17,37 +17,59 @@ import { type Table } from "@tanstack/react-table"
 import { DeletePqsDialog } from "./delete-pqs-dialog"
 import { AddPqDialog } from "./add-pq-dialog"
 import { PqCriterias } from "@/db/schema/pq"
+import { toast } from "sonner"
 // import { ImportPqButton } from "./import-pq-button"
 // import { exportPqTemplate } from "./pq-excel-template"
 
 interface PqTableToolbarActionsProps {
   table: Table<PqCriterias>
   pqListId: number
+  pqListInfo: Awaited<ReturnType<typeof import("../service").getPQListInfo>>
 }
 
 export function PqTableToolbarActions({ 
   table, 
-  pqListId
+  pqListId,
+  pqListInfo
 }: PqTableToolbarActionsProps) {
-  // const [refreshKey, setRefreshKey] = React.useState(0)
+  // PQ 리스트가 ACTIVE 상태인지 확인
+  const isActive = pqListInfo.success && pqListInfo.data.status === "ACTIVE";
   
-  // // Import 성공 후 테이블 갱신
-  // const handleImportSuccess = () => {
-  //   setRefreshKey(prev => prev + 1)
-  // }
+  // ACTIVE 상태일 때 기능 제한
+  const handleRestrictedAction = () => {
+    toast.error("활성화된 PQ 목록은 수정할 수 없습니다. 먼저 PQ 목록을 비활성화해주세요.");
+  };
   
   return (
     <div className="flex items-center gap-2">
       {table.getFilteredSelectedRowModel().rows.length > 0 ? (
-        <DeletePqsDialog
-          pqs={table
-            .getFilteredSelectedRowModel()
-            .rows.map((row) => row.original)}
-          onSuccess={() => table.toggleAllRowsSelected(false)}
-        />
+        isActive ? (
+          <button
+            onClick={handleRestrictedAction}
+            className="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 px-3 text-destructive hover:text-destructive"
+          >
+            PQ 항목 삭제
+          </button>
+        ) : (
+          <DeletePqsDialog
+            pqs={table
+              .getFilteredSelectedRowModel()
+              .rows.map((row) => row.original)}
+            onSuccess={() => table.toggleAllRowsSelected(false)}
+          />
+        )
       ) : null}
       
-      <AddPqDialog pqListId={pqListId} />
+      {isActive ? (
+        <button
+          onClick={handleRestrictedAction}
+          className="inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-9 px-3"
+        >
+          PQ 항목 추가
+        </button>
+      ) : (
+        <AddPqDialog pqListId={pqListId} />
+      )}
       
       {/* Import 버튼 */}
       {/* <ImportPqButton 
-- 
cgit v1.2.3

