summaryrefslogtreecommitdiff
path: root/lib/legal-review
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-09-09 10:32:34 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-09-09 10:32:34 +0000
commitc62ec046327fd388ebce04571b55910747e69a3b (patch)
tree41ccdc4a8dea99808622f6d5d52014ac59a2d7ab /lib/legal-review
parentebcec3f296d1d27943caf8a3aed26efef117cdc5 (diff)
(정희성, 최겸, 대표님) formatDate 변경 등
Diffstat (limited to 'lib/legal-review')
-rw-r--r--lib/legal-review/status/request-review-dialog.tsx182
1 files changed, 100 insertions, 82 deletions
diff --git a/lib/legal-review/status/request-review-dialog.tsx b/lib/legal-review/status/request-review-dialog.tsx
index 838752c4..bfaa14b9 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(),
@@ -103,6 +103,10 @@ export function RequestReviewDialog({
const [canRequest, setCanRequest] = React.useState(true)
const [requestCheckMessage, setRequestCheckMessage] = React.useState("")
+ // "기타" 모드 상태를 별도로 관리
+ const [isTitleOtherMode, setIsTitleOtherMode] = React.useState(false)
+ const [customTitle, setCustomTitle] = React.useState("")
+
// work의 category에 따라 기본 reviewDepartment 결정
const getDefaultReviewDepartment = () => {
return work?.category === "CP" ? "준법문의" : "법무검토"
@@ -128,7 +132,7 @@ export function RequestReviewDialog({
setCanRequest(result.canRequest)
setRequestCheckMessage(result.reason || "")
})
-
+
const defaultDepartment = work.category === "CP" ? "준법문의" : "법무검토"
form.setValue("reviewDepartment", defaultDepartment)
}
@@ -137,14 +141,14 @@ 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 === "기타"
@@ -169,6 +173,10 @@ export function RequestReviewDialog({
form.setValue("shipownerOrderer", "")
form.setValue("projectType", "")
form.setValue("governingLaw", "")
+
+ setIsTitleOtherMode(false) // 기타 모드 해제
+ setCustomTitle("") // 커스텀 제목 초기화
+
} else {
// 제목 초기화 (기타 상태였거나 값이 없으면 기본값으로)
const currentTitle = form.getValues("title")
@@ -176,6 +184,9 @@ export function RequestReviewDialog({
form.setValue("title", "GTC검토")
}
form.setValue("isPublic", false)
+
+ setIsTitleOtherMode(false) // 기타 모드 해제
+ setCustomTitle("") // 커스텀 제목 초기화
}
}, [reviewDepartment, form])
@@ -184,7 +195,7 @@ export function RequestReviewDialog({
if (inquiryType) {
// 계약서 종류 초기화 (옵션이 달라지므로)
form.setValue("contractType", "")
-
+
// 조건에 맞지 않는 필드들 초기화
if (!isDomesticContractFieldsActive) {
form.setValue("contractCounterparty", "")
@@ -192,11 +203,11 @@ export function RequestReviewDialog({
form.setValue("contractPeriod", "")
form.setValue("contractAmount", "")
}
-
+
if (!isFactualRelationActive) {
form.setValue("factualRelation", "")
}
-
+
if (!isOverseasFieldsActive) {
form.setValue("projectNumber", "")
form.setValue("shipownerOrderer", "")
@@ -224,15 +235,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 +274,8 @@ export function RequestReviewDialog({
})
setAttachments([])
setEditorContent("")
+ setIsTitleOtherMode(false) // 기타 모드 리셋
+ setCustomTitle("") // 커스텀 제목 리셋
}
// 다이얼로그 닫기 핸들러
@@ -422,7 +435,7 @@ export function RequestReviewDialog({
</div>
<Form {...form}>
- <form
+ <form
onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-col flex-1 min-h-0"
>
@@ -563,71 +576,76 @@ export function RequestReviewDialog({
/>
)}
- {/* 제목 - 조건부 렌더링 */}
- <FormField
- control={form.control}
- name="title"
- render={({ field }) => (
- <FormItem>
- <FormLabel>제목</FormLabel>
- {!isTitleOther ? (
- // Select 모드
- <Select
- onValueChange={(value) => {
- field.onChange(value)
- if (value !== "기타") {
- // 기타가 아닌 값으로 변경시 해당 값으로 설정
- form.setValue("title", value)
- }
- }}
- value={field.value}
- >
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder="제목 선택" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {getTitleOptions().map((option) => (
- <SelectItem key={option.value} value={option.value}>
- {option.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- ) : (
- // Input 모드 (기타 선택시)
- <div className="space-y-2">
- <div className="flex items-center gap-2">
- <Badge variant="outline" className="text-xs">기타</Badge>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={() => {
- const defaultTitle = reviewDepartment === "준법문의" ? "CP검토" : "GTC검토"
- form.setValue("title", defaultTitle)
- }}
- className="h-6 text-xs"
- >
- 선택 모드로 돌아가기
- </Button>
- </div>
- <FormControl>
- <Input
- placeholder="제목을 직접 입력하세요"
- value={field.value === "기타" ? "" : field.value}
- onChange={(e) => field.onChange(e.target.value)}
- autoFocus
- />
- </FormControl>
- </div>
- )}
- <FormMessage />
- </FormItem>
- )}
- />
-
+ {/* 제목 필드 수정 */}
+ <FormField
+ control={form.control}
+ name="title"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>제목</FormLabel>
+ {!isTitleOtherMode ? (
+ // Select 모드
+ <Select
+ onValueChange={(value) => {
+ if (value === "기타") {
+ setIsTitleOtherMode(true)
+ // "기타" 상태는 유지하되 실제 값은 나중에 입력받음
+ field.onChange(value)
+ } else {
+ field.onChange(value)
+ setIsTitleOtherMode(false)
+ }
+ }}
+ value={field.value || (reviewDepartment === "준법문의" ? "CP검토" : "GTC검토")}
+ >
+ <FormControl>
+ <SelectTrigger>
+ <SelectValue placeholder="제목 선택" />
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ {getTitleOptions().map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ ) : (
+ // Input 모드 (기타 선택시)
+ <div className="space-y-2">
+ <div className="flex items-center gap-2">
+ <Badge variant="outline" className="text-xs">기타</Badge>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={() => {
+ const defaultTitle = reviewDepartment === "준법문의" ? "CP검토" : "GTC검토"
+ form.setValue("title", defaultTitle)
+ setIsTitleOtherMode(false)
+ }}
+ className="h-6 text-xs"
+ >
+ 선택 모드로 돌아가기
+ </Button>
+ </div>
+ <FormControl>
+ <Input
+ placeholder="제목을 직접 입력하세요"
+ value={field.value === "기타" ? "" : field.value}
+ onChange={(e) => {
+ field.onChange(e.target.value)
+ }}
+ autoFocus
+ />
+ </FormControl>
+ </div>
+ )}
+ <FormMessage />
+ </FormItem>
+ )}
+ />
{/* 준법문의 전용 필드들 */}
{reviewDepartment === "준법문의" && (
<FormField
@@ -913,7 +931,7 @@ export function RequestReviewDialog({
</span>
</label>
</div>
-
+
{/* 선택된 파일 목록 */}
{attachments.length > 0 && (
<div className="space-y-2">
@@ -949,8 +967,8 @@ export function RequestReviewDialog({
>
취소
</Button>
- <Button
- type="submit"
+ <Button
+ type="submit"
disabled={isSubmitting}
className="bg-blue-600 hover:bg-blue-700"
>