@digitaldefiance/express-suite-react-components 4.26.21 → 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.21",
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,8 @@
1
+ import { FC, ReactNode } from 'react';
2
+ interface AdminRouteProps {
3
+ children: ReactNode;
4
+ redirectTo?: string;
5
+ }
6
+ export declare const AdminRoute: FC<AdminRouteProps>;
7
+ export default AdminRoute;
8
+ //# sourceMappingURL=AdminRoute.d.ts.map
@@ -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;
@@ -1,3 +1,4 @@
1
+ export { default as AdminRoute } from './AdminRoute';
1
2
  export { default as PrivateRoute } from './PrivateRoute';
2
3
  export { default as UnAuthRoute } from './UnAuthRoute';
3
4
  export * from './Private';
@@ -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");
@@ -2,7 +2,6 @@ import { FC } from 'react';
2
2
  import { RegisterFormProps } from '../components/RegisterForm';
3
3
  export interface RegisterFormWrapperProps {
4
4
  onSuccess?: () => void;
5
- redirectTo?: string;
6
5
  componentProps?: Partial<Omit<RegisterFormProps, 'onSubmit' | 'timezones' | 'getInitialTimezone'>>;
7
6
  }
8
7
  export declare const RegisterFormWrapper: FC<RegisterFormWrapperProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"RegisterFormWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/RegisterFormWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,OAAO,EAEL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAGpC,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CACtB,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,WAAW,GAAG,oBAAoB,CAAC,CACzE,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAgD5D,CAAC"}
1
+ {"version":3,"file":"RegisterFormWrapper.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/RegisterFormWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAEL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAGpC,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CACtB,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,WAAW,GAAG,oBAAoB,CAAC,CACzE,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CA8C5D,CAAC"}
@@ -2,13 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RegisterFormWrapper = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_router_dom_1 = require("react-router-dom");
6
5
  const RegisterForm_1 = require("../components/RegisterForm");
7
6
  const contexts_1 = require("../contexts");
8
- const RegisterFormWrapper = ({ onSuccess, redirectTo, componentProps = {}, }) => {
7
+ const RegisterFormWrapper = ({ onSuccess, componentProps = {}, }) => {
9
8
  const { register } = (0, contexts_1.useAuth)();
10
- const navigate = (0, react_router_dom_1.useNavigate)();
11
- const { routes, timezones } = (0, contexts_1.useSuiteConfig)();
9
+ const { timezones } = (0, contexts_1.useSuiteConfig)();
12
10
  const handleSubmit = async (values) => {
13
11
  const result = await register(values.username, values.email, values.timezone || 'UTC', values.password, values.mnemonic, values.displayName);
14
12
  if ('error' in result) {