From 86b1fd1cc801f45642f84d24c0b5c84368454ff0 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Tue, 9 Sep 2025 10:34:05 +0000 Subject: (최겸) 구매 입찰 사전견적, 입찰, 낙찰, 유찰, 재입찰 기능 개발 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/legal-review/status/request-review-dialog.tsx | 195 ++++++++++------------ 1 file changed, 92 insertions(+), 103 deletions(-) (limited to 'lib/legal-review/status/request-review-dialog.tsx') diff --git a/lib/legal-review/status/request-review-dialog.tsx b/lib/legal-review/status/request-review-dialog.tsx index bfaa14b9..d99fc0e3 100644 --- a/lib/legal-review/status/request-review-dialog.tsx +++ b/lib/legal-review/status/request-review-dialog.tsx @@ -54,18 +54,18 @@ const requestReviewSchema = z.object({ dueDate: z.string().min(1, "검토 완료 희망일을 선택해주세요"), assignee: z.string().optional(), notificationMethod: z.enum(["email", "internal", "both"]).default("both"), - + // 법무업무 상세 정보 reviewDepartment: z.enum(["준법문의", "법무검토"]), inquiryType: z.enum(["국내계약", "국내자문", "해외계약", "해외자문"]).optional(), - + // 공통 필드 title: z.string().min(1, "제목을 선택해주세요"), requestContent: z.string().min(1, "요청내용을 입력해주세요"), - + // 준법문의 전용 필드 isPublic: z.boolean().default(false), - + // 법무검토 전용 필드들 contractProjectName: z.string().optional(), contractType: z.string().optional(), @@ -102,10 +102,7 @@ export function RequestReviewDialog({ const [editorContent, setEditorContent] = React.useState("") const [canRequest, setCanRequest] = React.useState(true) const [requestCheckMessage, setRequestCheckMessage] = React.useState("") - - // "기타" 모드 상태를 별도로 관리 - const [isTitleOtherMode, setIsTitleOtherMode] = React.useState(false) - const [customTitle, setCustomTitle] = React.useState("") + const [isCustomTitle, setIsCustomTitle] = React.useState(false) // work의 category에 따라 기본 reviewDepartment 결정 const getDefaultReviewDepartment = () => { @@ -132,7 +129,7 @@ export function RequestReviewDialog({ setCanRequest(result.canRequest) setRequestCheckMessage(result.reason || "") }) - + const defaultDepartment = work.category === "CP" ? "준법문의" : "법무검토" form.setValue("reviewDepartment", defaultDepartment) } @@ -141,24 +138,25 @@ export function RequestReviewDialog({ // 검토부문 감시 const reviewDepartment = form.watch("reviewDepartment") const inquiryType = form.watch("inquiryType") - // const titleValue = form.watch("title") + const titleValue = form.watch("title") // 조건부 필드 활성화 로직 const isContractTypeActive = inquiryType && ["국내계약", "해외계약", "해외자문"].includes(inquiryType) const isDomesticContractFieldsActive = inquiryType === "국내계약" const isFactualRelationActive = inquiryType && ["국내자문", "해외자문"].includes(inquiryType) const isOverseasFieldsActive = inquiryType && ["해외계약", "해외자문"].includes(inquiryType) - + // 제목 "기타" 선택 여부 확인 - const isTitleOther = titleValue === "기타" + // const isTitleOther = titleValue === "기타" // 검토부문 변경시 관련 필드 초기화 React.useEffect(() => { if (reviewDepartment === "준법문의") { + setIsCustomTitle(false) form.setValue("inquiryType", undefined) // 제목 초기화 (기타 상태였거나 값이 없으면 기본값으로) const currentTitle = form.getValues("title") - if (currentTitle === "기타" || !currentTitle || currentTitle === "GTC검토") { + if (!currentTitle || currentTitle === "GTC검토") { form.setValue("title", "CP검토") } // 법무검토 전용 필드들 초기화 @@ -173,20 +171,14 @@ export function RequestReviewDialog({ form.setValue("shipownerOrderer", "") form.setValue("projectType", "") form.setValue("governingLaw", "") - - setIsTitleOtherMode(false) // 기타 모드 해제 - setCustomTitle("") // 커스텀 제목 초기화 - } else { + setIsCustomTitle(false) // 제목 초기화 (기타 상태였거나 값이 없으면 기본값으로) const currentTitle = form.getValues("title") - if (currentTitle === "기타" || !currentTitle || currentTitle === "CP검토") { + if (!currentTitle || currentTitle === "CP검토") { form.setValue("title", "GTC검토") } form.setValue("isPublic", false) - - setIsTitleOtherMode(false) // 기타 모드 해제 - setCustomTitle("") // 커스텀 제목 초기화 } }, [reviewDepartment, form]) @@ -195,7 +187,7 @@ export function RequestReviewDialog({ if (inquiryType) { // 계약서 종류 초기화 (옵션이 달라지므로) form.setValue("contractType", "") - + // 조건에 맞지 않는 필드들 초기화 if (!isDomesticContractFieldsActive) { form.setValue("contractCounterparty", "") @@ -203,11 +195,11 @@ export function RequestReviewDialog({ form.setValue("contractPeriod", "") form.setValue("contractAmount", "") } - + if (!isFactualRelationActive) { form.setValue("factualRelation", "") } - + if (!isOverseasFieldsActive) { form.setValue("projectNumber", "") form.setValue("shipownerOrderer", "") @@ -235,15 +227,15 @@ export function RequestReviewDialog({ // 폼 제출 async function onSubmit(data: RequestReviewFormValues) { if (!work) return - + console.log("Request review data:", data) console.log("Work to review:", work) console.log("Attachments:", attachments) setIsSubmitting(true) - + try { const result = await requestReview(work.id, data, attachments) - + if (result.success) { toast.success(result.data?.message || `법무업무 #${work.id}에 대한 검토요청이 완료되었습니다.`) onOpenChange(false) @@ -263,6 +255,8 @@ export function RequestReviewDialog({ // 폼 리셋 함수 const handleReset = () => { const defaultDepartment = getDefaultReviewDepartment() + setIsCustomTitle(false) // 추가 + form.reset({ dueDate: "", assignee: "", @@ -274,8 +268,6 @@ export function RequestReviewDialog({ }) setAttachments([]) setEditorContent("") - setIsTitleOtherMode(false) // 기타 모드 리셋 - setCustomTitle("") // 커스텀 제목 리셋 } // 다이얼로그 닫기 핸들러 @@ -435,7 +427,7 @@ export function RequestReviewDialog({
- @@ -576,76 +568,73 @@ export function RequestReviewDialog({ /> )} - {/* 제목 필드 수정 */} - ( - - 제목 - {!isTitleOtherMode ? ( - // Select 모드 - - ) : ( - // Input 모드 (기타 선택시) -
-
- 기타 - -
- - { - field.onChange(e.target.value) - }} - autoFocus - /> - -
- )} - -
- )} - /> + {/* 제목 - 조건부 렌더링 */} + ( + + 제목 + {!isCustomTitle ? ( + // Select 모드 + + ) : ( + // Input 모드 (기타 선택시) +
+
+ 기타 + +
+ + field.onChange(e.target.value)} + autoFocus + /> + +
+ )} + +
+ )} +/> + {/* 준법문의 전용 필드들 */} {reviewDepartment === "준법문의" && ( - + {/* 선택된 파일 목록 */} {attachments.length > 0 && (
@@ -967,8 +956,8 @@ export function RequestReviewDialog({ > 취소 -