From 6160e8bd61360ada9e8e0574671c38292eaba9e7 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Tue, 25 Nov 2025 11:48:21 +0000
Subject: (임수민) 준법/gtc 코멘트 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../vendor-table/basic-contract-sign-dialog.tsx    | 63 +++++++++++++---------
 1 file changed, 38 insertions(+), 25 deletions(-)

(limited to 'lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx')

diff --git a/lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx b/lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx
index e5aab10d..407a3c4d 100644
--- a/lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx
+++ b/lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx
@@ -142,13 +142,20 @@ const canCompleteCurrentContract = React.useMemo(() => {
 
 
   // 계약서별 상태 초기화
+  // Vendor signed 상태의 계약서도 포함하여 초기화
   React.useEffect(() => {
     if (contracts.length > 0 && contractStatuses.length === 0) {
       setContractStatuses(
-        contracts.map(contract => ({
-          id: contract.id,
-          status: 'pending' as const
-        }))
+        contracts.map(contract => {
+          // 이미 서명된 계약서는 vendor_signed 상태로 초기화
+          const isSigned = contract.vendorSignedAt || 
+                          contract.status === "COMPLETED" || 
+                          contract.status === "VENDOR_SIGNED";
+          return {
+            id: contract.id,
+            status: isSigned ? ('vendor_signed' as const) : ('pending' as const)
+          };
+        })
       );
     }
   }, [contracts, contractStatuses.length]);
@@ -705,7 +712,7 @@ const canCompleteCurrentContract = React.useMemo(() => {
                     <div className="space-y-2">
                       {filteredContracts.map((contract) => {
                         const contractStatus = contractStatuses.find(status => status.id === contract.id);
-                        const isCompleted = contractStatus?.status === 'completed';
+                        const isCompleted = contractStatus?.status === 'completed' || contractStatus?.status === 'vendor_signed';
                         const hasError = contractStatus?.status === 'error';
 
                         // 계약서별 완료 상태 확인
@@ -732,7 +739,8 @@ const canCompleteCurrentContract = React.useMemo(() => {
                               !isCompleted && !hasError && "hover:bg-blue-50 hover:border-blue-200"
                             )}
                             onClick={() => handleSelectContract(contract)}
-                            disabled={isCompleted}
+                            // Vendor signed 상태에서도 코멘트를 볼 수 있도록 비활성화하지 않음
+                            disabled={false}
                           >
                             <div className="flex flex-col w-full space-y-1">
                               {/* 첫 번째 줄: 제목 + 상태 */}
@@ -851,7 +859,7 @@ const canCompleteCurrentContract = React.useMemo(() => {
                       {selectedContract.templateName || t("basicContracts.dialog.document")}
 
                       {/* 현재 계약서 상태 표시 */}
-                      {currentContractStatus?.status === 'completed' ? (
+                      {(currentContractStatus?.status === 'completed' || currentContractStatus?.status === 'vendor_signed') ? (
                         <Badge variant="outline" className="ml-2 bg-green-50 text-green-700 border-green-200">
                           <CheckCircle2 className="h-3 w-3 mr-1" />
                           {isBuyerMode ? "승인 완료" : "서명 완료"}
@@ -931,10 +939,10 @@ const canCompleteCurrentContract = React.useMemo(() => {
                   <div className="p-4 flex justify-between items-center bg-gray-50 border-t flex-shrink-0">
                     <div className="flex items-center space-x-4">
                       {/* 현재 계약서가 완료된 경우 */}
-                      {currentContractStatus?.status === 'completed' ? (
+                      {currentContractStatus?.status === 'completed' || currentContractStatus?.status === 'vendor_signed' ? (
                         <p className="text-sm text-green-600 flex items-center">
                           <CheckCircle2 className="h-4 w-4 text-green-500 mr-1" />
-                          이 계약서는 이미 {isBuyerMode ? "승인이" : "서명이"} 완료되었습니다
+                          이 계약서는 이미 {isBuyerMode ? "승인이" : "서명이"} 완료되었습니다. 코멘트를 확인할 수 있습니다.
                         </p>
                       ) : currentContractStatus?.status === 'error' ? (
                         <p className="text-sm text-red-600 flex items-center">
@@ -1015,22 +1023,27 @@ const canCompleteCurrentContract = React.useMemo(() => {
                           <Trophy className="h-4 w-4" />
                           모든 {isBuyerMode ? "승인" : "서명"} 완료
                         </Button>
-                      ) : currentContractStatus?.status === 'completed' ? (
-                        // 현재 계약서가 완료된 경우
-                        <Button
-                          variant="outline"
-                          className="gap-2"
-                          onClick={() => {
-                            const nextContract = getNextPendingContract();
-                            if (nextContract) {
-                              setSelectedContract(nextContract);
-                            }
-                          }}
-                          disabled={!getNextPendingContract()}
-                        >
-                          <ArrowRight className="h-4 w-4" />
-                          다음 계약서
-                        </Button>
+                      ) : (currentContractStatus?.status === 'completed' || currentContractStatus?.status === 'vendor_signed') ? (
+                        // 현재 계약서가 완료된 경우 - 코멘트 확인만 가능
+                        <div className="flex items-center gap-2">
+                          <Button
+                            variant="outline"
+                            className="gap-2"
+                            onClick={() => {
+                              const nextContract = getNextPendingContract();
+                              if (nextContract) {
+                                setSelectedContract(nextContract);
+                              }
+                            }}
+                            disabled={!getNextPendingContract()}
+                          >
+                            <ArrowRight className="h-4 w-4" />
+                            다음 계약서
+                          </Button>
+                          <p className="text-sm text-gray-500">
+                            서명 완료 - 코멘트 확인 가능
+                          </p>
+                        </div>
                       ) : (
                         // 현재 계약서를 서명해야 하는 경우
                         <Button
-- 
cgit v1.2.3

