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
|
"use client"
import * as React from "react"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm, useFieldArray } from "react-hook-form"
import { z } from "zod"
import { toast } from "sonner"
import { Plus, X, GripVertical, Trash2 } from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
} from "@/components/ui/sheet"
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion"
import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import { Badge } from "@/components/ui/badge"
import { Separator } from "@/components/ui/separator"
import { ScrollArea } from "@/components/ui/scroll-area"
import { getEsgEvaluationDetails } from "../service"
interface EsgEvaluationDetailsSheetProps {
open: boolean
onOpenChange: (open: boolean) => void
evaluationId: number | null
}
export function EsgEvaluationDetailsSheet({
open,
onOpenChange,
evaluationId,
}: EsgEvaluationDetailsSheetProps) {
const [evaluation, setEvaluation] = React.useState<any>(null)
const [isLoading, setIsLoading] = React.useState(false)
console.log(evaluation)
// 데이터 로드
React.useEffect(() => {
if (open && evaluationId) {
setIsLoading(true)
getEsgEvaluationDetails(evaluationId)
.then(setEvaluation)
.catch((error) => {
console.error('Error loading evaluation details:', error)
toast.error('평가표 상세 정보를 불러오는데 실패했습니다.')
})
.finally(() => setIsLoading(false))
}
}, [open, evaluationId])
if (!open) return null
return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent className="w-[900px] sm:max-w-[900px] flex flex-col" style={{width:900, maxWidth:900}}>
<SheetHeader className="flex-shrink-0">
<SheetTitle>ESG 평가표 상세보기</SheetTitle>
<SheetDescription>
평가표의 상세 정보와 평가항목들을 확인합니다.
</SheetDescription>
</SheetHeader>
{isLoading ? (
<div className="flex items-center justify-center h-32">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"></div>
<span className="ml-2">로딩 중...</span>
</div>
) : evaluation ? (
<div className="flex-1 overflow-y-auto px-1">
<div className="space-y-6">
{/* 기본 정보 */}
<Card>
<CardHeader>
<CardTitle>기본 정보</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div>
<label className="text-sm font-medium">시리얼번호</label>
<p className="text-sm text-muted-foreground">{evaluation.serialNumber}</p>
</div>
<div>
<label className="text-sm font-medium">분류</label>
<p className="text-sm text-muted-foreground">
<Badge variant="secondary">{evaluation.category}</Badge>
</p>
</div>
<div>
<label className="text-sm font-medium">점검항목</label>
<p className="text-sm text-muted-foreground">{evaluation.inspectionItem}</p>
</div>
</CardContent>
</Card>
{/* 평가항목들 */}
<Card>
<CardHeader>
<CardTitle>평가항목들 ({evaluation.evaluationItems?.length || 0}개)</CardTitle>
</CardHeader>
<CardContent>
{evaluation.evaluationItems?.length > 0 ? (
<Accordion type="multiple" className="w-full">
{evaluation.evaluationItems.map((item: any, index: number) => (
<AccordionItem key={item.id} value={`item-${item.id}`}>
<AccordionTrigger className="text-left">
<div className="flex items-center gap-2">
<Badge variant="outline">{index + 1}</Badge>
<span className="truncate">{item.evaluationItem}</span>
</div>
</AccordionTrigger>
<AccordionContent>
<div className="space-y-3">
<div className="text-sm text-muted-foreground">
답변 옵션들 ({item.answerOptions?.length || 0}개)
</div>
{item.answerOptions?.map((option: any, optionIndex: number) => (
<div
key={option.id}
className="flex items-center justify-between p-3 bg-muted/50 rounded-lg"
>
<div className="flex items-center gap-2">
<Badge variant="default" className="text-xs">
{optionIndex + 1}
</Badge>
<span className="text-sm">{option.answerText}</span>
</div>
<Badge variant="secondary">
{Math.floor(Number(option.score))}점
</Badge>
</div>
))}
</div>
</AccordionContent>
</AccordionItem>
))}
</Accordion>
) : (
<p className="text-sm text-muted-foreground text-center py-8">
등록된 평가항목이 없습니다.
</p>
)}
</CardContent>
</Card>
</div>
</div>
) : (
<div className="text-center text-muted-foreground py-8">
평가표를 찾을 수 없습니다.
</div>
)}
</SheetContent>
</Sheet>
)
}
|