@digitaldefiance/express-suite-react-components 2.1.49 → 2.1.50
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 +4 -0
- package/package.json +2 -2
- package/src/auth/PrivateRoute.d.ts +3 -5
- package/src/auth/PrivateRoute.d.ts.map +1 -1
- package/src/auth/PrivateRoute.js +10 -5
- package/src/auth/UnAuthRoute.d.ts +0 -3
- package/src/auth/UnAuthRoute.d.ts.map +1 -1
- package/src/auth/UnAuthRoute.js +8 -3
- 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.50",
|
|
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
|
+
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,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAcvC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/src/auth/PrivateRoute.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PrivateRoute = void 0;
|
|
4
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
6
|
+
const AuthProvider_1 = require("../contexts/AuthProvider");
|
|
7
|
+
const contexts_1 = require("../contexts");
|
|
8
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
9
|
+
const PrivateRoute = ({ children, redirectTo }) => {
|
|
10
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
11
|
+
const { isAuthenticated, isCheckingAuth } = (0, react_1.useContext)(AuthProvider_1.AuthContext);
|
|
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 ?? "/login", state: { from: location }, replace: true });
|
|
13
18
|
}
|
|
14
19
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
15
20
|
};
|
|
16
|
-
exports.
|
|
21
|
+
exports.default = PrivateRoute;
|
|
@@ -1,10 +1,7 @@
|
|
|
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>;
|
|
10
7
|
//# 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"}
|
package/src/auth/UnAuthRoute.js
CHANGED
|
@@ -2,14 +2,19 @@
|
|
|
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
|
};
|
|
@@ -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);
|