summaryrefslogtreecommitdiff
path: root/lib/general-contracts/detail/general-contract-documents.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/general-contracts/detail/general-contract-documents.tsx')
-rw-r--r--lib/general-contracts/detail/general-contract-documents.tsx17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/general-contracts/detail/general-contract-documents.tsx b/lib/general-contracts/detail/general-contract-documents.tsx
index 11d2de68..b0f20e7f 100644
--- a/lib/general-contracts/detail/general-contract-documents.tsx
+++ b/lib/general-contracts/detail/general-contract-documents.tsx
@@ -32,6 +32,7 @@ interface ContractDocument {
documentName: string
fileName: string
filePath: string
+ documentType?: string
shiComment?: string | null
vendorComment?: string | null
uploadedAt: Date
@@ -80,6 +81,16 @@ export function ContractDocuments({ contractId, userId, readOnly = false }: Cont
startTransition(async () => {
try {
+ // 본 계약문서 타입인 경우 기존 문서 확인
+ if (selectedDocumentType === 'main') {
+ const existingMainDoc = documents.find(doc => doc.documentType === 'main')
+ if (existingMainDoc) {
+ toast.info('기존 계약문서가 새롭게 업로드한 문서로 대체됩니다.')
+ // 기존 본 계약문서 삭제
+ await deleteContractAttachment(existingMainDoc.id, contractId)
+ }
+ }
+
await uploadContractAttachment(contractId, file, userId, selectedDocumentType)
toast.success('문서가 업로드되었습니다.')
loadDocuments()
@@ -108,7 +119,7 @@ export function ContractDocuments({ contractId, userId, readOnly = false }: Cont
startTransition(async () => {
try {
- await deleteContractAttachment(documentId, contractId, userId)
+ await deleteContractAttachment(documentId, contractId)
toast.success('문서가 삭제되었습니다.')
loadDocuments()
} catch (error) {
@@ -275,7 +286,7 @@ export function ContractDocuments({ contractId, userId, readOnly = false }: Cont
<Button
variant="ghost"
size="sm"
- onClick={() => handleEditComment(doc.id, 'shi', doc.shiComment)}
+ onClick={() => handleEditComment(doc.id, 'shi', doc.shiComment || '')}
>
<MessageSquare className="h-4 w-4" />
</Button>
@@ -321,7 +332,7 @@ export function ContractDocuments({ contractId, userId, readOnly = false }: Cont
<Button
variant="ghost"
size="sm"
- onClick={() => handleEditComment(doc.id, 'vendor', doc.vendorComment)}
+ onClick={() => handleEditComment(doc.id, 'vendor', doc.vendorComment || '')}
>
<MessageSquare className="h-4 w-4" />
</Button>