diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-19 06:15:43 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-19 06:15:43 +0000 |
| commit | c92bd1b8caa6ddabe6acee42018262febd5d91fb (patch) | |
| tree | 833a62c9577894b0f77d3677d4d0274e1cb99385 /lib/basic-contract/viewer/SurveyComponent.tsx | |
| parent | 9bf5b15734cdf87a02c68b2d2a25046a0678a037 (diff) | |
(임수민) 기본계약 코멘트, 법무검토 수정
Diffstat (limited to 'lib/basic-contract/viewer/SurveyComponent.tsx')
| -rw-r--r-- | lib/basic-contract/viewer/SurveyComponent.tsx | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/lib/basic-contract/viewer/SurveyComponent.tsx b/lib/basic-contract/viewer/SurveyComponent.tsx index 8662155e..950519ad 100644 --- a/lib/basic-contract/viewer/SurveyComponent.tsx +++ b/lib/basic-contract/viewer/SurveyComponent.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useRef, useMemo, useCallback } from "react"; import { useForm, useWatch, Controller } from "react-hook-form"; -import { Loader2, FileText, ClipboardList, AlertTriangle, CheckCircle2, Upload, ChevronDown, ChevronUp } from "lucide-react"; +import { Loader2, FileText, ClipboardList, AlertTriangle, CheckCircle2, Upload, ChevronDown, ChevronUp, Download } from "lucide-react"; import { toast } from "sonner"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; @@ -40,6 +40,8 @@ interface SurveyComponentProps { onSurveyDataUpdate: (data: any) => void; onLoadSurveyTemplate: () => void; setActiveTab: (tab: string) => void; + contractFilePath?: string; // 계약서 파일 경로 추가 + contractFileName?: string; // 계약서 파일 이름 추가 } export const SurveyComponent: React.FC<SurveyComponentProps> = ({ @@ -51,7 +53,9 @@ export const SurveyComponent: React.FC<SurveyComponentProps> = ({ onSurveyComplete, onSurveyDataUpdate, onLoadSurveyTemplate, - setActiveTab + setActiveTab, + contractFilePath, + contractFileName }) => { const [uploadedFiles, setUploadedFiles] = useState<Record<number, File[]>>({}); const [existingResponse, setExistingResponse] = useState<ExistingResponse | null>(null); @@ -321,6 +325,40 @@ export const SurveyComponent: React.FC<SurveyComponentProps> = ({ ); }, [control, visibleQuestions]); + // 계약서 다운로드 핸들러 + const handleDownloadContract = useCallback(async () => { + if (!contractFilePath) { + toast.error("다운로드할 파일이 없습니다."); + return; + } + + try { + // 파일 경로를 API 경로로 변환 + const normalizedPath = contractFilePath.startsWith('/') + ? contractFilePath.substring(1) + : contractFilePath; + const encodedPath = normalizedPath.split('/').map(part => encodeURIComponent(part)).join('/'); + const apiFilePath = `/api/files/${encodedPath}`; + + // 파일 경로에서 실제 파일명 추출 + const actualFileName = contractFileName || contractFilePath.split('/').pop() || '계약서.pdf'; + + // 다운로드 링크 생성 및 클릭 + const link = document.createElement('a'); + link.href = apiFilePath; + link.download = actualFileName; + link.target = '_blank'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + toast.success("파일 다운로드가 시작되었습니다."); + } catch (error) { + console.error("파일 다운로드 실패:", error); + toast.error("파일 다운로드에 실패했습니다."); + } + }, [contractFilePath, contractFileName]); + // 설문조사 완료 핸들러 const handleSurveyComplete = useCallback(async () => { console.log('🎯 설문조사 완료 시도'); @@ -543,6 +581,20 @@ export const SurveyComponent: React.FC<SurveyComponentProps> = ({ </CardTitle> <div className="flex items-center space-x-3"> + {/* Word 파일 다운로드 버튼 */} + {contractFilePath && ( + <Button + variant="outline" + size="sm" + onClick={handleDownloadContract} + className="h-8 text-xs" + title="계약서 문서 다운로드" + > + <Download className="h-3 w-3 mr-1" /> + 문서 다운로드 + </Button> + )} + {/* 컴팩트 진행률 표시 */} <div className="flex items-center space-x-2"> <div className="w-20 bg-gray-200 rounded-full h-1.5"> |
