@digitaldefiance/express-suite-react-components 4.26.22 → 4.26.23
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.23",
|
|
4
4
|
"homepage": "https://github.com/Digital-Defiance/react-components",
|
|
5
5
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
6
6
|
"repository": {
|
|
@@ -0,0 +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;AAOlD,UAAU,eAAe;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAmB1C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminRoute = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
7
|
+
const AuthProvider_1 = require("../contexts/AuthProvider");
|
|
8
|
+
const contexts_1 = require("../contexts");
|
|
9
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
10
|
+
const express_suite_react_components_1 = require("@digitaldefiance/express-suite-react-components");
|
|
11
|
+
const AdminRoute = ({ children, redirectTo }) => {
|
|
12
|
+
const { admin } = (0, express_suite_react_components_1.useAuth)();
|
|
13
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
|
+
const { isAuthenticated, isCheckingAuth } = (0, react_1.useContext)(AuthProvider_1.AuthContext);
|
|
15
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
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), "..."] });
|
|
18
|
+
}
|
|
19
|
+
if (!isAuthenticated) {
|
|
20
|
+
return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo ?? "/login", state: { from: location }, replace: true });
|
|
21
|
+
}
|
|
22
|
+
if (!admin) {
|
|
23
|
+
return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo ?? "/", state: { from: location }, replace: true });
|
|
24
|
+
}
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
26
|
+
};
|
|
27
|
+
exports.AdminRoute = AdminRoute;
|
|
28
|
+
exports.default = exports.AdminRoute;
|
package/src/auth/index.d.ts
CHANGED
package/src/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAA"}
|
package/src/auth/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnAuthRoute = exports.PrivateRoute = void 0;
|
|
3
|
+
exports.UnAuthRoute = exports.PrivateRoute = exports.AdminRoute = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
var AdminRoute_1 = require("./AdminRoute");
|
|
6
|
+
Object.defineProperty(exports, "AdminRoute", { enumerable: true, get: function () { return tslib_1.__importDefault(AdminRoute_1).default; } });
|
|
5
7
|
var PrivateRoute_1 = require("./PrivateRoute");
|
|
6
8
|
Object.defineProperty(exports, "PrivateRoute", { enumerable: true, get: function () { return tslib_1.__importDefault(PrivateRoute_1).default; } });
|
|
7
9
|
var UnAuthRoute_1 = require("./UnAuthRoute");
|