@campxdev/campx-web-utils 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/exports.ts +1 -2
- package/package.json +1 -1
- package/src/App.tsx +7 -4
- package/src/config/axios.ts +12 -1
- package/src/{ErrorBoundary → context/ErrorBoundary}/ErrorBoundary.tsx +1 -1
- package/src/context/Providers.tsx +17 -22
- package/src/context/export.ts +4 -0
- package/src/ErrorBoundary/GlobalNetworkLoadingIndicator.tsx +0 -13
- package/src/ErrorBoundary/export.ts +0 -1
- package/src/context/LoginDialogProvider.tsx +0 -5
- /package/src/{ErrorBoundary → context/ErrorBoundary}/Login.tsx +0 -0
package/exports.ts
CHANGED
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { useRoutes } from "react-router-dom";
|
|
1
|
+
import { BrowserRouter, useRoutes } from "react-router-dom";
|
|
2
2
|
import Providers from "./context/Providers";
|
|
3
3
|
import { mainRoutes } from "./Pages/main";
|
|
4
4
|
|
|
5
5
|
export default function App() {
|
|
6
|
+
var baseName = "/";
|
|
6
7
|
return (
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
8
|
+
<BrowserRouter basename={baseName}>
|
|
9
|
+
<Providers>
|
|
10
|
+
<AppRouter />
|
|
11
|
+
</Providers>
|
|
12
|
+
</BrowserRouter>
|
|
10
13
|
);
|
|
11
14
|
}
|
|
12
15
|
const AppRouter = () => {
|
package/src/config/axios.ts
CHANGED
|
@@ -70,13 +70,24 @@ axios.interceptors.response.use(
|
|
|
70
70
|
return response;
|
|
71
71
|
},
|
|
72
72
|
function (err) {
|
|
73
|
-
if ([400,
|
|
73
|
+
if ([400, 422].includes(err.response.status)) {
|
|
74
74
|
SnackbarStore.update((s) => {
|
|
75
75
|
s.open = true;
|
|
76
76
|
s.message = err.response.data.message || "Bad Request";
|
|
77
77
|
s.severity = "error";
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
+
if (
|
|
81
|
+
err.response.config.method &&
|
|
82
|
+
["put", "post", "delete", "patch"].includes(err.response.config.method) &&
|
|
83
|
+
[404].includes(err.response.status)
|
|
84
|
+
) {
|
|
85
|
+
SnackbarStore.update((s) => {
|
|
86
|
+
s.open = true;
|
|
87
|
+
s.message = err.response.data.message;
|
|
88
|
+
s.severity = "success";
|
|
89
|
+
});
|
|
90
|
+
}
|
|
80
91
|
|
|
81
92
|
return Promise.reject(err);
|
|
82
93
|
}
|
|
@@ -12,7 +12,7 @@ import { ReactNode, useState } from "react";
|
|
|
12
12
|
import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary";
|
|
13
13
|
import { QueryErrorResetBoundary } from "react-query";
|
|
14
14
|
import { useLocation, useNavigate } from "react-router-dom";
|
|
15
|
-
import { axios } from "
|
|
15
|
+
import { axios } from "../../config/axios";
|
|
16
16
|
import { Login } from "./Login";
|
|
17
17
|
|
|
18
18
|
export type ErrorBoundaryProps = {
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
import { MuiThemeProvider } from "@campxdev/react-blueprint";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { QueryClient, QueryClientProvider } from "react-query";
|
|
4
|
-
import { BrowserRouter } from "react-router-dom";
|
|
5
|
-
import { ErrorBoundary } from "../ErrorBoundary/ErrorBoundary";
|
|
6
4
|
import { SnackbarProvider } from "./SnackbarProvider";
|
|
7
|
-
|
|
8
|
-
export const queryClient = new QueryClient({
|
|
9
|
-
defaultOptions: {
|
|
10
|
-
queries: {
|
|
11
|
-
refetchOnWindowFocus: false,
|
|
12
|
-
retry: false,
|
|
13
|
-
useErrorBoundary: true,
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
});
|
|
5
|
+
import { ErrorBoundary } from "./export";
|
|
17
6
|
|
|
18
7
|
export default function Providers({ children }: { children: ReactNode }) {
|
|
19
|
-
|
|
8
|
+
const queryClient = new QueryClient({
|
|
9
|
+
defaultOptions: {
|
|
10
|
+
queries: {
|
|
11
|
+
refetchOnWindowFocus: false,
|
|
12
|
+
retry: false,
|
|
13
|
+
useErrorBoundary: true,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
|
20
17
|
|
|
21
18
|
return (
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
</QueryClientProvider>
|
|
30
|
-
</BrowserRouter>
|
|
19
|
+
<QueryClientProvider client={queryClient}>
|
|
20
|
+
<MuiThemeProvider>
|
|
21
|
+
<SnackbarProvider>
|
|
22
|
+
<ErrorBoundary>{children}</ErrorBoundary>
|
|
23
|
+
</SnackbarProvider>
|
|
24
|
+
</MuiThemeProvider>
|
|
25
|
+
</QueryClientProvider>
|
|
31
26
|
);
|
|
32
27
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { LinearProgress } from "@mui/material";
|
|
2
|
-
import { Store } from "pullstate";
|
|
3
|
-
|
|
4
|
-
export const NetworkStore = new Store({
|
|
5
|
-
loading: false,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export default function GlobalNetworkLoadingIndicator() {
|
|
9
|
-
const { loading } = NetworkStore.useState();
|
|
10
|
-
|
|
11
|
-
if (loading) return <LinearProgress />;
|
|
12
|
-
if (loading) return null;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./ErrorBoundary";
|
|
File without changes
|