From 1e6d30c9f649dcaa0c1d24561af35d7a77fd51b2 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Tue, 18 Nov 2025 10:31:47 +0000
Subject: (최겸) 구매 법무검토 조회 dialog 개발
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ...basic-contract-detail-table-toolbar-actions.tsx | 135 +--------------------
 1 file changed, 5 insertions(+), 130 deletions(-)

(limited to 'lib/basic-contract/status-detail/basic-contract-detail-table-toolbar-actions.tsx')

diff --git a/lib/basic-contract/status-detail/basic-contract-detail-table-toolbar-actions.tsx b/lib/basic-contract/status-detail/basic-contract-detail-table-toolbar-actions.tsx
index 37ae135c..c71be9d1 100644
--- a/lib/basic-contract/status-detail/basic-contract-detail-table-toolbar-actions.tsx
+++ b/lib/basic-contract/status-detail/basic-contract-detail-table-toolbar-actions.tsx
@@ -2,7 +2,7 @@
 
 import * as React from "react"
 import { type Table } from "@tanstack/react-table"
-import { Download, FileDown, Mail, Scale, CheckCircle, AlertTriangle, Send, Gavel, Check, FileSignature } from "lucide-react"
+import { Download, FileDown, Mail, CheckCircle, AlertTriangle, Send, Check, FileSignature } from "lucide-react"
 
 import { exportTableToExcel } from "@/lib/export"
 import { downloadFile } from "@/lib/file-download"
@@ -18,11 +18,9 @@ import {
     DialogTitle,
 } from "@/components/ui/dialog"
 import { Badge } from "@/components/ui/badge"
-import { Textarea } from "@/components/ui/textarea"
-import { Label } from "@/components/ui/label"
-import { Separator } from "@/components/ui/separator"
-import { prepareFinalApprovalAction, quickFinalApprovalAction, requestLegalReviewAction, resendContractsAction } from "../service"
+import { prepareFinalApprovalAction, quickFinalApprovalAction, resendContractsAction } from "../service"
 import { BasicContractSignDialog } from "../vendor-table/basic-contract-sign-dialog"
