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
|
'use client'
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"
import { Separator } from "@/components/ui/separator"
import { ArrowLeft, Building2, Users, Info, AlertCircle, Copy } from "lucide-react"
import Link from "next/link"
import { useRouter } from "next/navigation"
import { useState, useEffect } from "react"
import { toast } from "sonner"
// 에러 정보 타입
interface ErrorInfo {
timestamp: string;
url: string;
userAgent: string;
platform: string;
language: string;
cookieEnabled: boolean;
onLine: boolean;
screen: {
width: number;
height: number;
colorDepth: number;
};
viewport: {
width: number;
height: number;
};
referrer: string;
localStorage: boolean;
sessionStorage: boolean;
}
export default function NotFound() {
const router = useRouter()
const [errorInfo, setErrorInfo] = useState<ErrorInfo | null>(null)
useEffect(() => {
// 브라우저 환경 정보 수집
const collectErrorInfo = () => {
const info: ErrorInfo = {
timestamp: new Date().toISOString(),
url: window.location.href,
userAgent: navigator.userAgent,
platform: navigator.platform,
language: navigator.language,
cookieEnabled: navigator.cookieEnabled,
onLine: navigator.onLine,
screen: {
width: screen.width,
height: screen.height,
colorDepth: screen.colorDepth,
},
viewport: {
width: window.innerWidth,
height: window.innerHeight,
},
referrer: document.referrer || '직접 접근',
localStorage: typeof Storage !== 'undefined',
sessionStorage: typeof Storage !== 'undefined',
}
setErrorInfo(info)
}
collectErrorInfo()
}, [])
const copyToClipboard = (text: string) => {
navigator.clipboard.writeText(text).then(() => {
toast.success("클립보드에 복사되었습니다")
}).catch(() => {
toast.error("복사에 실패했습니다")
})
}
const copyErrorInfo = () => {
if (!errorInfo) return
const errorText = `
=== 404 에러 정보 ===
시간: ${errorInfo.timestamp}
URL: ${errorInfo.url}
리퍼러: ${errorInfo.referrer}
브라우저: ${errorInfo.userAgent}
플랫폼: ${errorInfo.platform}
언어: ${errorInfo.language}
화면 해상도: ${errorInfo.screen.width}x${errorInfo.screen.height}
뷰포트: ${errorInfo.viewport.width}x${errorInfo.viewport.height}
온라인 상태: ${errorInfo.onLine ? '온라인' : '오프라인'}
쿠키 활성화: ${errorInfo.cookieEnabled ? '예' : '아니오'}
`.trim()
copyToClipboard(errorText)
}
return (
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-900 dark:to-slate-800 p-4">
<Card className="w-full max-w-2xl shadow-lg">
<CardHeader className="text-center space-y-4">
<div className="mx-auto w-24 h-24 bg-slate-100 dark:bg-slate-800 rounded-full flex items-center justify-center">
<span className="text-4xl font-bold text-slate-600 dark:text-slate-400">404</span>
</div>
<CardTitle className="text-3xl font-bold text-slate-900 dark:text-slate-100">
이 페이지는 개발중이거나, 잘못된 URL 입니다.
</CardTitle>
<CardDescription className="text-lg text-slate-600 dark:text-slate-400">
THIS PAGE IS UNDER DEVELOPMENT OR INVALID URL.
</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
<Separator />
<div className="text-center text-sm text-slate-500 dark:text-slate-400">
아래 버튼을 통해 원하는 페이지로 이동하세요
</div>
<div className="grid gap-4 sm:grid-cols-3">
{/* SHI 사용자 홈 */}
<Button
asChild
variant="outline"
className="h-auto p-4 flex flex-col items-center space-y-2 hover:bg-blue-50 hover:border-blue-200 dark:hover:bg-blue-950"
>
<Link href="/ko/evcp/dashboard">
<Building2 className="h-6 w-6 text-blue-600 dark:text-blue-400" />
<span className="font-medium">SHI 사용자 홈</span>
<span className="text-xs text-slate-500 dark:text-slate-400">EVCP 대시보드</span>
</Link>
</Button>
{/* 벤더 홈 */}
<Button
asChild
variant="outline"
className="h-auto p-4 flex flex-col items-center space-y-2 hover:bg-green-50 hover:border-green-200 dark:hover:bg-green-950"
>
<Link href="/ko/partners">
<Users className="h-6 w-6 text-green-600 dark:text-green-400" />
<span className="font-medium">벤더 홈</span>
<span className="text-xs text-slate-500 dark:text-slate-400">협력업체 포털</span>
</Link>
</Button>
{/* 뒤로 가기 */}
<Button
onClick={() => router.back()}
variant="outline"
className="h-auto p-4 flex flex-col items-center space-y-2 hover:bg-slate-50 hover:border-slate-200 dark:hover:bg-slate-800"
>
<ArrowLeft className="h-6 w-6 text-slate-600 dark:text-slate-400" />
<span className="font-medium">뒤로 가기</span>
<span className="text-xs text-slate-500 dark:text-slate-400">이전 페이지로</span>
</Button>
</div>
<Separator />
<div className="flex justify-center gap-4">
{/* 에러 정보 다이얼로그 */}
<Dialog>
<DialogTrigger asChild>
<Button variant="ghost" size="sm">
<Info className="h-4 w-4 mr-2" />
에러 정보
</Button>
</DialogTrigger>
<DialogContent className="max-w-2xl max-h-[80vh] overflow-y-auto">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<AlertCircle className="h-5 w-5" />
에러 상세 정보
</DialogTitle>
<DialogDescription>
기술 지원을 위한 상세 환경 정보입니다.
</DialogDescription>
</DialogHeader>
{errorInfo && (
<div className="space-y-4">
<div className="flex justify-end">
<Button onClick={copyErrorInfo} size="sm" variant="outline">
<Copy className="h-4 w-4 mr-2" />
전체 복사
</Button>
</div>
<div className="space-y-3">
<div className="grid gap-2">
<label className="text-sm font-medium">발생 시간</label>
<div className="p-2 bg-muted rounded text-sm font-mono">
{errorInfo.timestamp}
</div>
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">요청 URL</label>
<div className="p-2 bg-muted rounded text-sm font-mono break-all">
{errorInfo.url}
</div>
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">이전 페이지</label>
<div className="p-2 bg-muted rounded text-sm font-mono break-all">
{errorInfo.referrer}
</div>
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">브라우저 정보</label>
<div className="p-2 bg-muted rounded text-sm font-mono break-all">
{errorInfo.userAgent}
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="grid gap-2">
<label className="text-sm font-medium">플랫폼</label>
<div className="p-2 bg-muted rounded text-sm font-mono">
{errorInfo.platform}
</div>
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">언어</label>
<div className="p-2 bg-muted rounded text-sm font-mono">
{errorInfo.language}
</div>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="grid gap-2">
<label className="text-sm font-medium">화면 해상도</label>
<div className="p-2 bg-muted rounded text-sm font-mono">
{errorInfo.screen.width} × {errorInfo.screen.height}
</div>
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">뷰포트 크기</label>
<div className="p-2 bg-muted rounded text-sm font-mono">
{errorInfo.viewport.width} × {errorInfo.viewport.height}
</div>
</div>
</div>
<div className="grid grid-cols-3 gap-4">
<div className="grid gap-2">
<label className="text-sm font-medium">온라인 상태</label>
<div className="p-2 bg-muted rounded text-sm font-mono">
{errorInfo.onLine ? '온라인' : '오프라인'}
</div>
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">쿠키 활성화</label>
<div className="p-2 bg-muted rounded text-sm font-mono">
{errorInfo.cookieEnabled ? '예' : '아니오'}
</div>
</div>
<div className="grid gap-2">
<label className="text-sm font-medium">색상 깊이</label>
<div className="p-2 bg-muted rounded text-sm font-mono">
{errorInfo.screen.colorDepth}bit
</div>
</div>
</div>
</div>
</div>
)}
</DialogContent>
</Dialog>
</div>
</CardContent>
</Card>
</div>
)
}
|