mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 01:32:06 +10:00
wip
This commit is contained in:
@ -2,14 +2,12 @@
|
||||
|
||||
import { useState } from 'react';
|
||||
|
||||
import type { QueryClientConfig } from '@tanstack/react-query';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { httpBatchLink, httpLink, splitLink } from '@trpc/client';
|
||||
import { createTRPCReact } from '@trpc/react-query';
|
||||
import SuperJSON from 'superjson';
|
||||
|
||||
import { getBaseUrl } from '@documenso/lib/universal/get-base-url';
|
||||
|
||||
// import { getBaseUrl } from '@documenso/lib/universal/get-base-url';
|
||||
import type { AppRouter } from '../server/router';
|
||||
|
||||
export { getQueryKey } from '@trpc/react-query';
|
||||
@ -38,28 +36,12 @@ export interface TrpcProviderProps {
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
|
||||
// 'next-runtime-env
|
||||
// Todo
|
||||
const getBaseUrl = () => 'http://localhost:3000';
|
||||
|
||||
export function TrpcProvider({ children, headers }: TrpcProviderProps) {
|
||||
let queryClientConfig: QueryClientConfig | undefined;
|
||||
|
||||
const isDevelopingOffline =
|
||||
typeof window !== 'undefined' &&
|
||||
window.location.hostname === 'localhost' &&
|
||||
!window.navigator.onLine;
|
||||
|
||||
if (isDevelopingOffline) {
|
||||
queryClientConfig = {
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
networkMode: 'always',
|
||||
},
|
||||
mutations: {
|
||||
networkMode: 'always',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const [queryClient] = useState(() => new QueryClient(queryClientConfig));
|
||||
const [queryClient] = useState(() => new QueryClient());
|
||||
|
||||
const [trpcClient] = useState(() =>
|
||||
trpc.createClient({
|
||||
|
||||
Reference in New Issue
Block a user