-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
50 lines (46 loc) · 1.52 KB
/
index.tsx
File metadata and controls
50 lines (46 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as React from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from 'react-query/devtools';
import { BrowserRouter as Router } from 'react-router-dom';
import { Button, Spinner } from '@/components/Elements';
import { Notifications } from '@/components/Notifications/Notifications';
import { AuthProvider } from '@/lib/auth';
import { queryClient } from '@/lib/react-query';
function ErrorFallback() {
return (
<div
className="text-red-500 w-screen h-screen flex flex-col justify-center items-center"
role="alert"
>
<h2 className="text-lg font-semibold">Ooops, something went wrong :( </h2>
<Button className="mt-4" onClick={() => window.location.assign(window.location.origin)}>
Refresh
</Button>
</div>
);
}
type AppProviderProps = {
children: React.ReactNode;
};
export const AppProvider = ({ children }: AppProviderProps) => {
return (
<React.Suspense
fallback={
<div className="h-screen w-screen flex items-center justify-center">
<Spinner size="xl" />
</div>
}
>
<ErrorBoundary FallbackComponent={ErrorFallback}>
<QueryClientProvider client={queryClient}>
{process.env.NODE_ENV !== 'test' && <ReactQueryDevtools />}
<Notifications />
<AuthProvider>
<Router>{children}</Router>
</AuthProvider>
</QueryClientProvider>
</ErrorBoundary>
</React.Suspense>
);
};