From ec67f25270df089fa65315091afa24f0e8995b98 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Thu, 6 Nov 2025 12:20:19 +0900
Subject: (김준회) 결재 후처리 강제실행 기능 추가
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/approval-log-table-column.tsx            | 50 +++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

(limited to 'lib/approval-log/table/approval-log-table-column.tsx')

diff --git a/lib/approval-log/table/approval-log-table-column.tsx b/lib/approval-log/table/approval-log-table-column.tsx
index 747ce5ce..6005b0ff 100644
--- a/lib/approval-log/table/approval-log-table-column.tsx
+++ b/lib/approval-log/table/approval-log-table-column.tsx
@@ -8,14 +8,17 @@ import { Checkbox } from "@/components/ui/checkbox"
 import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header"
 import { type ApprovalLog } from "../service"
 import { formatDate } from "@/lib/utils"
-import { MoreHorizontal, Eye } from "lucide-react"
+import { MoreHorizontal, Eye, PlayCircle } from "lucide-react"
 import {
   DropdownMenu,
   DropdownMenuContent,
   DropdownMenuItem,
+  DropdownMenuSeparator,
   DropdownMenuTrigger,
 } from "@/components/ui/dropdown-menu"
 import { useParams, useRouter } from "next/navigation"
+import { forcePostProcessApproval } from "../actions"
+import { toast } from "sonner"
 
 interface GetColumnsProps {
   setRowAction: React.Dispatch<React.SetStateAction<{
@@ -256,6 +259,39 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<Approva
       id: "actions",
       cell: ({ row }) => {
         const apInfId = row.original.apInfId;
+        // eslint-disable-next-line react-hooks/rules-of-hooks
+        const [isProcessing, setIsProcessing] = React.useState(false);
+
+        // 항상 후처리 메뉴를 표시 (서버에서 검증)
+        const canPostProcess = true;
+
+        const handlePostProcess = async () => {
+          if (isProcessing) return;
+          
+          setIsProcessing(true);
+          try {
+            const result = await forcePostProcessApproval(apInfId);
+            
+            if (result.success) {
+              toast.success('후처리 성공', {
+                description: result.message,
+              });
+              // 페이지 새로고침
+              router.refresh();
+            } else {
+              toast.error('후처리 실패', {
+                description: result.error,
+              });
+            }
+          } catch (error) {
+            toast.error('후처리 오류', {
+              description: error instanceof Error ? error.message : '알 수 없는 오류가 발생했습니다.',
+            });
+          } finally {
+            setIsProcessing(false);
+          }
+        };
+
         return (
           <DropdownMenu>
             <DropdownMenuTrigger asChild>
@@ -276,6 +312,18 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<Approva
                 <Eye className="mr-2 size-4" aria-hidden="true" />
                 상세보기
               </DropdownMenuItem>
+              {canPostProcess && (
+                <>
+                  <DropdownMenuSeparator />
+                  <DropdownMenuItem
+                    onClick={handlePostProcess}
+                    disabled={isProcessing}
+                  >
+                    <PlayCircle className="mr-2 size-4" aria-hidden="true" />
+                    {isProcessing ? '처리중...' : '후처리 실행'}
+                  </DropdownMenuItem>
+                </>
+              )}
             </DropdownMenuContent>
           </DropdownMenu>
         );
-- 
cgit v1.2.3

