260312_01_ENH: Error 페이지 및 Redirect 페이지 구현

This commit is contained in:
2026-03-12 09:36:09 +09:00
parent bedcfbc9d1
commit f7ce249aa7
17 changed files with 710 additions and 6 deletions

116
src/components/external/Error.tsx vendored Normal file
View File

@@ -0,0 +1,116 @@
import { ServerCrash, FileQuestion } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Separator } from "@/components/ui/separator";
import ExternalLayout from "@/components/external/ExternalLayout";
import {ErrorCode} from "@/types/common";
interface ErrorConfig {
httpLabel: string;
defaultTitle: string;
defaultDescription: string;
Icon: React.ElementType;
badgeVariant: "default" | "destructive" | "outline" | "secondary";
accentClass: string;
}
// ─── Error Configs ────────────────────────────────────────────────────────────
const ERROR_MAP: Record<ErrorCode, ErrorConfig> = {
"404": {
httpLabel: "Page Not Found",
defaultTitle: "요청하신 페이지를 찾을 수 없습니다",
defaultDescription:
"입력하신 주소가 잘못되었거나, 페이지가 삭제 또는 이동되었을 수 있습니다",
Icon: FileQuestion,
badgeVariant: "secondary",
accentClass: "bg-primary",
},
"500": {
httpLabel: "Internal Server Error",
defaultTitle: "서버에서 오류가 발생했습니다",
defaultDescription:
"요청을 처리하는 중 예기치 못한 오류가 발생했습니다. 잠시 후 다시 시도해 주세요. 문제가 지속되면 담당자에게 문의해 주세요.",
Icon: ServerCrash,
badgeVariant: "destructive",
accentClass: "bg-destructive",
},
};
interface ErrorViewProps {
code?: ErrorCode;
errorTitle?: string;
errorDescription?: string;
}
const ErrorPage = ({
code = "404",
errorTitle,
errorDescription,
}: ErrorViewProps) => {
const config = ERROR_MAP[code] ?? ERROR_MAP["404"];
const { httpLabel, defaultTitle, defaultDescription, Icon, badgeVariant, accentClass } = config;
const title = errorTitle ?? defaultTitle;
const description = errorDescription ?? defaultDescription;
return (
<ExternalLayout footerRight={`ERR_${code}`}>
<div className="flex flex-1 items-center justify-center px-12 py-10">
<div className="w-full max-w-2xl">
{/* 에러 코드 타이포 레이어 */}
<div className="relative mb-2 select-none">
{/* 전면 숫자 */}
<span
className="block leading-none text-foreground"
style={{
fontSize: "clamp(72px, 12vw, 130px)",
fontWeight: 900,
letterSpacing: "-0.03em",
}}
>
{code}
</span>
</div>
{/* 뱃지 */}
<div className="mb-5 flex flex-wrap gap-2">
<Badge
variant={badgeVariant}
className="rounded-full px-3 py-1 text-xs font-bold uppercase tracking-wider"
>
{httpLabel}
</Badge>
<Badge
variant="outline"
className="rounded-full px-3 py-1 text-xs uppercase tracking-wider"
>
HTTP {code}
</Badge>
<Badge
variant="outline"
className="rounded-full px-3 py-1 text-xs uppercase tracking-wider"
>
KRi Platform
</Badge>
</div>
<Separator className={`mb-6 h-0.5 w-12 ${accentClass}`} />
<div className="mb-3 flex items-center gap-3">
<Icon size={22} className="flex-shrink-0 text-muted-foreground" />
<h1 className="text-2xl font-bold tracking-tight text-foreground">
{title}
</h1>
</div>
<p className="mb-9 max-w-md text-sm leading-relaxed text-muted-foreground">
{description}
</p>
</div>
</div>
</ExternalLayout>
);
}
export default ErrorPage;

View File

@@ -0,0 +1,61 @@
import React from "react";
import Image from "next/image";
interface ExternalLayoutProps {
children: React.ReactNode;
/** 헤더 우측 영역 (선택) */
headerRight?: React.ReactNode;
/** 푸터 우측 텍스트 (선택, 기본: "KRi Survey Platform") */
footerRight?: string;
}
const ExternalLayout = (
{
children,
headerRight,
footerRight = "KRi Contact System",
}: ExternalLayoutProps
) => {
return (
<div className="flex min-h-svh flex-col bg-background antialiased">
{/* 상단 컬러 바 */}
<div className="h-1 w-full flex-shrink-0 bg-primary" />
{/* 헤더 */}
<header className="flex flex-shrink-0 items-center justify-between border-b px-12 py-2">
<Image
src="/kri_logo.png"
alt="KRi"
width={80}
height={32}
className="h-8 w-auto object-contain"
priority
/>
{headerRight ?? (
<span className="text-xs font-semibold uppercase tracking-widest text-muted-foreground">
KRi Contact System
</span>
)}
</header>
{/* 콘텐츠 */}
<div className="flex flex-1 flex-col">
{children}
</div>
{/* 푸터 */}
<footer className="flex flex-shrink-0 items-center justify-between border-t px-12 py-5">
<span className="text-xs text-muted-foreground">
© {new Date().getFullYear()} KRi. All rights reserved.
</span>
<span className="text-xs text-muted-foreground">
{footerRight}
</span>
</footer>
</div>
);
}
export default ExternalLayout

