summaryrefslogtreecommitdiff
path: root/lib/compliance/compliance-response-detail.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compliance/compliance-response-detail.tsx')
-rw-r--r--lib/compliance/compliance-response-detail.tsx69
1 files changed, 55 insertions, 14 deletions
diff --git a/lib/compliance/compliance-response-detail.tsx b/lib/compliance/compliance-response-detail.tsx
index 709f3ede..4c2062d0 100644
--- a/lib/compliance/compliance-response-detail.tsx
+++ b/lib/compliance/compliance-response-detail.tsx
@@ -112,6 +112,17 @@ export function ComplianceResponseDetail({ templateId, responseId, promises }: C
return question ? question.hasFileUpload : false
}
+ const isQuestionRedFlag = (questionId: number) => {
+ const question = questions.find(q => q.id === questionId)
+ return question ? question.isRedFlag : false
+ }
+
+ const isRedFlagTriggered = (answer: any) => {
+ const isRedFlag = isQuestionRedFlag(answer.questionId)
+ const answerValue = (answer.answerValue ?? '').toString().trim().toUpperCase()
+ return isRedFlag && answerValue === 'YES'
+ }
+
// 파일 다운로드 핸들러
const handleFileDownload = async (file: any) => {
try {
@@ -245,22 +256,51 @@ export function ComplianceResponseDetail({ templateId, responseId, promises }: C
</div>
) : (
<div className="space-y-4">
- {answers.map((answer) => (
- <div key={answer.id} className="border rounded-lg p-4 space-y-3">
- <div className="flex items-center gap-2 pb-3 border-b">
- <Badge variant="outline">
- {getQuestionNumber(answer.questionId)}
- </Badge>
- <span className="font-medium">
- {getQuestionText(answer.questionId)}
- </span>
- </div>
- <div className="space-y-3">
+ {answers.map((answer) => {
+ const redFlagTriggered = isRedFlagTriggered(answer)
+ return (
+ <div
+ key={answer.id}
+ className={`border-2 rounded-lg p-4 space-y-3 ${
+ redFlagTriggered
+ ? 'border-red-500 bg-red-50/50'
+ : 'border-gray-200'
+ }`}
+ >
+ <div className="flex items-center gap-2 pb-3 border-b">
+ <Badge
+ variant={redFlagTriggered ? "destructive" : "outline"}
+ >
+ {getQuestionNumber(answer.questionId)}
+ </Badge>
+ <span className="font-medium">
+ {getQuestionText(answer.questionId)}
+ </span>
+ {/* {isQuestionRedFlag(answer.questionId) && (
+ <Badge variant="destructive" className="ml-auto">
+ RED FLAG
+ </Badge>
+ )} */}
+ </div>
+ <div className="space-y-3">
{/* 답변 값 */}
{answer.answerValue && (
<div>
<label className="text-sm font-medium text-muted-foreground">답변</label>
- <p className="mt-1 p-2 bg-muted rounded">{answer.answerValue}</p>
+ <div className="mt-1 flex items-center gap-2">
+ <p className={`flex-1 p-2 rounded ${
+ redFlagTriggered
+ ? 'bg-red-100 text-red-900 font-semibold'
+ : 'bg-muted'
+ }`}>
+ {answer.answerValue}
+ </p>
+ {/* {redFlagTriggered && (
+ <Badge variant="destructive" className="shrink-0">
+ Red Flag 발생
+ </Badge>
+ )} */}
+ </div>
</div>
)}
@@ -331,9 +371,10 @@ export function ComplianceResponseDetail({ templateId, responseId, promises }: C
'-'
}
</div>
+ </div>
</div>
- </div>
- ))}
+ )
+ })}
</div>
)}
</CardContent>