+import { SSLVWPurInqReqDialog } from "@/components/common/legal/sslvw-pur-inq-req-dialog"
 
 interface BasicContractDetailTableToolbarActionsProps {
     table: Table<BasicContractView>
@@ -35,10 +33,8 @@ export function BasicContractDetailTableToolbarActions({ table }: BasicContractD
 
     // 다이얼로그 상태
     const [resendDialog, setResendDialog] = React.useState(false)
-    const [legalReviewDialog, setLegalReviewDialog] = React.useState(false)
     const [finalApproveDialog, setFinalApproveDialog] = React.useState(false)
     const [loading, setLoading] = React.useState(false)
-    const [reviewNote, setReviewNote] = React.useState("")
     const [buyerSignDialog, setBuyerSignDialog] = React.useState(false)
     const [contractsToSign, setContractsToSign] = React.useState<any[]>([])
 
@@ -49,10 +45,6 @@ export function BasicContractDetailTableToolbarActions({ table }: BasicContractD
 
     const canBulkResend = hasSelectedRows
 
-    const canRequestLegalReview = hasSelectedRows && selectedRows.some(row =>
-        row.original.legalReviewRequired && !row.original.legalReviewRequestedAt
-    )
-
     const canFinalApprove = hasSelectedRows && selectedRows.some(row => {
         const contract = row.original;
         if (contract.completedAt !== null || !contract.signedFilePath) {
@@ -67,10 +59,6 @@ export function BasicContractDetailTableToolbarActions({ table }: BasicContractD
     // 필터링된 계약서들 계산
     const resendContracts = selectedRows.map(row => row.original)
 
-    const legalReviewContracts = selectedRows
-        .map(row => row.original)
-        .filter(contract => contract.legalReviewRequired && !contract.legalReviewRequestedAt)
-
     const finalApproveContracts = selectedRows
         .map(row => row.original)
         .filter(contract => {
@@ -204,15 +192,6 @@ export function BasicContractDetailTableToolbarActions({ table }: BasicContractD
         })
     }
 
-    // 법무검토 요청
-    const handleLegalReviewRequest = async () => {
-        if (!canRequestLegalReview) {
-            toast.error("법무검토 요청 가능한 계약서를 선택해주세요")
-            return
-        }
-        setLegalReviewDialog(true)
-    }
-
     // 최종승인
     const handleFinalApprove = async () => {
         if (!canFinalApprove) {
@@ -241,26 +220,6 @@ export function BasicContractDetailTableToolbarActions({ table }: BasicContractD
         }
     }
 
-    // 법무검토 요청 확인
-    const confirmLegalReview = async () => {
-        setLoading(true)
-        try {
-            // TODO: 서버액션 호출
-            await requestLegalReviewAction(legalReviewContracts.map(c => c.id), reviewNote)
-
-            console.log("법무검토 요청:", legalReviewContracts, "메모:", reviewNote)
-            toast.success(`${legalReviewContracts.length}건의 법무검토 요청을 완료했습니다`)
-            setLegalReviewDialog(false)
-            setReviewNote("")
-            table.toggleAllPageRowsSelected(false) // 선택 해제
-        } catch (error) {
-            toast.error("법무검토 요청 중 오류가 발생했습니다")
-            console.error(error)
-        } finally {
-            setLoading(false)
-        }
-    }
-
     // 최종승인 확인 (수정됨)
     const confirmFinalApprove = async () => {
         setLoading(true)
@@ -354,25 +313,8 @@ export function BasicContractDetailTableToolbarActions({ table }: BasicContractD
                     </span>
                 </Button>
 
-                {/* 법무검토 요청 버튼 */}
-                <Button
-                    variant="outline"
-                    size="sm"
-                    onClick={handleLegalReviewRequest}
-                    disabled={!canRequestLegalReview}
-                    className="gap-2"
-                    title={!hasSelectedRows
-                        ? "계약서를 선택해주세요"
-                        : !canRequestLegalReview
-                            ? "법무검토 요청 가능한 계약서가 없습니다"
-                            : `${legalReviewContracts.length}건 법무검토 요청`
-                    }
-                >
-                    <Scale className="size-4" aria-hidden="true" />
-                    <span className="hidden sm:inline">
-                        법무검토 {hasSelectedRows ? `(${selectedRows.length})` : ''}
-                    </span>
-                </Button>
+                {/* 법무검토 버튼 (SSLVW 데이터 조회) */}
+                <SSLVWPurInqReqDialog />
 
                 {/* 최종승인 버튼 */}
                 <Button
@@ -471,73 +413,6 @@ export function BasicContractDetailTableToolbarActions({ table }: BasicContractD
                 </DialogContent>
             </Dialog>
 
-            {/* 법무검토 요청 다이얼로그 */}
-            <Dialog open={legalReviewDialog} onOpenChange={setLegalReviewDialog}>
-                <DialogContent className="max-w-2xl">
-                    <DialogHeader>
-                        <DialogTitle className="flex items-center gap-2">
-                            <Gavel className="size-5" />
-                            법무검토 요청
-                        </DialogTitle>
-                        <DialogDescription>
-                            선택한 {legalReviewContracts.length}건의 계약서에 대한 법무검토를 요청합니다.
-                        </DialogDescription>
-                    </DialogHeader>
-
-                    <div className="space-y-4">
-                        <div className="max-h-48 overflow-y-auto">
-                            <div className="space-y-3">
-                                {legalReviewContracts.map((contract, index) => (
-                                    <div key={contract.id} className="flex items-center justify-between p-3 bg-blue-50 rounded-lg">
-                                        <div className="flex-1">
-                                            <div className="font-medium">{contract.vendorName || '업체명 없음'}</div>
-                                            <div className="text-sm text-gray-500">
-                                                {contract.vendorCode || '코드 없음'} | {contract.templateName || '템플릿명 없음'}
-                                            </div>
-                                        </div>
-                                        <Badge variant="secondary">{contract.status}</Badge>
-                                    </div>
-                                ))}
-                            </div>
-                        </div>
-
-                        <Separator />
-
-                        <div className="space-y-2">
-                            <Label htmlFor="review-note">검토 요청 메모 (선택사항)</Label>
-                            <Textarea
-                                id="review-note"
-                                placeholder="법무팀에게 전달할 특별한 요청사항이나 검토 포인트를 입력해주세요..."
-                                value={reviewNote}
-                                onChange={(e) => setReviewNote(e.target.value)}
-                                rows={3}
-                            />
-                        </div>
-                    </div>
-
-                    <DialogFooter>
-                        <Button
-                            variant="outline"
-                            onClick={() => {
-                                setLegalReviewDialog(false)
-                                setReviewNote("")
-                            }}
-                            disabled={loading}
-                        >
-                            취소
-                        </Button>
-                        <Button
-                            onClick={confirmLegalReview}
-                            disabled={loading}
-                            className="gap-2"
-                        >
-                            <Gavel className="size-4" />
-                            {loading ? "요청 중..." : `${legalReviewContracts.length}건 검토요청`}
-                        </Button>
-                    </DialogFooter>
-                </DialogContent>
-            </Dialog>
-
             {/* 최종승인 다이얼로그 */}
             <Dialog open={finalApproveDialog} onOpenChange={setFinalApproveDialog}>
                 <DialogContent className="max-w-2xl">
-- 
cgit v1.2.3

