diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-07 05:05:40 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-07 05:05:40 +0000 |
| commit | 8daa2aeee017c642d2fd171094cf5d442966eb12 (patch) | |
| tree | 289879c50cc8f1f28d44c129846d6b153ecacdac /lib/basic-contract/template/template-editor-wrapper.tsx | |
| parent | 7f973de2a814a2040a646161b563c8990b7e2fd2 (diff) | |
(임수민) 기본계약서 서명란 변수 수정
Diffstat (limited to 'lib/basic-contract/template/template-editor-wrapper.tsx')
| -rw-r--r-- | lib/basic-contract/template/template-editor-wrapper.tsx | 101 |
1 files changed, 62 insertions, 39 deletions
diff --git a/lib/basic-contract/template/template-editor-wrapper.tsx b/lib/basic-contract/template/template-editor-wrapper.tsx index 2c1c7e4d..8d2ce97f 100644 --- a/lib/basic-contract/template/template-editor-wrapper.tsx +++ b/lib/basic-contract/template/template-editor-wrapper.tsx @@ -43,9 +43,9 @@ const getVariablesForTemplate = (templateName: string): string[] => { } } - // 모든 템플릿에 서명란 변수 추가 (중복 제거) - const signatureVars = ["vendor_signature", "buyer_signature"]; - const allVariables = [...variables, ...signatureVars]; + // 모든 템플릿에 서명란 텍스트 추가 (자동 서명 기능을 위해 실제 텍스트 사용) + const signatureTexts = ["협력업체_서명란", "삼성중공업_서명란"]; + const allVariables = [...variables, ...signatureTexts]; return [...new Set(allVariables)]; // 중복 제거 }; @@ -78,21 +78,12 @@ const VARIABLE_DESCRIPTION_MAP = { "phone_number": "전화번호", "phone": "전화번호", "email": "이메일", - "vendor_signature": "협력업체 서명란", - "buyer_signature": "구매자 서명란", "협력업체_서명란": "협력업체 서명란", "삼성중공업_서명란": "구매자 서명란" } as const; -// 서명란 텍스트를 변수명으로 변환 -const getSignatureVariableName = (searchText: string): string => { - if (searchText === '협력업체_서명란') { - return 'vendor_signature'; - } else if (searchText === '삼성중공업_서명란') { - return 'buyer_signature'; - } - return searchText; -}; +// 서명란 텍스트는 그대로 사용 (자동 서명 기능이 정확한 텍스트를 찾아야 함) +// 변환하지 않고 원본 텍스트를 그대로 반환 // 변수 패턴 감지를 위한 정규식 const VARIABLE_PATTERN = /\{\{([^}]+)\}\}/g; @@ -207,7 +198,9 @@ export function TemplateEditorWrapper({ } try { - const textToInsert = `{{${variableName}}}`; + // 서명란 텍스트는 {{}} 없이 그대로 사용 + const isSignatureText = variableName === '협력업체_서명란' || variableName === '삼성중공업_서명란'; + const textToInsert = isSignatureText ? variableName : `{{${variableName}}}`; // 1단계: 클립보드 API 시도 if (navigator.clipboard && navigator.clipboard.writeText) { @@ -417,7 +410,7 @@ export function TemplateEditorWrapper({ {signatureVariables.length > 0 && ( <div> <p className="text-xs text-muted-foreground mb-2"> - 서명란 변수 (클릭하여 복사): + 서명란 텍스트 (클릭하여 복사): </p> <TooltipProvider> <div className="flex flex-wrap gap-1"> @@ -428,9 +421,34 @@ export function TemplateEditorWrapper({ variant="ghost" size="sm" className="h-6 px-2 text-xs hover:bg-green-50 border border-green-200" - onClick={() => insertVariable(variable)} + onClick={async () => { + // 서명란 텍스트는 {{}} 없이 그대로 복사 + const textToInsert = variable; + + // 클립보드에 복사 + if (navigator.clipboard && navigator.clipboard.writeText) { + try { + await navigator.clipboard.writeText(textToInsert); + toast.success(`"${textToInsert}"가 클립보드에 복사되었습니다.`, { + description: "문서에서 원하는 위치에 Ctrl+V로 붙여넣기 하세요." + }); + } catch (clipboardError) { + console.warn("클립보드 API 사용 실패:", clipboardError); + // 대안 방법 + const tempTextArea = document.createElement('textarea'); + tempTextArea.value = textToInsert; + tempTextArea.style.position = 'fixed'; + tempTextArea.style.left = '-9999px'; + document.body.appendChild(tempTextArea); + tempTextArea.select(); + document.execCommand('copy'); + document.body.removeChild(tempTextArea); + toast.success(`"${textToInsert}"가 클립보드에 복사되었습니다.`); + } + } + }} > - {`{{${variable}}}`} + {variable} </Button> </TooltipTrigger> <TooltipContent> @@ -451,23 +469,29 @@ export function TemplateEditorWrapper({ </p> <TooltipProvider> <div className="flex flex-wrap gap-1"> - {predefinedVariables.map((variable, index) => ( - <Tooltip key={index}> - <TooltipTrigger asChild> - <Button - variant="ghost" - size="sm" - className="h-6 px-2 text-xs hover:bg-blue-50" - onClick={() => insertVariable(variable)} - > - {`{{${variable}}}`} - </Button> - </TooltipTrigger> - <TooltipContent> - <p>{VARIABLE_DESCRIPTION_MAP[variable as keyof typeof VARIABLE_DESCRIPTION_MAP] || variable}</p> - </TooltipContent> - </Tooltip> - ))} + {predefinedVariables.map((variable, index) => { + // 서명란 텍스트는 {{}} 없이 표시 + const isSignatureText = variable === '협력업체_서명란' || variable === '삼성중공업_서명란'; + const displayText = isSignatureText ? variable : `{{${variable}}}`; + + return ( + <Tooltip key={index}> + <TooltipTrigger asChild> + <Button + variant="ghost" + size="sm" + className={`h-6 px-2 text-xs ${isSignatureText ? 'hover:bg-green-50 border border-green-200' : 'hover:bg-blue-50'}`} + onClick={() => insertVariable(variable)} + > + {displayText} + </Button> + </TooltipTrigger> + <TooltipContent> + <p>{VARIABLE_DESCRIPTION_MAP[variable as keyof typeof VARIABLE_DESCRIPTION_MAP] || variable}</p> + </TooltipContent> + </Tooltip> + ); + })} </div> </TooltipProvider> </div> @@ -486,11 +510,10 @@ export function TemplateEditorWrapper({ instance={instance} setInstance={setInstance} onSignatureFieldFound={(searchText) => { - // 서명란 발견 시 변수명으로 변환하여 추가 - const variableName = getSignatureVariableName(searchText); + // 서명란 발견 시 원본 텍스트를 그대로 추가 (자동 서명 기능을 위해) setSignatureVariables(prev => { - if (!prev.includes(variableName)) { - return [...prev, variableName]; + if (!prev.includes(searchText)) { + return [...prev, searchText]; } return prev; }); |