View File

@@ -0,0 +1,177 @@
import { CheckCircle, XCircle, Users } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardHeader } from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
import ExternalLayout from "./ExternalLayout";
import {RedirectSlug} from "@/types/common";
interface StatusConfig {
label: string;
sublabel: string;
title: string;
description: string;
Icon: React.ElementType;
badgeVariant: "default" | "secondary" | "destructive" | "outline";
iconClassName: string;
savedVisible: boolean;
}
// ─── Status Configs ───────────────────────────────────────────────────────────
const STATUS_MAP: Record<RedirectSlug, StatusConfig> = {
complete: {
label: "설문 완료",
sublabel: "Survey Complete",
title: "설문에 참여해 주셔서\n감사합니다",
description:
"귀하의 소중한 의견이 성공적으로 접수되었습니다. 응답 결과는 연구 목적으로만 활용되며, 개인 정보는 철저히 보호됩니다.",
Icon: CheckCircle,
badgeVariant: "default",
iconClassName: "text-primary",
savedVisible: true,
},
screen: {
label: "참여 불가",
sublabel: "Screen Out",
title: "이번 설문에는\n참여하실 수 없습니다",
description:
"현재 진행 중인 설문은 특정 조건에 맞는 응답자를 대상으로 합니다. 귀하의 프로필이 이번 조사의 대상과 맞지 않아 참여가 제한되었습니다.",
Icon: XCircle,
badgeVariant: "outline",
iconClassName: "text-muted-foreground",
savedVisible: false,
},
quota: {
label: "할당 초과",
sublabel: "Quota Full",
title: "모집 인원이\n마감되었습니다",
description:
"해당 설문의 목표 응답 수가 충족되어 더 이상 참여가 불가합니다. 참여 의사를 가져주신 데 감사드리며, 다른 설문 기회를 기대해 주세요.",
Icon: Users,
badgeVariant: "outline",
iconClassName: "text-muted-foreground",
savedVisible: false,
},
};
const InfoRow = ({
label,
value,
mono = false,
}: {
label: string;
value: React.ReactNode;
mono?: boolean;
}) => {
return (
<div className="flex items-center justify-between border-b border-border px-4 py-3 last:border-b-0">
<span className="text-xs text-muted-foreground">{label}</span>
<span
className={`text-xs font-medium text-foreground ${
mono ? "rounded bg-muted px-2 py-0.5 font-mono" : ""
}`}
>
{value}
</span>
</div>
);
}
interface RedirectLandingProps {
redirectSlug: RedirectSlug;
timestamp?: string;
}
const RedirectLanding = ({
redirectSlug,
timestamp,
}: RedirectLandingProps) => {
const {
label,
sublabel,
title,
description,
Icon,
badgeVariant,
iconClassName,
savedVisible,
} = STATUS_MAP[redirectSlug];
const displayTime =
timestamp ??
new Date().toLocaleString("ko-KR", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
});
return (
<ExternalLayout>
<div className="flex flex-1 items-center justify-center px-12 py-8">
<div className="grid w-full max-w-4xl gap-12 lg:grid-cols-2">
{/* 왼쪽: 메시지 */}
<div className="flex flex-col justify-center">
<Badge
variant={badgeVariant}
className="mb-7 w-fit gap-1.5 rounded-full px-3 py-1 text-xs font-bold uppercase tracking-wider"
>
<Icon size={12} />
{sublabel}
</Badge>
<h1 className="mb-5 whitespace-pre-line text-4xl font-extrabold leading-tight tracking-tight text-foreground">
{title}
</h1>
<Separator className="mb-5 h-0.5 w-12 bg-primary" />
<p className="max-w-sm text-sm leading-relaxed text-muted-foreground">
{description}
</p>
</div>
{/* 오른쪽: 카드 */}
<div className="flex flex-col gap-4">
{/* 상태 카드 */}
<Card className="relative overflow-hidden">
<div className="absolute inset-x-0 top-0 h-0.5 bg-primary" />
<CardHeader className="pb-0 pt-6">
<div className="mb-5 flex h-14 w-14 items-center justify-center rounded-xl bg-muted">
<Icon size={26} className={iconClassName} />
</div>
</CardHeader>
<CardContent>
<p className="mb-1 text-xs font-semibold uppercase tracking-widest text-muted-foreground">
최종 상태
</p>
<p className="text-xl font-bold tracking-tight text-foreground">
{label}
</p>
</CardContent>
</Card>
{/* 상세 정보 */}
<Card className="overflow-hidden p-0">
<InfoRow label="응답 상태" value={redirectSlug.toUpperCase()} mono />
<InfoRow label="처리 시각" value={displayTime} />
<InfoRow label="플랫폼" value="KRi Contact System" />
{savedVisible && (
<InfoRow
label="저장 상태"
value={<span className="text-green-500">✓ 저장 완료</span>}
/>
)}
</Card>
</div>
</div>
</div>
</ExternalLayout>
);
}
export default RedirectLanding;