From 748bb1720fd81e97a84c3e92f89d606e976b52e3 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Wed, 28 May 2025 00:18:16 +0000
Subject: (대표님) 컴포넌트 파트 커밋
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/layout/providers.tsx | 49 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 41 insertions(+), 8 deletions(-)

(limited to 'components/layout/providers.tsx')

diff --git a/components/layout/providers.tsx b/components/layout/providers.tsx
index 1c645531..376c419a 100644
--- a/components/layout/providers.tsx
+++ b/components/layout/providers.tsx
@@ -4,15 +4,47 @@ import * as React from "react"
 import { Provider as JotaiProvider } from "jotai"
 import { ThemeProvider as NextThemesProvider } from "next-themes"
 import { NuqsAdapter } from "nuqs/adapters/next/app"
-import { SessionProvider } from "next-auth/react";
-import { CacheProvider } from '@emotion/react';
+import { SessionProvider } from "next-auth/react"
+import { CacheProvider } from '@emotion/react'
+import { SWRConfig } from 'swr' // ✅ SWR 추가
 
 import { TooltipProvider } from "@/components/ui/tooltip"
-import createEmotionCache from './createEmotionCashe';
+import createEmotionCache from './createEmotionCashe'
 
+const cache = createEmotionCache()
 
-const cache = createEmotionCache();
-
+// 간소화된 SWR 설정
+const swrConfig = {
+  // 기본 동작 설정
+  revalidateOnFocus: false,        // 포커스시 자동 갱신 비활성화
+  revalidateOnReconnect: true,     // 재연결시 갱신 활성화
+  shouldRetryOnError: false,       // 에러시 자동 재시도 비활성화 (수동으로 제어)
+  dedupingInterval: 2000,          // 2초 내 중복 요청 방지
+  refreshInterval: 0,              // 기본적으로 자동 갱신 비활성화 (개별 훅에서 설정)
+  
+  // 간단한 전역 에러 핸들러 (토스트 없이 로깅만)
+  onError: (error: any, key: string) => {
+    // 개발 환경에서만 상세 로깅
+    if (process.env.NODE_ENV === 'development') {
+      console.warn('SWR fetch failed:', { 
+        url: key, 
+        status: error?.status, 
+        message: error?.message 
+      })
+    }
+    
+    // 401 Unauthorized의 경우 특별 처리 (선택사항)
+    if (error?.status === 401) {
+      console.warn('Authentication required')
+      // 필요시 로그인 페이지로 리다이렉트
+      // window.location.href = '/login'
+    }
+  },
+  
+  // 전역 성공 핸들러는 제거 (너무 많은 로그 방지)
+  
+  // 기본 fetcher 제거 (각 훅에서 개별 관리)
+}
 
 export function ThemeProvider({
   children,
@@ -21,18 +53,19 @@ export function ThemeProvider({
   return (
     <JotaiProvider>
       <CacheProvider value={cache}>
-
         <NextThemesProvider {...props}>
           <TooltipProvider delayDuration={0}>
             <NuqsAdapter>
               <SessionProvider>
-                {children}
+                {/* ✅ 간소화된 SWR 설정 적용 */}
+                <SWRConfig value={swrConfig}>
+                  {children}
+                </SWRConfig>
               </SessionProvider>
             </NuqsAdapter>
           </TooltipProvider>
         </NextThemesProvider>
       </CacheProvider>
-
     </JotaiProvider>
   )
 }
-- 
cgit v1.2.3

