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-column.tsx | 50 ++++++++++++++++++++++++++--------
 1 file changed, 39 insertions(+), 11 deletions(-)

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

diff --git a/lib/pq/pq-criteria/pq-table-column.tsx b/lib/pq/pq-criteria/pq-table-column.tsx
index 32d6cc32..ed1180f7 100644
--- a/lib/pq/pq-criteria/pq-table-column.tsx
+++ b/lib/pq/pq-criteria/pq-table-column.tsx
@@ -18,13 +18,16 @@ import { Button } from "@/components/ui/button"
 import { Ellipsis } from "lucide-react"
 import { Badge } from "@/components/ui/badge"
 import { PqCriterias } from "@/db/schema/pq"
+import { toast } from "sonner"
 
 interface GetColumnsProps {
   setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<PqCriterias> | null>>
+  pqListInfo?: Awaited<ReturnType<typeof import("../service").getPQListInfo>>
 }
 
 export function getColumns({
   setRowAction,
+  pqListInfo,
 }: GetColumnsProps): ColumnDef<PqCriterias>[] {
   return [
  {
@@ -205,6 +208,12 @@ export function getColumns({
       id: "actions",
       enableHiding: false,
       cell: function Cell({ row }) {
+        const isActive = pqListInfo?.success && pqListInfo.data.status === "ACTIVE";
+        
+        const handleRestrictedAction = () => {
+          toast.error("활성화된 PQ 목록은 수정할 수 없습니다. 먼저 PQ 목록을 비활성화해주세요.");
+        };
+        
         return (
           <DropdownMenu>
             <DropdownMenuTrigger asChild>
@@ -217,18 +226,37 @@ export function getColumns({
               </Button>
             </DropdownMenuTrigger>
             <DropdownMenuContent align="end" className="w-40">
-              <DropdownMenuItem
-                onSelect={() => setRowAction({ row, type: "update" })}
-              >
-                Edit
-              </DropdownMenuItem>
+              {isActive ? (
+                <DropdownMenuItem
+                  onSelect={handleRestrictedAction}
+                  className="text-muted-foreground"
+                >
+                  Edit
+                </DropdownMenuItem>
+              ) : (
+                <DropdownMenuItem
+                  onSelect={() => setRowAction({ row, type: "update" })}
+                >
+                  Edit
+                </DropdownMenuItem>
+              )}
 
-              <DropdownMenuItem
-                onSelect={() => setRowAction({ row, type: "delete" })}
-              >
-                Delete
-                <DropdownMenuShortcut>⌘⌫</DropdownMenuShortcut>
-              </DropdownMenuItem>
+              {isActive ? (
+                <DropdownMenuItem
+                  onSelect={handleRestrictedAction}
+                  className="text-muted-foreground"
+                >
+                  Delete
+                  <DropdownMenuShortcut>⌘⌫</DropdownMenuShortcut>
+                </DropdownMenuItem>
+              ) : (
+                <DropdownMenuItem
+                  onSelect={() => setRowAction({ row, type: "delete" })}
+                >
+                  Delete
+                  <DropdownMenuShortcut>⌘⌫</DropdownMenuShortcut>
+                </DropdownMenuItem>
+              )}
             </DropdownMenuContent>
           </DropdownMenu>
         )
-- 
cgit v1.2.3

