@digitaldefiance/express-suite-react-components 4.26.23 → 4.26.24
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "4.26.
|
|
3
|
+
"version": "4.26.24",
|
|
4
4
|
"homepage": "https://github.com/Digital-Defiance/react-components",
|
|
5
5
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
6
6
|
"repository": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminRoute.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/auth/AdminRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AdminRoute.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/auth/AdminRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAWlD,UAAU,eAAe;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAmC1C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/src/auth/AdminRoute.js
CHANGED
|
@@ -7,20 +7,20 @@ const react_router_dom_1 = require("react-router-dom");
|
|
|
7
7
|
const AuthProvider_1 = require("../contexts/AuthProvider");
|
|
8
8
|
const contexts_1 = require("../contexts");
|
|
9
9
|
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
10
|
-
const
|
|
10
|
+
const AuthProvider_2 = require("../contexts/AuthProvider");
|
|
11
11
|
const AdminRoute = ({ children, redirectTo }) => {
|
|
12
|
-
const { admin } = (0,
|
|
12
|
+
const { admin } = (0, AuthProvider_2.useAuth)();
|
|
13
13
|
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
14
|
const { isAuthenticated, isCheckingAuth } = (0, react_1.useContext)(AuthProvider_1.AuthContext);
|
|
15
15
|
const location = (0, react_router_dom_1.useLocation)();
|
|
16
16
|
if (isCheckingAuth) {
|
|
17
|
-
return (0, jsx_runtime_1.jsxs)("div", { children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_CheckingAuthentication), "..."] });
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_CheckingAuthentication), "..."] }));
|
|
18
18
|
}
|
|
19
19
|
if (!isAuthenticated) {
|
|
20
|
-
return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo ??
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo ?? '/login', state: { from: location }, replace: true }));
|
|
21
21
|
}
|
|
22
22
|
if (!admin) {
|
|
23
|
-
return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo ??
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo ?? '/', state: { from: location }, replace: true }));
|
|
24
24
|
}
|
|
25
25
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
26
26
|
};
|