l-min-components 1.7.1377 → 1.7.1379
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/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import logo from "../../assets/images/logo.png";
|
|
|
5
5
|
import bg from "./images/bg-404.png";
|
|
6
6
|
import redirectURL from "../../utils/redirectURL";
|
|
7
7
|
import useCustomNavigate from "../../hooks/useCustomNavigate";
|
|
8
|
+
import getCookie from "../../utils/getCookie";
|
|
8
9
|
|
|
9
10
|
const ErrorWrapper = ({
|
|
10
11
|
title = "Oops!",
|
|
@@ -13,10 +14,22 @@ const ErrorWrapper = ({
|
|
|
13
14
|
btnText = "Go to home page",
|
|
14
15
|
bgSrc,
|
|
15
16
|
fallbackPath,
|
|
17
|
+
isDashboard,
|
|
16
18
|
}) => {
|
|
17
19
|
const navigate = useCustomNavigate();
|
|
18
20
|
const handleNav = () => {
|
|
19
|
-
|
|
21
|
+
const accountType = getCookie("defaultAccountType")?.toLocaleLowerCase();
|
|
22
|
+
|
|
23
|
+
if (isDashboard && accountType) {
|
|
24
|
+
const route =
|
|
25
|
+
accountType === "developer"
|
|
26
|
+
? "/developer"
|
|
27
|
+
: `/${accountType}/dashboard`;
|
|
28
|
+
|
|
29
|
+
navigate(fallbackPath || route || "/", { replace: true });
|
|
30
|
+
} else {
|
|
31
|
+
navigate(fallbackPath || "/", { replace: true });
|
|
32
|
+
}
|
|
20
33
|
};
|
|
21
34
|
return (
|
|
22
35
|
<Container>
|
|
@@ -3,8 +3,12 @@ import bg403 from "./images/bg-403.png";
|
|
|
3
3
|
import bg500 from "./images/bg-500.png";
|
|
4
4
|
import bg503 from "./images/bg-503.png";
|
|
5
5
|
|
|
6
|
-
const Error404 = ({ btnText, fallbackPath }) => (
|
|
7
|
-
<ErrorWrapper
|
|
6
|
+
const Error404 = ({ btnText, fallbackPath, isDashboard }) => (
|
|
7
|
+
<ErrorWrapper
|
|
8
|
+
fallbackPath={fallbackPath}
|
|
9
|
+
btnText={btnText}
|
|
10
|
+
isDashboard={isDashboard}
|
|
11
|
+
/>
|
|
8
12
|
);
|
|
9
13
|
const Error403 = ({ btnText, fallbackPath }) => (
|
|
10
14
|
<ErrorWrapper
|
|
@@ -13,6 +17,7 @@ const Error403 = ({ btnText, fallbackPath }) => (
|
|
|
13
17
|
bgSrc={bg403}
|
|
14
18
|
fallbackPath={fallbackPath}
|
|
15
19
|
btnText={btnText}
|
|
20
|
+
isDashboard={isDashboard}
|
|
16
21
|
/>
|
|
17
22
|
);
|
|
18
23
|
const Error500 = ({ btnText, fallbackPath }) => (
|
|
@@ -22,6 +27,7 @@ const Error500 = ({ btnText, fallbackPath }) => (
|
|
|
22
27
|
bgSrc={bg500}
|
|
23
28
|
fallbackPath={fallbackPath}
|
|
24
29
|
btnText={btnText}
|
|
30
|
+
isDashboard={isDashboard}
|
|
25
31
|
/>
|
|
26
32
|
);
|
|
27
33
|
const Error503 = ({ btnText, fallbackPath }) => (
|
|
@@ -32,6 +38,7 @@ const Error503 = ({ btnText, fallbackPath }) => (
|
|
|
32
38
|
bgSrc={bg503}
|
|
33
39
|
fallbackPath={fallbackPath}
|
|
34
40
|
btnText={btnText}
|
|
41
|
+
isDashboard={isDashboard}
|
|
35
42
|
/>
|
|
36
43
|
);
|
|
37
44
|
|
|
@@ -40,35 +47,102 @@ function ErrorBoundary({
|
|
|
40
47
|
isRouteErrorResponse,
|
|
41
48
|
fallbackPath,
|
|
42
49
|
btnText,
|
|
50
|
+
isDashboard,
|
|
43
51
|
}) {
|
|
44
52
|
if (isRouteErrorResponse?.(routeError)) {
|
|
45
53
|
if (error.status === 404)
|
|
46
|
-
return
|
|
54
|
+
return (
|
|
55
|
+
<Error404
|
|
56
|
+
fallbackPath={fallbackPath}
|
|
57
|
+
btnText={btnText}
|
|
58
|
+
isDashboard={isDashboard}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
47
61
|
if (error.status === 403)
|
|
48
|
-
return
|
|
62
|
+
return (
|
|
63
|
+
<Error403
|
|
64
|
+
fallbackPath={fallbackPath}
|
|
65
|
+
btnText={btnText}
|
|
66
|
+
isDashboard={isDashboard}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
49
69
|
if (error.status === 500)
|
|
50
|
-
return
|
|
70
|
+
return (
|
|
71
|
+
<Error500
|
|
72
|
+
fallbackPath={fallbackPath}
|
|
73
|
+
btnText={btnText}
|
|
74
|
+
isDashboard={isDashboard}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
51
77
|
if (error.status === 503)
|
|
52
|
-
return
|
|
53
|
-
|
|
78
|
+
return (
|
|
79
|
+
<Error503
|
|
80
|
+
fallbackPath={fallbackPath}
|
|
81
|
+
btnText={btnText}
|
|
82
|
+
isDashboard={isDashboard}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
return (
|
|
86
|
+
<Error500
|
|
87
|
+
fallbackPath={fallbackPath}
|
|
88
|
+
btnText={btnText}
|
|
89
|
+
isDashboard={isDashboard}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
54
92
|
}
|
|
55
93
|
|
|
56
94
|
if (error instanceof Error)
|
|
57
|
-
return
|
|
58
|
-
|
|
95
|
+
return (
|
|
96
|
+
<Error500
|
|
97
|
+
fallbackPath={fallbackPath}
|
|
98
|
+
btnText={btnText}
|
|
99
|
+
isDashboard={isDashboard}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
return (
|
|
103
|
+
<Error500
|
|
104
|
+
fallbackPath={fallbackPath}
|
|
105
|
+
btnText={btnText}
|
|
106
|
+
isDashboard={isDashboard}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
59
109
|
}
|
|
60
110
|
|
|
61
|
-
function ErrorComponent({ fallbackPath, btnText }) {
|
|
111
|
+
function ErrorComponent({ fallbackPath, btnText, isDashboard = false }) {
|
|
62
112
|
const params = new URLSearchParams(window.location.search);
|
|
63
|
-
const errorParam = params.get("error");
|
|
113
|
+
const errorParam = params.get("error-status");
|
|
64
114
|
|
|
65
115
|
if (errorParam === "_403_")
|
|
66
|
-
return
|
|
116
|
+
return (
|
|
117
|
+
<Error403
|
|
118
|
+
fallbackPath={fallbackPath}
|
|
119
|
+
btnText={btnText}
|
|
120
|
+
isDashboard={isDashboard}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
67
123
|
if (errorParam === "_500_")
|
|
68
|
-
return
|
|
124
|
+
return (
|
|
125
|
+
<Error500
|
|
126
|
+
fallbackPath={fallbackPath}
|
|
127
|
+
btnText={btnText}
|
|
128
|
+
isDashboard={isDashboard}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
69
131
|
if (errorParam === "_503_")
|
|
70
|
-
return
|
|
71
|
-
|
|
132
|
+
return (
|
|
133
|
+
<Error503
|
|
134
|
+
fallbackPath={fallbackPath}
|
|
135
|
+
btnText={btnText}
|
|
136
|
+
isDashboard={isDashboard}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
return (
|
|
140
|
+
<Error404
|
|
141
|
+
fallbackPath={fallbackPath}
|
|
142
|
+
btnText={btnText}
|
|
143
|
+
isDashboard={isDashboard}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
72
146
|
}
|
|
73
147
|
|
|
74
148
|
const getErrorFeatures = () => {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { useCallback } from "react";
|
|
2
|
-
|
|
3
1
|
export default function useCustomNavigate() {
|
|
4
|
-
return
|
|
2
|
+
return (path, { replace = false, state = null } = {}) => {
|
|
5
3
|
const historyState = { ...state };
|
|
6
4
|
|
|
7
5
|
if (replace) {
|
|
@@ -11,5 +9,5 @@ export default function useCustomNavigate() {
|
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
14
|
-
}
|
|
12
|
+
};
|
|
15
13
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function getCookie(name) {
|
|
2
|
+
const cookieStr = document.cookie;
|
|
3
|
+
const cookies = cookieStr.split("; ");
|
|
4
|
+
|
|
5
|
+
for (const cookie of cookies) {
|
|
6
|
+
const [key, value] = cookie.split("=");
|
|
7
|
+
if (key === name) return decodeURIComponent(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return null; // Not found
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default getCookie;
|