diff options
Diffstat (limited to 'lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx')
| -rw-r--r-- | lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx | 85 |
1 files changed, 44 insertions, 41 deletions
diff --git a/lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx b/lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx index 47a371d9..3dc2c6fc 100644 --- a/lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx +++ b/lib/basic-contract/vendor-table/basic-contract-sign-dialog.tsx @@ -5,7 +5,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/u import { Button } from "@/components/ui/button"; import { ScrollArea } from "@/components/ui/scroll-area"; import { formatDate } from "@/lib/utils"; -import { toast } from "sonner"; +import { useToast } from "@/hooks/use-toast"; import { cn } from "@/lib/utils"; import type { WebViewerInstance } from "@pdftron/webviewer"; import type { BasicContractView } from "@/db/schema"; @@ -62,6 +62,8 @@ export function BasicContractSignDialog({ open: externalOpen, onOpenChange: externalOnOpenChange }: BasicContractSignDialogProps) { + const { toast } = useToast(); + // 내부 상태 (외부 제어가 없을 때 사용) const [internalOpen, setInternalOpen] = React.useState(false); const [selectedContract, setSelectedContract] = React.useState<BasicContractView | null>(null); @@ -257,7 +259,7 @@ const canCompleteCurrentContract = React.useMemo(() => { } // "비밀유지 계약서"인 경우에만 추가 파일 가져오기 - if (selectedContract.templateName === "비밀유지 계약서") { + if (selectedContract.templateName === "비밀유지 계약서" && selectedContract.vendorId) { setIsLoadingAttachments(true); try { const result = await getVendorAttachments(selectedContract.vendorId); @@ -327,9 +329,10 @@ const canCompleteCurrentContract = React.useMemo(() => { const signatureCompleted = signatureStatus[contractId] === true; if (!signatureCompleted) { - toast.error("계약서에 서명을 먼저 완료해주세요.", { + toast({ + title: "계약서에 서명을 먼저 완료해주세요.", description: "문서의 서명 필드에 서명해주세요.", - icon: <Target className="h-5 w-5 text-blue-500" /> + variant: "destructive" }); return; } @@ -342,25 +345,28 @@ const canCompleteCurrentContract = React.useMemo(() => { const signatureCompleted = signatureStatus[contractId] === true; if (!surveyCompleted) { - toast.error("준법 설문조사를 먼저 완료해주세요.", { + toast({ + title: "준법 설문조사를 먼저 완료해주세요.", description: "설문조사 탭에서 모든 필수 항목을 완료해주세요.", - icon: <AlertCircle className="h-5 w-5 text-red-500" /> + variant: "destructive" }); return; } if (!gtcCompleted) { - toast.error("GTC 조항에 코멘트가 있어 서명할 수 없습니다.", { - description: "조항 검토 탭에서 모든 코멘트를 삭제하거나 협의를 완료해주세요.", - icon: <AlertCircle className="h-5 w-5 text-red-500" /> + toast({ + title: "코멘트가 있어 서명할 수 없습니다.", + description: "협의 코멘트 탭에서 모든 코멘트를 삭제하거나 협의를 완료해주세요.", + variant: "destructive" }); return; } if (!signatureCompleted) { - toast.error("계약서에 서명을 먼저 완료해주세요.", { + toast({ + title: "계약서에 서명을 먼저 완료해주세요.", description: "문서의 서명 필드에 서명해주세요.", - icon: <Target className="h-5 w-5 text-blue-500" /> + variant: "destructive" }); return; } @@ -406,9 +412,9 @@ const canCompleteCurrentContract = React.useMemo(() => { ) ); - toast.success("최종승인이 완료되었습니다!", { - description: `${selectedContract.templateName} - ${completedCount + 1}/${totalCount}개 완료`, - icon: <CheckCircle2 className="h-5 w-5 text-green-500" /> + toast({ + title: "최종승인이 완료되었습니다!", + description: `${selectedContract.templateName} - ${completedCount + 1}/${totalCount}개 완료` }); // 구매자 서명 완료 콜백 호출 @@ -420,15 +426,11 @@ const canCompleteCurrentContract = React.useMemo(() => { const nextContract = getNextPendingContract(); if (nextContract) { setSelectedContract(nextContract); - // toast.info(`다음 계약서로 이동합니다`, { - // description: nextContract.templateName, - // icon: <ArrowRight className="h-4 w-4 text-blue-500" /> - // }); } else { // 모든 계약서 완료시 - toast.success("🎉 모든 계약서 최종승인이 완료되었습니다!", { - description: `총 ${totalCount}개 계약서 승인 완료`, - icon: <Trophy className="h-5 w-5 text-yellow-500" /> + toast({ + title: "🎉 모든 계약서 최종승인이 완료되었습니다!", + description: `총 ${totalCount}개 계약서 승인 완료` }); } @@ -443,9 +445,10 @@ const canCompleteCurrentContract = React.useMemo(() => { ) ); - toast.error("최종승인 처리 중 오류가 발생했습니다", { + toast({ + title: "최종승인 처리 중 오류가 발생했습니다", description: result.message, - icon: <AlertCircle className="h-5 w-5 text-red-500" /> + variant: "destructive" }); } } else { @@ -479,24 +482,20 @@ const canCompleteCurrentContract = React.useMemo(() => { ) ); - toast.success("계약서 서명이 완료되었습니다!", { - description: `${selectedContract.templateName} - ${completedCount + 1}/${totalCount}개 완료`, - icon: <CheckCircle2 className="h-5 w-5 text-green-500" /> + toast({ + title: "계약서 서명이 완료되었습니다!", + description: `${selectedContract.templateName} - ${completedCount + 1}/${totalCount}개 완료` }); // 다음 미완료 계약서로 자동 이동 const nextContract = getNextPendingContract(); if (nextContract) { setSelectedContract(nextContract); - // toast.info(`다음 계약서로 이동합니다`, { - // description: nextContract.templateName, - // icon: <ArrowRight className="h-4 w-4 text-blue-500" /> - // }); } else { // 모든 계약서 완료시 - toast.success("🎉 모든 계약서 서명이 완료되었습니다!", { - description: `총 ${totalCount}개 계약서 서명 완료`, - icon: <Trophy className="h-5 w-5 text-yellow-500" /> + toast({ + title: "🎉 모든 계약서 서명이 완료되었습니다!", + description: `총 ${totalCount}개 계약서 서명 완료` }); } @@ -511,9 +510,10 @@ const canCompleteCurrentContract = React.useMemo(() => { ) ); - toast.error("서명 처리 중 오류가 발생했습니다", { + toast({ + title: "서명 처리 중 오류가 발생했습니다", description: result.error, - icon: <AlertCircle className="h-5 w-5 text-red-500" /> + variant: "destructive" }); } } @@ -529,7 +529,10 @@ const canCompleteCurrentContract = React.useMemo(() => { ) ); - toast.error("서명 처리 중 오류가 발생했습니다"); + toast({ + title: "서명 처리 중 오류가 발생했습니다", + variant: "destructive" + }); } finally { setIsSubmitting(false); } @@ -545,9 +548,9 @@ const canCompleteCurrentContract = React.useMemo(() => { ? "모든 계약서 최종승인이 완료되었습니다!" : "모든 계약서 서명이 완료되었습니다!"; - toast.success(successMessage, { - description: "계약서 관리 페이지가 새고침됩니다.", - icon: <Trophy className="h-5 w-5 text-yellow-500" /> + toast({ + title: successMessage, + description: "계약서 관리 페이지가 새고침됩니다." }); }; @@ -776,7 +779,7 @@ const canCompleteCurrentContract = React.useMemo(() => { {isGTCTemplate && ( <span className={`flex items-center ${hasGtcCompleted ? 'text-green-600' : 'text-red-600'}`}> <CheckCircle2 className={`h-3 w-3 mr-1 ${hasGtcCompleted ? 'text-green-500' : 'text-red-500'}`} /> - 조항검토 + 협의 </span> )} <span className={`flex items-center ${hasSignatureCompleted ? 'text-green-600' : 'text-gray-400'}`}> @@ -952,7 +955,7 @@ const canCompleteCurrentContract = React.useMemo(() => { {selectedContract.templateName?.includes('GTC') && ( <span className={`flex items-center ${(gtcCommentStatus[selectedContract.id]?.isComplete === true) ? 'text-green-600' : 'text-red-600'}`}> <CheckCircle2 className={`h-3 w-3 mr-1 ${(gtcCommentStatus[selectedContract.id]?.isComplete === true) ? 'text-green-500' : 'text-red-500'}`} /> - 조항검토 {(gtcCommentStatus[selectedContract.id]?.isComplete === true) ? '완료' : + 협의 {(gtcCommentStatus[selectedContract.id]?.isComplete === true) ? '완료' : `미완료 (코멘트 ${gtcCommentStatus[selectedContract.id]?.commentCount || 0}개)`} </span> )} |
