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
|
"use client";
import * as React from "react";
import { useParams } from "next/navigation";
import { useTranslation } from "@/i18n/client";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle
} from "@/components/ui/dialog";
import { Loader, Send, AlertTriangle, CheckCircle } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Progress } from "@/components/ui/progress";
// SEDP Send Confirmation Dialog
export function SEDPConfirmationDialog({
isOpen,
onClose,
onConfirm,
formName,
tagCount,
isLoading
}: {
isOpen: boolean;
onClose: () => void;
onConfirm: () => void;
formName: string;
tagCount: number;
isLoading: boolean;
}) {
const params = useParams();
const lng = (params?.lng as string) || "ko";
const { t } = useTranslation(lng, "engineering");
return (
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>{t("sedp.sendDataTitle")}</DialogTitle>
<DialogDescription>
{t("sedp.sendDataDescription")}
</DialogDescription>
</DialogHeader>
<div className="py-4">
<div className="grid grid-cols-2 gap-4 mb-4">
<div className="text-muted-foreground">{t("sedp.formName")}:</div>
<div className="font-medium">{formName}</div>
<div className="text-muted-foreground">{t("sedp.totalTags")}:</div>
<div className="font-medium">{tagCount}</div>
</div>
<div className="bg-amber-50 p-3 rounded-md border border-amber-200 flex items-start gap-2">
<AlertTriangle className="h-5 w-5 text-amber-500 mt-0.5 flex-shrink-0" />
<div className="text-sm text-amber-800">
{t("sedp.warningMessage")}
</div>
</div>
</div>
<DialogFooter className="gap-2 sm:gap-0">
<Button variant="outline" onClick={onClose} disabled={isLoading}>
{t("buttons.cancel")}
</Button>
<Button
variant="samsung"
onClick={onConfirm}
disabled={isLoading}
className="gap-2"
>
{isLoading ? (
<>
<Loader className="h-4 w-4 animate-spin" />
{t("sedp.sending")}
</>
) : (
<>
<Send className="h-4 w-4" />
{t("sedp.sendToSEDP")}
</>
)}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
// SEDP Status Dialog - shows the result of the SEDP operation
export function SEDPStatusDialog({
isOpen,
onClose,
status,
message,
successCount,
errorCount,
totalCount
}: {
isOpen: boolean;
onClose: () => void;
status: 'success' | 'error' | 'partial';
message: string;
successCount: number;
errorCount: number;
totalCount: number;
}) {
const params = useParams();
const lng = (params?.lng as string) || "ko";
const { t } = useTranslation(lng, "engineering");
// Calculate percentage for the progress bar
const percentage = Math.round((successCount / totalCount) * 100);
const getStatusTitle = () => {
switch (status) {
case 'success':
return t("sedp.dataSentSuccessfully");
case 'partial':
return t("sedp.partiallySuccessful");
case 'error':
default:
return t("sedp.failedToSendData");
}
};
return (
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>
{getStatusTitle()}
</DialogTitle>
</DialogHeader>
<div className="py-4">
{/* Status Icon */}
<div className="flex justify-center mb-4">
{status === 'success' ? (
<div className="h-12 w-12 rounded-full bg-green-100 flex items-center justify-center">
<CheckCircle className="h-8 w-8 text-green-600" />
</div>
) : status === 'partial' ? (
<div className="h-12 w-12 rounded-full bg-amber-100 flex items-center justify-center">
<AlertTriangle className="h-8 w-8 text-amber-600" />
</div>
) : (
<div className="h-12 w-12 rounded-full bg-red-100 flex items-center justify-center">
<AlertTriangle className="h-8 w-8 text-red-600" />
</div>
)}
</div>
{/* Message */}
<p className="text-center mb-4">{message}</p>
{/* Progress Stats */}
<div className="space-y-2 mb-4">
<div className="flex justify-between text-sm">
<span>{t("sedp.progress")}</span>
<span>{percentage}%</span>
</div>
<Progress value={percentage} className="h-2" />
<div className="flex justify-between text-sm pt-1">
<div>
<Badge variant="outline" className="bg-green-50 text-green-700 hover:bg-green-50">
{t("sedp.successfulCount", { count: successCount })}
</Badge>
</div>
{errorCount > 0 && (
<div>
<Badge variant="outline" className="bg-red-50 text-red-700 hover:bg-red-50">
{t("sedp.failedCount", { count: errorCount })}
</Badge>
</div>
)}
</div>
</div>
</div>
<DialogFooter>
<Button onClick={onClose}>
{t("buttons.close")}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
|