From 7b19153fb26443a28265166176c449d97ba67dfc Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 1 Dec 2025 07:24:59 +0000
Subject: (임수민) 준법설문 응답 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../basic-contracts-detail-columns.tsx             | 51 +++++++++++++++-------
 1 file changed, 36 insertions(+), 15 deletions(-)

(limited to 'lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx')

diff --git a/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx b/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
index 8783894c..aab808b8 100644
--- a/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
+++ b/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
@@ -304,6 +304,13 @@ export function getDetailColumns({
 
         const handleOpenGTC = (e: React.MouseEvent) => {
           e.stopPropagation()
+          if (typeof window === "undefined") return
+
+          // 현재 URL에서 언어(lng) 추출
+          const pathname = window.location.pathname || ""
+          const segments = pathname.split("/").filter(Boolean)
+          const lng = segments[0] || ""
+          const basePath = lng ? `/${lng}` : ""
           
           // 상세보기와 동일하게 contract.id를 경로 파라미터로 사용
           const params = new URLSearchParams();
@@ -318,7 +325,7 @@ export function getDetailColumns({
             params.set("vendorName", contract.vendorName);
           }
           const query = params.toString();
-          const gtcUrl = `/evcp/basic-contract/vendor-gtc/${contract.id}${query ? `?${query}` : ""}`;
+          const gtcUrl = `${basePath}/evcp/basic-contract/vendor-gtc/${contract.id}${query ? `?${query}` : ""}`;
           window.open(gtcUrl, '_blank');
         }
 
@@ -381,8 +388,15 @@ export function getDetailColumns({
                       if (contract.vendorName) {
                         params.set("vendorName", contract.vendorName);
                       }
+
+                      // 현재 URL에서 언어(lng) 추출
+                      const pathname = window.location.pathname || ""
+                      const segments = pathname.split("/").filter(Boolean)
+                      const lng = segments[0] || ""
+                      const basePath = lng ? `/${lng}` : ""
+
                       const query = params.toString();
-                      const complianceUrl = `/evcp/basic-contract/compliance-comments/${contract.id}${query ? `?${query}` : ""}`;
+                      const complianceUrl = `${basePath}/evcp/basic-contract/compliance-comments/${contract.id}${query ? `?${query}` : ""}`;
                       window.open(complianceUrl, "_blank", "noopener,noreferrer");
                     }}
                     style={{ cursor: "pointer" }}
@@ -396,22 +410,29 @@ export function getDetailColumns({
                       variant="outline"
                       className="text-xs bg-blue-50 text-blue-700 border-blue-200"
                       title="SHI에서 협의 코멘트를 시작합니다"
-                      onClick={(event) => {
+                      onClick={async (event) => {
                         event.stopPropagation()
                         if (typeof window === "undefined") return
-                        const params = new URLSearchParams()
-                        if (contract.templateId) {
-                          params.set("templateId", contract.templateId.toString())
-                        }
-                        if (contract.vendorId) {
-                          params.set("vendorId", contract.vendorId.toString())
-                        }
-                        if (contract.vendorName) {
-                          params.set("vendorName", contract.vendorName)
+                        try {
+                          const complianceResponse = await getComplianceResponseByBasicContractId(contract.id)
+                          if (!complianceResponse) {
+                            toast.error("준법 설문 응답을 찾을 수 없습니다.")
+                            return
+                          }
+
+                          // 현재 URL에서 언어(lng) 추출
+                          const pathname = window.location.pathname || ""
+                          const segments = pathname.split("/").filter(Boolean)
+                          const lng = segments[0] || ""
+                          const basePath = lng ? `/${lng}` : ""
+
+                          router.push(
+                            `${basePath}/evcp/compliance/${complianceResponse.templateId}/responses/${complianceResponse.id}`
+                          )
+                        } catch (error) {
+                          console.error("Failed to open compliance response detail:", error)
+                          toast.error("준법 설문 응답 상세 페이지로 이동하는 데 실패했습니다.")
                         }
-                        const query = params.toString()
-                        const complianceUrl = `/evcp/basic-contract/compliance-comments/${contract.id}${query ? `?${query}` : ""}`
-                        window.open(complianceUrl, "_blank", "noopener,noreferrer")
                       }}
                       style={{ cursor: "pointer" }}
                     >
-- 
cgit v1.2.3

