From aa86729f9a2ab95346a2851e3837de1c367aae17 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Fri, 20 Jun 2025 11:37:31 +0000
Subject: (대표님) 20250620 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/form-data/form-data-table.tsx | 57 ++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 21 deletions(-)

(limited to 'components/form-data/form-data-table.tsx')

diff --git a/components/form-data/form-data-table.tsx b/components/form-data/form-data-table.tsx
index 61e9897f..b59684e3 100644
--- a/components/form-data/form-data-table.tsx
+++ b/components/form-data/form-data-table.tsx
@@ -57,6 +57,7 @@ import { SEDPConfirmationDialog, SEDPStatusDialog } from "./sedp-components";
 import { SEDPCompareDialog } from "./sedp-compare-dialog";
 import { getSEDPToken } from "@/lib/sedp/sedp-token";
 import { DeleteFormDataDialog } from "./delete-form-data-dialog";
+import { TemplateViewDialog } from "./spreadJS-dialog";
 
 // 기존 fetchTagDataFromSEDP 함수
 async function fetchTagDataFromSEDP(projectCode: string, formCode: string): Promise<any> {
@@ -328,12 +329,12 @@ export default function DynamicTable({
 
     try {
       setIsLoadingTemplate(true);
-
+      
       const templateResult = await fetchTemplateFromSEDP(projectCode, formCode);
-
+      
       setTemplateData(templateResult);
       setTemplateDialogOpen(true);
-
+      
       toast.success("Template data loaded successfully");
     } catch (error) {
       console.error("Error fetching template:", error);
@@ -720,21 +721,6 @@ export default function DynamicTable({
           </Button>
         )}
 
-        {/* 새로 추가된 Template 보기 버튼 */}
-        <Button
-          variant="outline"
-          size="sm"
-          onClick={handleGetTemplate}
-          disabled={isAnyOperationPending || selectedRowCount !== 1}
-        >
-          {isLoadingTemplate ? (
-            <Loader className="mr-2 size-4 animate-spin" />
-          ) : (
-            <Eye className="mr-2 size-4" />
-          )}
-          View In Spread
-        </Button>
-
         {/* 버튼 그룹 */}
         <div className="flex items-center gap-2">
           {/* 태그 관리 드롭다운 */}
@@ -827,7 +813,25 @@ export default function DynamicTable({
             Export
           </Button>
 
-
+          {/* 새로 추가된 Template 보기 버튼 */}
+          <Button
+            variant="outline"
+            size="sm"
+            onClick={handleGetTemplate}
+            disabled={isAnyOperationPending || selectedRowCount !== 1}
+          >
+            {isLoadingTemplate ? (
+              <Loader className="mr-2 size-4 animate-spin" />
+            ) : (
+              <Eye className="mr-2 size-4" />
+            )}
+            View Template
+            {selectedRowCount === 1 && (
+              <span className="ml-2 text-xs bg-green-100 text-green-700 px-2 py-1 rounded">
+                1
+              </span>
+            )}
+          </Button>
 
           {/* COMPARE WITH SEDP 버튼 */}
           <Button
@@ -918,6 +922,18 @@ export default function DynamicTable({
         templateData={templateData}
         selectedRow={selectedRowsData[0]}
         formCode={formCode}
+        contractItemId={contractItemId}
+        onUpdateSuccess={(updatedValues) => {
+          // SpreadSheets에서 업데이트된 값을 테이블에 반영
+          const tagNo = updatedValues.TAG_NO;
+          if (tagNo) {
+            setTableData(prev =>
+              prev.map(item =>
+                item.TAG_NO === tagNo ? updatedValues : item
+              )
+            );
+          }
+        }}
       />
 
       {/* SEDP Confirmation Dialog */}
@@ -989,5 +1005,4 @@ export default function DynamicTable({
       )}
     </>
   );
-}
-
+}
\ No newline at end of file
-- 
cgit v1.2.3

