251127:1700 Frontend Start Build
This commit is contained in:
31
frontend/providers/query-provider.tsx
Normal file
31
frontend/providers/query-provider.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
// File: providers/query-provider.tsx
|
||||
"use client";
|
||||
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function QueryProvider({ children }: { children: React.ReactNode }) {
|
||||
// สร้าง QueryClient instance เพียงครั้งเดียวต่อ request
|
||||
const [queryClient] = useState(
|
||||
() =>
|
||||
new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
// ข้อมูลจะถือว่า "สดใหม่" (Fresh) เป็นเวลา 1 นาที
|
||||
staleTime: 60 * 1000,
|
||||
// จำนวนครั้งที่จะลองใหม่ถ้า Request ล้มเหลว
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{children}
|
||||
<ReactQueryDevtools initialIsOpen={false} buttonPosition="bottom-right" />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
8
frontend/providers/session-provider.tsx
Normal file
8
frontend/providers/session-provider.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
// File: providers/session-provider.tsx
|
||||
"use client";
|
||||
|
||||
import { SessionProvider as NextAuthSessionProvider } from "next-auth/react";
|
||||
|
||||
export default function SessionProvider({ children }: { children: React.ReactNode }) {
|
||||
return <NextAuthSessionProvider>{children}</NextAuthSessionProvider>;
|
||||
}
|
||||
Reference in New Issue
Block a user