From 6e533b815cf503fdcd8f91035f5ea7a25a6787ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=A0=9C=EA=B2=BD?= Date: Thu, 2 Jul 2026 22:20:58 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=EC=A0=84=EC=97=AD=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B0=8F=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EB=A0=88=EB=B2=A8=20ErrorBoundar?= =?UTF-8?q?y=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Error.tsx: useRouteError 기반으로 개선, 404/일반 에러 분기 및 재시도·홈 이동 액션 추가 - NotFound.tsx: 404 전용 페이지 신규 생성 (이전 페이지·홈 이동 액션) - Router: path "*" 라우트 추가, errorElement 업데이트 - react-error-boundary 설치 및 ErrorBoundary 컴포넌트 추가 - MetricErrorFallback / ChartErrorFallback fallback UI 제작 - OverviewDashboard 각 섹션을 ErrorBoundary로 래핑하여 위젯 에러 격리 --- package-lock.json | 88 ++++++++++++++ package.json | 1 + .../common/error/ChartErrorFallback.tsx | 34 ++++++ src/components/common/error/ErrorBoundary.tsx | 6 + .../common/error/MetricErrorFallback.tsx | 34 ++++++ src/pages/common/Error.tsx | 110 +++++++++++++++++- src/pages/common/NotFound.tsx | 98 ++++++++++++++++ .../dashboard/overview/OverviewDashboard.tsx | 60 ++++++---- src/routes/Router.tsx | 11 +- 9 files changed, 412 insertions(+), 30 deletions(-) create mode 100644 src/components/common/error/ChartErrorFallback.tsx create mode 100644 src/components/common/error/ErrorBoundary.tsx create mode 100644 src/components/common/error/MetricErrorFallback.tsx create mode 100644 src/pages/common/NotFound.tsx diff --git a/package-lock.json b/package-lock.json index b1082918..2725a8b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "react": "^19.2.0", "react-apexcharts": "^2.0.1", "react-dom": "^19.2.0", + "react-error-boundary": "^6.1.2", "react-hook-form": "^7.71.1", "react-markdown": "^10.1.0", "react-remove-scroll": "^2.7.2", @@ -32,6 +33,7 @@ "@commitlint/cli": "^20.3.1", "@commitlint/config-conventional": "^20.3.1", "@eslint/js": "^9.39.2", + "@playwright/test": "^1.60.0", "@storybook/addon-essentials": "8.6.17", "@storybook/react": "8.6.17", "@storybook/react-vite": "8.6.17", @@ -43,6 +45,7 @@ "@typescript-eslint/eslint-plugin": "^8.53.0", "@typescript-eslint/parser": "^8.53.0", "@vitejs/plugin-react-swc": "^3.11.0", + "dotenv": "^17.4.2", "eslint": "^9.39.2", "eslint-config-prettier": "^10.1.8", "eslint-plugin-import": "^2.32.0", @@ -1508,6 +1511,22 @@ "url": "https://opencollective.com/pkgr" } }, + "node_modules/@playwright/test": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.61.1.tgz", + "integrity": "sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.61.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@rolldown/pluginutils": { "version": "1.0.0-beta.27", "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz", @@ -5044,6 +5063,19 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "17.4.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", + "integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -9215,6 +9247,53 @@ "node": ">=0.10" } }, + "node_modules/playwright": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.61.1.tgz", + "integrity": "sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.61.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.61.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.61.1.tgz", + "integrity": "sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/polished": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/polished/-/polished-4.3.1.tgz", @@ -9476,6 +9555,15 @@ "react": "^19.2.4" } }, + "node_modules/react-error-boundary": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-6.1.2.tgz", + "integrity": "sha512-3DpCr5HVdZ0caUjYE/kIHBEJN0mNP3ZCgf16c48uJ5TbWjorKVp+YG8W3XqlJ7vJAVNw6wNIImyPXmFydwmyng==", + "license": "MIT", + "peerDependencies": { + "react": "^18.0.0 || ^19.0.0" + } + }, "node_modules/react-hook-form": { "version": "7.71.1", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.71.1.tgz", diff --git a/package.json b/package.json index 7860646f..981de919 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "react": "^19.2.0", "react-apexcharts": "^2.0.1", "react-dom": "^19.2.0", + "react-error-boundary": "^6.1.2", "react-hook-form": "^7.71.1", "react-markdown": "^10.1.0", "react-remove-scroll": "^2.7.2", diff --git a/src/components/common/error/ChartErrorFallback.tsx b/src/components/common/error/ChartErrorFallback.tsx new file mode 100644 index 00000000..765590ee --- /dev/null +++ b/src/components/common/error/ChartErrorFallback.tsx @@ -0,0 +1,34 @@ +import { memo } from "react"; + +import Button from "@/components/common/button/Button"; + +import type { FallbackProps } from "./ErrorBoundary"; + +import WarnCircleIcon from "@/assets/icon/common/warn-circle.svg?react"; + +const ChartErrorFallback = memo(function ChartErrorFallback({ + resetErrorBoundary, +}: FallbackProps) { + return ( +
+
+ ); +}); + +export default ChartErrorFallback; diff --git a/src/components/common/error/ErrorBoundary.tsx b/src/components/common/error/ErrorBoundary.tsx new file mode 100644 index 00000000..496b8ff5 --- /dev/null +++ b/src/components/common/error/ErrorBoundary.tsx @@ -0,0 +1,6 @@ +export type { FallbackProps } from "react-error-boundary"; +export { + ErrorBoundary, + useErrorBoundary, + withErrorBoundary, +} from "react-error-boundary"; diff --git a/src/components/common/error/MetricErrorFallback.tsx b/src/components/common/error/MetricErrorFallback.tsx new file mode 100644 index 00000000..b7c72bfa --- /dev/null +++ b/src/components/common/error/MetricErrorFallback.tsx @@ -0,0 +1,34 @@ +import { memo } from "react"; + +import Button from "@/components/common/button/Button"; + +import type { FallbackProps } from "./ErrorBoundary"; + +import WarnCircleIcon from "@/assets/icon/common/warn-circle.svg?react"; + +const MetricErrorFallback = memo(function MetricErrorFallback({ + resetErrorBoundary, +}: FallbackProps) { + return ( +
+
+ ); +}); + +export default MetricErrorFallback; diff --git a/src/pages/common/Error.tsx b/src/pages/common/Error.tsx index f3b91f58..1994848b 100644 --- a/src/pages/common/Error.tsx +++ b/src/pages/common/Error.tsx @@ -1,3 +1,107 @@ -export default function Error() { - return
Error
; -} +import { memo } from "react"; +import { useNavigate, useRouteError } from "react-router-dom"; +import { motion, useReducedMotion } from "framer-motion"; + +import Button from "@/components/common/button/Button"; + +import WarningIcon from "@/assets/icon/ai/warning.svg?react"; + +const easeOut = [0, 0, 0.2, 1] as const; + +const containerVariants = { + hidden: {}, + visible: (reduce: boolean) => ({ + transition: { + staggerChildren: reduce ? 0 : 0.05, + delayChildren: 0, + }, + }), +}; + +const itemVariants = { + hidden: (reduce: boolean) => ({ + opacity: reduce ? 1 : 0, + y: reduce ? 0 : 10, + }), + visible: (reduce: boolean) => ({ + opacity: 1, + y: 0, + transition: { duration: reduce ? 0 : 0.35, ease: easeOut }, + }), +}; + +const ErrorPage = memo(function ErrorPage() { + const error = useRouteError() as { status?: number; message?: string } | null; + const navigate = useNavigate(); + const reduceMotion = useReducedMotion(); + + const is404 = error?.status === 404; + const title = is404 ? "페이지를 찾을 수 없어요" : "오류가 발생했어요"; + const description = is404 + ? "요청하신 페이지가 존재하지 않거나\n주소가 변경되었을 수 있어요." + : "일시적인 오류가 발생했습니다.\n잠시 후 다시 시도해 주세요."; + + return ( +
+ + + + + + + {title} + + + + {description} + + + + {!is404 && ( + + )} + + + +
+ ); +}); + +export default ErrorPage; diff --git a/src/pages/common/NotFound.tsx b/src/pages/common/NotFound.tsx new file mode 100644 index 00000000..cd5e7d0c --- /dev/null +++ b/src/pages/common/NotFound.tsx @@ -0,0 +1,98 @@ +import { memo } from "react"; +import { useNavigate } from "react-router-dom"; +import { motion, useReducedMotion } from "framer-motion"; + +import Button from "@/components/common/button/Button"; + +import WarningIcon from "@/assets/icon/ai/warning.svg?react"; + +const easeOut = [0, 0, 0.2, 1] as const; + +const containerVariants = { + hidden: {}, + visible: (reduce: boolean) => ({ + transition: { + staggerChildren: reduce ? 0 : 0.05, + delayChildren: 0, + }, + }), +}; + +const itemVariants = { + hidden: (reduce: boolean) => ({ + opacity: reduce ? 1 : 0, + y: reduce ? 0 : 10, + }), + visible: (reduce: boolean) => ({ + opacity: 1, + y: 0, + transition: { duration: reduce ? 0 : 0.35, ease: easeOut }, + }), +}; + +const NotFound = memo(function NotFound() { + const navigate = useNavigate(); + const reduceMotion = useReducedMotion(); + + return ( +
+ + + + + + + 페이지를 찾을 수 없어요 + + + + {"요청하신 페이지가 존재하지 않거나\n주소가 변경되었을 수 있어요."} + + + + + + + +
+ ); +}); + +export default NotFound; diff --git a/src/pages/dashboard/overview/OverviewDashboard.tsx b/src/pages/dashboard/overview/OverviewDashboard.tsx index 80254208..8ca0aaa4 100644 --- a/src/pages/dashboard/overview/OverviewDashboard.tsx +++ b/src/pages/dashboard/overview/OverviewDashboard.tsx @@ -4,6 +4,9 @@ import { useBudget } from "@/hooks/dashboard/useBudget"; import { useOverviewMetrics } from "@/hooks/dashboard/useOverviewMetrics"; import { useOverviewRoasRankings } from "@/hooks/dashboard/useOverviewRoasRankings"; +import ChartErrorFallback from "@/components/common/error/ChartErrorFallback"; +import { ErrorBoundary } from "@/components/common/error/ErrorBoundary"; +import MetricErrorFallback from "@/components/common/error/MetricErrorFallback"; import DashboardAiSummarySection from "@/components/dashboard/ai-report/components/DashboardAiSummarySection"; import { getBudgetStatus } from "@/components/dashboard/charts/BudgetGaugeChart"; @@ -49,33 +52,42 @@ export default function OverviewDashboard() { return (
- - + + + + + + +
- navigate("/platform")} - /> + + navigate("/platform")} + /> + - + + +
); } diff --git a/src/routes/Router.tsx b/src/routes/Router.tsx index 1d1a1421..42d39d2c 100644 --- a/src/routes/Router.tsx +++ b/src/routes/Router.tsx @@ -7,7 +7,8 @@ import MainRoutes from "./MainRoutes"; import AuthLayout from "@/layout/auth/AuthLayout"; import GlobalLayout from "@/layout/GlobalLayout"; import MainLayout from "@/layout/main/MainLayout"; -import Error from "@/pages/common/Error"; +import ErrorPage from "@/pages/common/Error"; +import NotFound from "@/pages/common/NotFound"; import useAuthStore from "@/store/useAuthStore"; const LandingPage = React.lazy(() => import("@/pages/landing/LandingPage")); @@ -35,11 +36,11 @@ export const router = createBrowserRouter([ ), - errorElement: , + errorElement: , }, { element: , - errorElement: , + errorElement: , children: [ { path: "/landing", @@ -61,6 +62,10 @@ export const router = createBrowserRouter([ ), children: MainRoutes, }, + { + path: "*", + element: , + }, ], }, ]); From 82daa50f6c06809c83384d27e4f2b69518ce7aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=A0=9C=EA=B2=BD?= Date: Thu, 2 Jul 2026 22:31:18 +0900 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20=EC=97=90=EB=9F=AC=C2=B7404=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B7=B0=ED=8F=AC=ED=8A=B8=20?= =?UTF-8?q?=EC=A4=91=EC=95=99=20=EC=A0=95=EB=A0=AC=20=EB=B0=8F=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Error, NotFound: h-full min-h-[70vh] → min-h-screen으로 교체하여 완전 중앙 정렬 - ComingSoonPlaceholder: 임의값 클래스를 Tailwind 토큰으로 통일 --- src/components/common/ComingSoonPlaceholder.tsx | 2 +- src/pages/common/Error.tsx | 4 ++-- src/pages/common/NotFound.tsx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/common/ComingSoonPlaceholder.tsx b/src/components/common/ComingSoonPlaceholder.tsx index 8011f96f..46957a36 100644 --- a/src/components/common/ComingSoonPlaceholder.tsx +++ b/src/components/common/ComingSoonPlaceholder.tsx @@ -52,7 +52,7 @@ const ComingSoonPlaceholder = memo(function ComingSoonPlaceholder({ )} > +
+
Date: Fri, 3 Jul 2026 12:57:15 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20MetricErrorFallback,=20ChartErrorFa?= =?UTF-8?q?llback=20=EC=8A=A4=ED=86=A0=EB=A6=AC=EB=B6=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../error/ChartErrorFallback.stories.tsx | 28 +++++++++++++++++++ .../error/MetricErrorFallback.stories.tsx | 27 ++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/components/common/error/ChartErrorFallback.stories.tsx create mode 100644 src/components/common/error/MetricErrorFallback.stories.tsx diff --git a/src/components/common/error/ChartErrorFallback.stories.tsx b/src/components/common/error/ChartErrorFallback.stories.tsx new file mode 100644 index 00000000..3ad91aee --- /dev/null +++ b/src/components/common/error/ChartErrorFallback.stories.tsx @@ -0,0 +1,28 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import { fn } from "@storybook/test"; + +import ChartErrorFallback from "./ChartErrorFallback"; + +const meta: Meta = { + title: "Common/Error/ChartErrorFallback", + component: ChartErrorFallback, + args: { + error: new Error("차트 데이터를 불러오지 못했습니다."), + resetErrorBoundary: fn(), + }, + parameters: { layout: "centered" }, +}; + +export default meta; +type TStory = StoryObj; + +export const Default: TStory = {}; + +export const InCard: TStory = { + render: (args) => ( +
+

실시간 트래픽 변화

+ +
+ ), +}; diff --git a/src/components/common/error/MetricErrorFallback.stories.tsx b/src/components/common/error/MetricErrorFallback.stories.tsx new file mode 100644 index 00000000..123b1a36 --- /dev/null +++ b/src/components/common/error/MetricErrorFallback.stories.tsx @@ -0,0 +1,27 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import { fn } from "@storybook/test"; + +import MetricErrorFallback from "./MetricErrorFallback"; + +const meta: Meta = { + title: "Common/Error/MetricErrorFallback", + component: MetricErrorFallback, + args: { + error: new Error("지표 데이터를 불러오지 못했습니다."), + resetErrorBoundary: fn(), + }, + parameters: { layout: "centered" }, +}; + +export default meta; +type TStory = StoryObj; + +export const Default: TStory = {}; + +export const InGrid: TStory = { + render: (args) => ( +
+ +
+ ), +}; From a1ec648d660a68702a00697b71056d004ccd9618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=A0=9C=EA=B2=BD?= Date: Fri, 3 Jul 2026 13:18:04 +0900 Subject: [PATCH 4/8] =?UTF-8?q?refactor:=20ErrorBoundary=EB=A5=BC=20?= =?UTF-8?q?=EC=84=B9=EC=85=98=20=EB=82=B4=EB=B6=80=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=ED=95=98=EC=97=AC=20=EC=B9=B4=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EC=9C=A0=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - KPI 섹션: ErrorBoundary를 카드 그리드·트래픽 차트 내부로 이동 - Budget 섹션: 예산 카드 헤더 유지, 차트 콘텐츠 영역에만 ErrorBoundary 적용 - OverviewDashboard에서 KPI·Budget 바깥 ErrorBoundary 제거 - ChartErrorFallback: flex-1 추가 및 배경 투명도 조정 - MetricErrorFallback: min-h-28 추가 --- .../common/error/ChartErrorFallback.tsx | 2 +- .../common/error/MetricErrorFallback.tsx | 2 +- .../dashboard/overview/OverviewDashboard.tsx | 32 +++++------- .../sections/OverviewBudgetSection.tsx | 34 +++++++------ .../overview/sections/OverviewKpiSection.tsx | 51 +++++++++++-------- 5 files changed, 63 insertions(+), 58 deletions(-) diff --git a/src/components/common/error/ChartErrorFallback.tsx b/src/components/common/error/ChartErrorFallback.tsx index 765590ee..89751fac 100644 --- a/src/components/common/error/ChartErrorFallback.tsx +++ b/src/components/common/error/ChartErrorFallback.tsx @@ -12,7 +12,7 @@ const ChartErrorFallback = memo(function ChartErrorFallback({ return (
- - - - - - - + +
diff --git a/src/pages/dashboard/overview/sections/OverviewBudgetSection.tsx b/src/pages/dashboard/overview/sections/OverviewBudgetSection.tsx index 0953aabb..74423430 100644 --- a/src/pages/dashboard/overview/sections/OverviewBudgetSection.tsx +++ b/src/pages/dashboard/overview/sections/OverviewBudgetSection.tsx @@ -7,6 +7,8 @@ import Card from "@/components/common/card/Card"; import ChartLegend, { type IChartLegendItem, } from "@/components/common/chart/ChartLegend"; +import ChartErrorFallback from "@/components/common/error/ChartErrorFallback"; +import { ErrorBoundary } from "@/components/common/error/ErrorBoundary"; import type { getBudgetStatus } from "@/components/dashboard/charts/BudgetGaugeChart"; import BudgetGaugeChart, { statusBadgeVariant, @@ -58,21 +60,23 @@ export function OverviewBudgetSection({ } >
- {isBudgetError ? ( -
- {budgetError?.message ?? ( - <> - 예산 데이터를 불러오지 못했습니다. -
- 잠시 후 다시 시도해 주세요. - - )} -
- ) : isBudgetLoading ? ( - - ) : budget ? ( - - ) : null} + + {isBudgetError ? ( +
+ {budgetError?.message ?? ( + <> + 예산 데이터를 불러오지 못했습니다. +
+ 잠시 후 다시 시도해 주세요. + + )} +
+ ) : isBudgetLoading ? ( + + ) : budget ? ( + + ) : null} +
diff --git a/src/pages/dashboard/overview/sections/OverviewKpiSection.tsx b/src/pages/dashboard/overview/sections/OverviewKpiSection.tsx index f8d08209..6d54e381 100644 --- a/src/pages/dashboard/overview/sections/OverviewKpiSection.tsx +++ b/src/pages/dashboard/overview/sections/OverviewKpiSection.tsx @@ -9,6 +9,9 @@ import type { useOverviewMetrics } from "@/hooks/dashboard/useOverviewMetrics"; import Card from "@/components/common/card/Card"; import StatCard from "@/components/common/card/StatCard"; import ChartLegend from "@/components/common/chart/ChartLegend"; +import ChartErrorFallback from "@/components/common/error/ChartErrorFallback"; +import { ErrorBoundary } from "@/components/common/error/ErrorBoundary"; +import MetricErrorFallback from "@/components/common/error/MetricErrorFallback"; import TrafficChart, { TrafficChartDownload, } from "@/components/dashboard/charts/TrafficChart"; @@ -32,25 +35,27 @@ export function OverviewKpiSection({ return (
- {isKpisError ? ( -
- {kpisError?.message ?? - "지표 데이터를 불러오지 못했습니다. 잠시 후 다시 시도해 주세요."} -
- ) : ( -
- {isKpisLoading - ? [0, 1, 2, 3].map((i) => ) - : kpiList.map((kpi) => ( - - ))} -
- )} + + {isKpisError ? ( +
+ {kpisError?.message ?? + "지표 데이터를 불러오지 못했습니다. 잠시 후 다시 시도해 주세요."} +
+ ) : ( +
+ {isKpisLoading + ? [0, 1, 2, 3].map((i) => ) + : kpiList.map((kpi) => ( + + ))} +
+ )} +
} >
- }> - - + + }> + + +
From 3864c8375943874cb55f6e422f2fecf63be16aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=A0=9C=EA=B2=BD?= Date: Fri, 3 Jul 2026 13:25:18 +0900 Subject: [PATCH 5/8] =?UTF-8?q?fix:=20pnpm-lock.yaml=EC=97=90=20react-erro?= =?UTF-8?q?r-boundary=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pnpm-lock.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85c8cda9..1aa270f7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,9 @@ importers: react-dom: specifier: ^19.2.0 version: 19.2.4(react@19.2.4) + react-error-boundary: + specifier: ^6.1.2 + version: 6.1.2(react@19.2.4) react-hook-form: specifier: ^7.71.1 version: 7.71.1(react@19.2.4) @@ -2925,6 +2928,11 @@ packages: peerDependencies: react: ^19.2.4 + react-error-boundary@6.1.2: + resolution: {integrity: sha512-3DpCr5HVdZ0caUjYE/kIHBEJN0mNP3ZCgf16c48uJ5TbWjorKVp+YG8W3XqlJ7vJAVNw6wNIImyPXmFydwmyng==} + peerDependencies: + react: ^18.0.0 || ^19.0.0 + react-hook-form@7.71.1: resolution: {integrity: sha512-9SUJKCGKo8HUSsCO+y0CtqkqI5nNuaDqTxyqPsZPqIwudpj4rCrAz/jZV+jn57bx5gtZKOh3neQu94DXMc+w5w==} engines: {node: '>=18.0.0'} @@ -6553,6 +6561,10 @@ snapshots: react: 19.2.4 scheduler: 0.27.0 + react-error-boundary@6.1.2(react@19.2.4): + dependencies: + react: 19.2.4 + react-hook-form@7.71.1(react@19.2.4): dependencies: react: 19.2.4 From 762dfbc86d385d417dca51e31b463a4ea2222701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=A0=9C=EA=B2=BD?= Date: Fri, 3 Jul 2026 15:04:59 +0900 Subject: [PATCH 6/8] =?UTF-8?q?refactor:=20=EC=A4=91=EB=B3=B5=20=EC=95=A0?= =?UTF-8?q?=EB=8B=88=EB=A9=94=EC=9D=B4=EC=85=98/=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83=EC=9D=84=20ErrorLayout=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=B6=94=EC=B6=9C=ED=95=98=EA=B3=A0=20resetKeys=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - src/lib/animation.ts: easeOut, containerVariants, itemVariants 공용 프리셋 분리 - ErrorLayout 컴포넌트 신규 생성: NotFound·Error 페이지의 공통 motion wrapper 통합 - OverviewPlatformSection ErrorBoundary에 resetKeys={[roasRankingsData]} 추가 - OverviewBudgetSection ErrorBoundary에 resetKeys={[budget]} 추가 --- src/components/common/error/ErrorLayout.tsx | 66 +++++++++++++++ src/lib/animation.ts | 23 ++++++ src/pages/common/Error.tsx | 78 +++--------------- src/pages/common/NotFound.tsx | 80 +++---------------- .../dashboard/overview/OverviewDashboard.tsx | 5 +- .../sections/OverviewBudgetSection.tsx | 5 +- 6 files changed, 117 insertions(+), 140 deletions(-) create mode 100644 src/components/common/error/ErrorLayout.tsx create mode 100644 src/lib/animation.ts diff --git a/src/components/common/error/ErrorLayout.tsx b/src/components/common/error/ErrorLayout.tsx new file mode 100644 index 00000000..b83a23ad --- /dev/null +++ b/src/components/common/error/ErrorLayout.tsx @@ -0,0 +1,66 @@ +import { memo, type ReactNode } from "react"; +import { motion, useReducedMotion } from "framer-motion"; + +import WarningIcon from "@/assets/icon/ai/warning.svg?react"; +import { containerVariants, itemVariants } from "@/lib/animation"; + +interface IErrorLayoutProps { + title: string; + description: string; + actions: ReactNode; +} + +const ErrorLayout = memo(function ErrorLayout({ + title, + description, + actions, +}: IErrorLayoutProps) { + const reduceMotion = useReducedMotion(); + + return ( +
+ + + + + + + {title} + + + + {description} + + + + {actions} + + +
+ ); +}); + +export default ErrorLayout; diff --git a/src/lib/animation.ts b/src/lib/animation.ts new file mode 100644 index 00000000..d0842947 --- /dev/null +++ b/src/lib/animation.ts @@ -0,0 +1,23 @@ +export const easeOut = [0, 0, 0.2, 1] as const; + +export const containerVariants = { + hidden: {}, + visible: (reduce: boolean) => ({ + transition: { + staggerChildren: reduce ? 0 : 0.05, + delayChildren: 0, + }, + }), +}; + +export const itemVariants = { + hidden: (reduce: boolean) => ({ + opacity: reduce ? 1 : 0, + y: reduce ? 0 : 10, + }), + visible: (reduce: boolean) => ({ + opacity: 1, + y: 0, + transition: { duration: reduce ? 0 : 0.35, ease: easeOut }, + }), +}; diff --git a/src/pages/common/Error.tsx b/src/pages/common/Error.tsx index aa3784ab..504470b9 100644 --- a/src/pages/common/Error.tsx +++ b/src/pages/common/Error.tsx @@ -1,39 +1,12 @@ import { memo } from "react"; import { useNavigate, useRouteError } from "react-router-dom"; -import { motion, useReducedMotion } from "framer-motion"; import Button from "@/components/common/button/Button"; - -import WarningIcon from "@/assets/icon/ai/warning.svg?react"; - -const easeOut = [0, 0, 0.2, 1] as const; - -const containerVariants = { - hidden: {}, - visible: (reduce: boolean) => ({ - transition: { - staggerChildren: reduce ? 0 : 0.05, - delayChildren: 0, - }, - }), -}; - -const itemVariants = { - hidden: (reduce: boolean) => ({ - opacity: reduce ? 1 : 0, - y: reduce ? 0 : 10, - }), - visible: (reduce: boolean) => ({ - opacity: 1, - y: 0, - transition: { duration: reduce ? 0 : 0.35, ease: easeOut }, - }), -}; +import ErrorLayout from "@/components/common/error/ErrorLayout"; const ErrorPage = memo(function ErrorPage() { const error = useRouteError() as { status?: number; message?: string } | null; const navigate = useNavigate(); - const reduceMotion = useReducedMotion(); const is404 = error?.status === 404; const title = is404 ? "페이지를 찾을 수 없어요" : "오류가 발생했어요"; @@ -42,44 +15,11 @@ const ErrorPage = memo(function ErrorPage() { : "일시적인 오류가 발생했습니다.\n잠시 후 다시 시도해 주세요."; return ( -
- - - - - - - {title} - - - - {description} - - - + {!is404 && ( - - -
+ + } + /> ); }); diff --git a/src/pages/common/NotFound.tsx b/src/pages/common/NotFound.tsx index ec26c7cb..7329d4b8 100644 --- a/src/pages/common/NotFound.tsx +++ b/src/pages/common/NotFound.tsx @@ -1,78 +1,20 @@ import { memo } from "react"; import { useNavigate } from "react-router-dom"; -import { motion, useReducedMotion } from "framer-motion"; import Button from "@/components/common/button/Button"; - -import WarningIcon from "@/assets/icon/ai/warning.svg?react"; - -const easeOut = [0, 0, 0.2, 1] as const; - -const containerVariants = { - hidden: {}, - visible: (reduce: boolean) => ({ - transition: { - staggerChildren: reduce ? 0 : 0.05, - delayChildren: 0, - }, - }), -}; - -const itemVariants = { - hidden: (reduce: boolean) => ({ - opacity: reduce ? 1 : 0, - y: reduce ? 0 : 10, - }), - visible: (reduce: boolean) => ({ - opacity: 1, - y: 0, - transition: { duration: reduce ? 0 : 0.35, ease: easeOut }, - }), -}; +import ErrorLayout from "@/components/common/error/ErrorLayout"; const NotFound = memo(function NotFound() { const navigate = useNavigate(); - const reduceMotion = useReducedMotion(); return ( -
- - - - - - - 페이지를 찾을 수 없어요 - - - - {"요청하신 페이지가 존재하지 않거나\n주소가 변경되었을 수 있어요."} - - - + - - -
+ + } + /> ); }); diff --git a/src/pages/dashboard/overview/OverviewDashboard.tsx b/src/pages/dashboard/overview/OverviewDashboard.tsx index c3902a5e..418cd9c6 100644 --- a/src/pages/dashboard/overview/OverviewDashboard.tsx +++ b/src/pages/dashboard/overview/OverviewDashboard.tsx @@ -66,7 +66,10 @@ export default function OverviewDashboard() { />
- +
- + {isBudgetError ? (
{budgetError?.message ?? ( From b1b3328d65c6c95fdd65a1e0abb0f5e7cec16856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=A0=9C=EA=B2=BD?= Date: Fri, 3 Jul 2026 15:22:57 +0900 Subject: [PATCH 7/8] =?UTF-8?q?refactor:=20=EC=A0=91=EA=B7=BC=EC=84=B1?= =?UTF-8?q?=C2=B7=ED=83=80=EC=9E=85=20=EC=95=88=EC=A0=84=EC=84=B1=C2=B7Err?= =?UTF-8?q?orBoundary=20=EB=A1=9C=EA=B9=85=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ErrorLayout: role="alert" → "status"로 교체, memo 제거 - Error.tsx: memo 제거, useRouteError 타입 캐스트 → isRouteErrorResponse 분기 - NotFound.tsx: memo 제거, navigate(-1) → history 길이 확인 후 안전한 fallback 추가 - OverviewDashboard: 두 ErrorBoundary에 onError 핸들러 추가해 렌더 에러 로깅 --- src/components/common/error/ErrorLayout.tsx | 12 ++++-------- src/pages/common/Error.tsx | 17 +++++++++-------- src/pages/common/NotFound.tsx | 13 +++++++------ .../dashboard/overview/OverviewDashboard.tsx | 14 +++++++++++++- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/components/common/error/ErrorLayout.tsx b/src/components/common/error/ErrorLayout.tsx index b83a23ad..0c7ce050 100644 --- a/src/components/common/error/ErrorLayout.tsx +++ b/src/components/common/error/ErrorLayout.tsx @@ -1,4 +1,4 @@ -import { memo, type ReactNode } from "react"; +import { type ReactNode } from "react"; import { motion, useReducedMotion } from "framer-motion"; import WarningIcon from "@/assets/icon/ai/warning.svg?react"; @@ -10,18 +10,14 @@ interface IErrorLayoutProps { actions: ReactNode; } -const ErrorLayout = memo(function ErrorLayout({ - title, - description, - actions, -}: IErrorLayoutProps) { +function ErrorLayout({ title, description, actions }: IErrorLayoutProps) { const reduceMotion = useReducedMotion(); return (
); -}); +} export default ErrorLayout; diff --git a/src/pages/common/Error.tsx b/src/pages/common/Error.tsx index 504470b9..f5cc3a07 100644 --- a/src/pages/common/Error.tsx +++ b/src/pages/common/Error.tsx @@ -1,14 +1,17 @@ -import { memo } from "react"; -import { useNavigate, useRouteError } from "react-router-dom"; +import { + isRouteErrorResponse, + useNavigate, + useRouteError, +} from "react-router-dom"; import Button from "@/components/common/button/Button"; import ErrorLayout from "@/components/common/error/ErrorLayout"; -const ErrorPage = memo(function ErrorPage() { - const error = useRouteError() as { status?: number; message?: string } | null; +export default function ErrorPage() { + const error = useRouteError(); const navigate = useNavigate(); - const is404 = error?.status === 404; + const is404 = isRouteErrorResponse(error) && error.status === 404; const title = is404 ? "페이지를 찾을 수 없어요" : "오류가 발생했어요"; const description = is404 ? "요청하신 페이지가 존재하지 않거나\n주소가 변경되었을 수 있어요." @@ -42,6 +45,4 @@ const ErrorPage = memo(function ErrorPage() { } /> ); -}); - -export default ErrorPage; +} diff --git a/src/pages/common/NotFound.tsx b/src/pages/common/NotFound.tsx index 7329d4b8..fdbcc275 100644 --- a/src/pages/common/NotFound.tsx +++ b/src/pages/common/NotFound.tsx @@ -1,10 +1,9 @@ -import { memo } from "react"; import { useNavigate } from "react-router-dom"; import Button from "@/components/common/button/Button"; import ErrorLayout from "@/components/common/error/ErrorLayout"; -const NotFound = memo(function NotFound() { +export default function NotFound() { const navigate = useNavigate(); return ( @@ -19,7 +18,11 @@ const NotFound = memo(function NotFound() { size="big" variant="secondary" fullWidth - onClick={() => navigate(-1)} + onClick={() => + window.history.length > 1 + ? navigate(-1) + : navigate("/", { replace: true }) + } > 이전 페이지로 @@ -35,6 +38,4 @@ const NotFound = memo(function NotFound() { } /> ); -}); - -export default NotFound; +} diff --git a/src/pages/dashboard/overview/OverviewDashboard.tsx b/src/pages/dashboard/overview/OverviewDashboard.tsx index 418cd9c6..393b1709 100644 --- a/src/pages/dashboard/overview/OverviewDashboard.tsx +++ b/src/pages/dashboard/overview/OverviewDashboard.tsx @@ -69,6 +69,9 @@ export default function OverviewDashboard() { + console.error("[OverviewPlatformSection]", error, info.componentStack) + } > - + + console.error( + "[DashboardAiSummarySection]", + error, + info.componentStack, + ) + } + > Date: Fri, 3 Jul 2026 15:28:49 +0900 Subject: [PATCH 8/8] =?UTF-8?q?refactor:=20onError=20console.error=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20(React=EA=B0=80=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=BD=98=EC=86=94=20=EC=B6=9C=EB=A0=A5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/dashboard/overview/OverviewDashboard.tsx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/pages/dashboard/overview/OverviewDashboard.tsx b/src/pages/dashboard/overview/OverviewDashboard.tsx index 393b1709..418cd9c6 100644 --- a/src/pages/dashboard/overview/OverviewDashboard.tsx +++ b/src/pages/dashboard/overview/OverviewDashboard.tsx @@ -69,9 +69,6 @@ export default function OverviewDashboard() { - console.error("[OverviewPlatformSection]", error, info.componentStack) - } > - - console.error( - "[DashboardAiSummarySection]", - error, - info.componentStack, - ) - } - > +