@digitaldefiance/express-suite-react-components 2.1.49 → 2.1.51
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/README.md +8 -0
- package/package.json +2 -2
- package/src/auth/PrivateRoute.d.ts +2 -4
- package/src/auth/PrivateRoute.d.ts.map +1 -1
- package/src/auth/PrivateRoute.js +10 -3
- package/src/auth/UnAuthRoute.d.ts +1 -3
- package/src/auth/UnAuthRoute.d.ts.map +1 -1
- package/src/auth/UnAuthRoute.js +9 -3
- package/src/auth/index.d.ts +2 -2
- package/src/auth/index.d.ts.map +1 -1
- package/src/auth/index.js +5 -2
- package/src/components/ApiAccess.d.ts +1 -0
- package/src/components/ApiAccess.d.ts.map +1 -1
- package/src/components/ApiAccess.js +3 -2
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.51",
|
|
4
4
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@digitaldefiance/i18n-lib": "2.1.40",
|
|
30
|
-
"@digitaldefiance/suite-core-lib": "2.1.
|
|
30
|
+
"@digitaldefiance/suite-core-lib": "2.1.50",
|
|
31
31
|
"@emotion/react": "^11.14.0",
|
|
32
32
|
"@emotion/styled": "^11.14.0",
|
|
33
33
|
"@mui/icons-material": "^7.0.2",
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
interface PrivateRouteProps {
|
|
3
3
|
children: ReactNode;
|
|
4
|
-
isAuthenticated: boolean;
|
|
5
|
-
isCheckingAuth: boolean;
|
|
6
4
|
redirectTo?: string;
|
|
7
|
-
loadingComponent?: ReactNode;
|
|
8
5
|
}
|
|
9
6
|
export declare const PrivateRoute: FC<PrivateRouteProps>;
|
|
7
|
+
export default PrivateRoute;
|
|
10
8
|
//# sourceMappingURL=PrivateRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivateRoute.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/auth/PrivateRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"PrivateRoute.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/auth/PrivateRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAMlD,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAc9C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/src/auth/PrivateRoute.js
CHANGED
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PrivateRoute = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
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 PrivateRoute = ({ children, redirectTo }) => {
|
|
11
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
12
|
+
const { isAuthenticated, isCheckingAuth } = (0, react_1.useContext)(AuthProvider_1.AuthContext);
|
|
7
13
|
const location = (0, react_router_dom_1.useLocation)();
|
|
8
14
|
if (isCheckingAuth) {
|
|
9
|
-
return (0, jsx_runtime_1.
|
|
15
|
+
return (0, jsx_runtime_1.jsxs)("div", { children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_CheckingAuthentication), "..."] });
|
|
10
16
|
}
|
|
11
17
|
if (!isAuthenticated) {
|
|
12
|
-
return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo, state: { from: location }, replace: true });
|
|
18
|
+
return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo ?? "/login", state: { from: location }, replace: true });
|
|
13
19
|
}
|
|
14
20
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
15
21
|
};
|
|
16
22
|
exports.PrivateRoute = PrivateRoute;
|
|
23
|
+
exports.default = exports.PrivateRoute;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
export interface UnAuthRouteProps {
|
|
3
3
|
children: ReactNode;
|
|
4
|
-
isAuthenticated: boolean;
|
|
5
|
-
isCheckingAuth: boolean;
|
|
6
4
|
redirectTo?: string;
|
|
7
|
-
loadingComponent?: ReactNode;
|
|
8
5
|
}
|
|
9
6
|
export declare const UnAuthRoute: FC<UnAuthRouteProps>;
|
|
7
|
+
export default UnAuthRoute;
|
|
10
8
|
//# sourceMappingURL=UnAuthRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnAuthRoute.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/auth/UnAuthRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"UnAuthRoute.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/auth/UnAuthRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAKlD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAiB5C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/src/auth/UnAuthRoute.js
CHANGED
|
@@ -2,15 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UnAuthRoute = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
7
|
+
const contexts_1 = require("../contexts");
|
|
8
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
9
|
+
const UnAuthRoute = ({ children, redirectTo = '/dashboard', }) => {
|
|
10
|
+
const { isAuthenticated, isCheckingAuth } = (0, react_1.useContext)(contexts_1.AuthContext);
|
|
11
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
7
12
|
const location = (0, react_router_dom_1.useLocation)();
|
|
8
13
|
if (isCheckingAuth) {
|
|
9
|
-
return (0, jsx_runtime_1.
|
|
14
|
+
return (0, jsx_runtime_1.jsxs)("div", { children: [tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Common_CheckingAuthentication), "..."] });
|
|
10
15
|
}
|
|
11
16
|
if (isAuthenticated) {
|
|
12
|
-
return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo, state: { from: location }, replace: true });
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(react_router_dom_1.Navigate, { to: redirectTo ?? "/dashboard", state: { from: location }, replace: true });
|
|
13
18
|
}
|
|
14
19
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
15
20
|
};
|
|
16
21
|
exports.UnAuthRoute = UnAuthRoute;
|
|
22
|
+
exports.default = exports.UnAuthRoute;
|
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,
|
|
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"}
|
package/src/auth/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnAuthRoute = exports.PrivateRoute = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
var PrivateRoute_1 = require("./PrivateRoute");
|
|
6
|
+
Object.defineProperty(exports, "PrivateRoute", { enumerable: true, get: function () { return tslib_1.__importDefault(PrivateRoute_1).default; } });
|
|
7
|
+
var UnAuthRoute_1 = require("./UnAuthRoute");
|
|
8
|
+
Object.defineProperty(exports, "UnAuthRoute", { enumerable: true, get: function () { return tslib_1.__importDefault(UnAuthRoute_1).default; } });
|
|
6
9
|
tslib_1.__exportStar(require("./Private"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiAccess.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ApiAccess.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AA4BrC,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"ApiAccess.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/ApiAccess.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AA4BrC,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA8ExC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -29,8 +29,9 @@ const ApiAccessTitle = (0, material_1.styled)(material_1.Typography)(({ theme })
|
|
|
29
29
|
marginBottom: theme.spacing(3),
|
|
30
30
|
color: theme.palette.primary.main,
|
|
31
31
|
}));
|
|
32
|
-
const ApiAccess = ({ labels = {}, }) => {
|
|
33
|
-
const { token } = (0, contexts_1.useAuth)();
|
|
32
|
+
const ApiAccess = ({ token: tokenProp, labels = {}, }) => {
|
|
33
|
+
const { token: authToken } = (0, contexts_1.useAuth)();
|
|
34
|
+
const token = tokenProp !== undefined ? tokenProp : authToken;
|
|
34
35
|
const { tComponent } = (0, contexts_1.useI18n)();
|
|
35
36
|
const [dialogOpen, setDialogOpen] = (0, react_1.useState)(false);
|
|
36
37
|
const [isError, setIsError] = (0, react_1.useState)(false);
|