1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
|
"use client";
import * as React from "react";
import {
Eye,
FileText,
Building,
User,
Calendar,
Clock,
MessageSquare,
CheckCircle,
ShieldCheck,
} from "lucide-react";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
import { formatDate } from "@/lib/utils";
import { LegalWorksDetailView } from "@/db/schema";
// -----------------------------------------------------------------------------
// TYPES
// -----------------------------------------------------------------------------
type LegalWorkData = LegalWorksDetailView;
interface LegalWorkDetailDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
work: LegalWorkData | null;
}
// -----------------------------------------------------------------------------
// HELPERS
// -----------------------------------------------------------------------------
// 상태별 배지 스타일
const getStatusBadgeVariant = (status: string) => {
switch (status) {
case "검토요청":
return "bg-blue-100 text-blue-800 border-blue-200";
case "담당자배정":
return "bg-yellow-100 text-yellow-800 border-yellow-200";
case "검토중":
return "bg-orange-100 text-orange-800 border-orange-200";
case "답변완료":
return "bg-green-100 text-green-800 border-green-200";
case "재검토요청":
return "bg-purple-100 text-purple-800 border-purple-200";
case "보류":
return "bg-gray-100 text-gray-800 border-gray-200";
case "취소":
return "bg-red-100 text-red-800 border-red-200";
default:
return "bg-gray-100 text-gray-800 border-gray-200";
}
};
export function LegalWorkDetailDialog({
open,
onOpenChange,
work,
}: LegalWorkDetailDialogProps) {
if (!work) return null;
// ---------------------------------------------------------------------------
// CONDITIONAL FLAGS
// ---------------------------------------------------------------------------
const isLegalReview = work.reviewDepartment === "법무검토";
const isCompliance = work.reviewDepartment === "준법문의";
const isDomesticContract = work.inquiryType === "국내계약";
const isDomesticAdvisory = work.inquiryType === "국내자문";
const isOverseasContract = work.inquiryType === "해외계약";
const isOverseasAdvisory = work.inquiryType === "해외자문";
const isContractTypeActive =
isDomesticContract || isOverseasContract || isOverseasAdvisory;
const isDomesticContractFieldsActive = isDomesticContract;
const isFactualRelationActive = isDomesticAdvisory || isOverseasAdvisory;
const isOverseasFieldsActive = isOverseasContract || isOverseasAdvisory;
// ---------------------------------------------------------------------------
// RENDER
// ---------------------------------------------------------------------------
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-4xl h-[90vh] p-0 flex flex-col">
{/* 헤더 */}
<div className="flex-shrink-0 p-6 border-b">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<Eye className="h-5 w-5" /> 법무업무 상세보기
</DialogTitle>
<DialogDescription>
법무업무 #{work.id}의 상세 정보를 확인합니다.
</DialogDescription>
</DialogHeader>
</div>
{/* 본문 */}
<ScrollArea className="flex-1 p-6">
<div className="space-y-6">
{/* 1. 기본 정보 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-lg">
<FileText className="h-5 w-5" /> 기본 정보
</CardTitle>
</CardHeader>
<CardContent>
<div className="grid grid-cols-2 gap-6 text-sm">
<div className="space-y-4">
<div className="flex items-center gap-2">
<span className="font-medium text-muted-foreground">업무 ID:</span>
<Badge variant="outline">#{work.id}</Badge>
</div>
<div className="flex items-center gap-2">
<span className="font-medium text-muted-foreground">구분:</span>
<Badge
variant={
work.category === "CP"
? "default"
: work.category === "GTC"
? "secondary"
: "outline"
}
>
{work.category}
</Badge>
{work.isUrgent && (
<Badge variant="destructive" className="text-xs">
긴급
</Badge>
)}
</div>
<div className="flex items-center gap-2">
<span className="font-medium text-muted-foreground">상태:</span>
<Badge
className={getStatusBadgeVariant(work.status)}
variant="outline"
>
{work.status}
</Badge>
</div>
</div>
<div className="space-y-4">
<div className="flex items-center gap-2">
<Building className="h-4 w-4 text-muted-foreground" />
<span className="font-medium text-muted-foreground">벤더:</span>
<span>
{work.vendorCode} - {work.vendorName}
</span>
</div>
<div className="flex items-center gap-2">
<Calendar className="h-4 w-4 text-muted-foreground" />
<span className="font-medium text-muted-foreground">의뢰일:</span>
<span>{formatDate(work.consultationDate, "KR")}</span>
</div>
<div className="flex items-center gap-2">
<Clock className="h-4 w-4 text-muted-foreground" />
<span className="font-medium text-muted-foreground">답변요청일:</span>
<span>{formatDate(work.requestDate, "KR")}</span>
</div>
</div>
</div>
</CardContent>
</Card>
{/* 2. 담당자 정보 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-lg">
<User className="h-5 w-5" /> 담당자 정보
</CardTitle>
</CardHeader>
<CardContent>
<div className="grid grid-cols-2 gap-6 text-sm">
<div className="space-y-2">
<span className="font-medium text-muted-foreground">검토요청자</span>
<p>{work.reviewer || "미지정"}</p>
</div>
<div className="space-y-2">
<span className="font-medium text-muted-foreground">법무답변자</span>
<p>{work.legalResponder || "미배정"}</p>
</div>
{work.expectedAnswerDate && (
<div className="space-y-2">
<span className="font-medium text-muted-foreground">답변예정일</span>
<p>{formatDate(work.expectedAnswerDate, "KR")}</p>
</div>
)}
{work.legalCompletionDate && (
<div className="space-y-2">
<span className="font-medium text-muted-foreground">법무완료일</span>
<p>{formatDate(work.legalCompletionDate, "KR")}</p>
</div>
)}
</div>
</CardContent>
</Card>
{/* 3. 법무업무 상세 정보 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-lg">
<ShieldCheck className="h-5 w-5" /> 법무업무 상세 정보
</CardTitle>
</CardHeader>
<CardContent className="space-y-4 text-sm">
<div className="grid grid-cols-2 gap-6">
<div className="space-y-2">
<span className="font-medium text-muted-foreground">검토부문</span>
<Badge variant="outline">{work.reviewDepartment}</Badge>
</div>
{work.inquiryType && (
<div className="space-y-2">
<span className="font-medium text-muted-foreground">문의종류</span>
<Badge variant="secondary">{work.inquiryType}</Badge>
</div>
)}
{isCompliance && (
<div className="space-y-2 col-span-2">
<span className="font-medium text-muted-foreground">공개여부</span>
<Badge variant={work.isPublic ? "default" : "outline"}>
{work.isPublic ? "공개" : "비공개"}
</Badge>
</div>
)}
</div>
{/* 법무검토 전용 필드 */}
{isLegalReview && (
<>
{work.contractProjectName && (
<>
<Separator className="my-2" />
<div className="space-y-2">
<span className="font-medium text-muted-foreground">
계약명 / 프로젝트명
</span>
<p>{work.contractProjectName}</p>
</div>
</>
)}
{/* 계약서 종류 */}
{isContractTypeActive && work.contractType && (
<div className="space-y-2">
<span className="font-medium text-muted-foreground">계약서 종류</span>
<Badge variant="outline" className="max-w-max">
{work.contractType}
</Badge>
</div>
)}
{/* 국내계약 전용 필드 */}
{isDomesticContractFieldsActive && (
<div className="grid grid-cols-2 gap-6 mt-4">
{work.contractCounterparty && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">
계약상대방
</span>
<p>{work.contractCounterparty}</p>
</div>
)}
{work.counterpartyType && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">
계약상대방 구분
</span>
<p>{work.counterpartyType}</p>
</div>
)}
{work.contractPeriod && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">계약기간</span>
<p>{work.contractPeriod}</p>
</div>
)}
{work.contractAmount && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">계약금액</span>
<p>{work.contractAmount}</p>
</div>
)}
</div>
)}
{/* 사실관계 */}
{isFactualRelationActive && work.factualRelation && (
<div className="space-y-2 mt-4">
<span className="font-medium text-muted-foreground">사실관계</span>
<p className="whitespace-pre-wrap">{work.factualRelation}</p>
</div>
)}
{/* 해외 전용 필드 */}
{isOverseasFieldsActive && (
<div className="grid grid-cols-2 gap-6 mt-4">
{work.projectNumber && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">프로젝트번호</span>
<p>{work.projectNumber}</p>
</div>
)}
{work.shipownerOrderer && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">선주 / 발주처</span>
<p>{work.shipownerOrderer}</p>
</div>
)}
{work.projectType && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">프로젝트종류</span>
<p>{work.projectType}</p>
</div>
)}
{work.governingLaw && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">준거법</span>
<p>{work.governingLaw}</p>
</div>
)}
</div>
)}
</>
)}
</CardContent>
</Card>
{/* 4. 요청 내용 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-lg">
<MessageSquare className="h-5 w-5" /> 요청 내용
</CardTitle>
</CardHeader>
<CardContent className="space-y-4 text-sm">
{work.title && (
<div className="space-y-1">
<span className="font-medium text-muted-foreground">제목</span>
<p className="font-medium">{work.title}</p>
</div>
)}
<Separator />
<div className="space-y-1">
<span className="font-medium text-muted-foreground">상세 내용</span>
<div className="bg-muted/30 rounded-lg p-4">
{work.requestContent ? (
<div className="prose prose-sm max-w-none">
<div
dangerouslySetInnerHTML={{ __html: work.requestContent }}
/>
</div>
) : (
<p className="italic text-muted-foreground">요청 내용이 없습니다.</p>
)}
</div>
</div>
{work.attachmentCount > 0 && (
<div className="flex items-center gap-2">
<FileText className="h-4 w-4" /> 첨부파일 {work.attachmentCount}개
</div>
)}
</CardContent>
</Card>
{/* 5. 답변 내용 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-lg">
<CheckCircle className="h-5 w-5" /> 답변 내용
</CardTitle>
</CardHeader>
<CardContent className="space-y-4 text-sm">
<div className="bg-green-50 border border-green-200 rounded-lg p-4">
{work.responseContent ? (
<div className="prose prose-sm max-w-none">
<div
dangerouslySetInnerHTML={{ __html: work.responseContent }}
/>
</div>
) : (
<p className="italic text-muted-foreground">
아직 답변이 등록되지 않았습니다.
</p>
)}
</div>
</CardContent>
</Card>
</div>
</ScrollArea>
</DialogContent>
</Dialog>
);
}
|