namirasoft-account-react 1.4.19 → 1.4.21

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.
Files changed (76) hide show
  1. package/.env.template +10 -10
  2. package/config-overrides.js +72 -72
  3. package/dist/IEntityInfo.d.ts +11 -11
  4. package/dist/Messages.js.map +1 -1
  5. package/dist/NSARouterMaker.d.ts +0 -1
  6. package/dist/NSARouterMaker.js.map +1 -1
  7. package/dist/Router.d.ts +0 -1
  8. package/dist/components/NSAAccessListDialog.js.map +1 -1
  9. package/dist/components/NSAAccessListDialog.module.css +87 -0
  10. package/dist/components/NSABoxOTP.js.map +1 -1
  11. package/dist/components/NSABoxOTP.module.css +11 -0
  12. package/dist/components/NSAMessageListDialog.js.map +1 -1
  13. package/dist/components/NSAMessageListDialog.module.css +98 -0
  14. package/dist/components/NSAProductListDialog.js.map +1 -1
  15. package/dist/components/NSAProductListDialog.module.css +45 -0
  16. package/dist/components/NSAWorkspaceListDialog.js.map +1 -1
  17. package/dist/components/NSAWorkspaceListDialog.module.css +43 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/layouts/Actions.d.ts +2 -1
  20. package/dist/layouts/Actions.js +38 -17
  21. package/dist/layouts/Actions.js.map +1 -1
  22. package/dist/layouts/NSALayout.d.ts +2 -1
  23. package/dist/layouts/NSALayout.js +58 -37
  24. package/dist/layouts/NSALayout.js.map +1 -1
  25. package/dist/layouts/NSASectionEdit.d.ts +0 -1
  26. package/dist/layouts/NSASectionEdit.js +12 -8
  27. package/dist/layouts/NSASectionEdit.js.map +1 -1
  28. package/dist/layouts/NSASectionList.js +6 -4
  29. package/dist/layouts/NSASectionList.js.map +1 -1
  30. package/dist/layouts/NSASectionTabs.d.ts +0 -1
  31. package/dist/layouts/NSASectionTabs.js +4 -7
  32. package/dist/layouts/NSASectionTabs.js.map +1 -1
  33. package/dist/layouts/NSASectionView.js +4 -3
  34. package/dist/layouts/NSASectionView.js.map +1 -1
  35. package/dist/pages/NSAHomePage.module.css +23 -0
  36. package/dist/pages/NSALoginPage.module.css +20 -0
  37. package/dist/pages/NSAVerificationPage.module.css +23 -0
  38. package/package.json +70 -70
  39. package/public/index.html +21 -21
  40. package/src/App.css +31 -31
  41. package/src/App.tsx +18 -18
  42. package/src/IEntityInfo.ts +31 -31
  43. package/src/INSARouterMaker.ts +7 -7
  44. package/src/INSARouterProps.ts +17 -17
  45. package/src/INSARouterState.ts +5 -5
  46. package/src/Info.ts +20 -20
  47. package/src/Message.ts +6 -6
  48. package/src/Messages.ts +33 -33
  49. package/src/NSARouterMaker.tsx +142 -142
  50. package/src/Router.tsx +39 -39
  51. package/src/components/NSAAccessListDialog.module.css +86 -86
  52. package/src/components/NSAAccessListDialog.tsx +160 -160
  53. package/src/components/NSABoxOTP.module.css +10 -10
  54. package/src/components/NSABoxOTP.tsx +63 -63
  55. package/src/components/NSAMessageListDialog.module.css +97 -97
  56. package/src/components/NSAMessageListDialog.tsx +116 -116
  57. package/src/components/NSAProductListDialog.module.css +44 -44
  58. package/src/components/NSAProductListDialog.tsx +100 -100
  59. package/src/components/NSAWorkspaceListDialog.module.css +42 -42
  60. package/src/components/NSAWorkspaceListDialog.tsx +73 -73
  61. package/src/index.tsx +24 -24
  62. package/src/layouts/Actions.ts +147 -119
  63. package/src/layouts/Menus.ts +15 -15
  64. package/src/layouts/NSALayout.tsx +417 -387
  65. package/src/layouts/NSASectionEdit.tsx +144 -140
  66. package/src/layouts/NSASectionList.tsx +161 -158
  67. package/src/layouts/NSASectionTabs.tsx +152 -156
  68. package/src/layouts/NSASectionView.tsx +61 -60
  69. package/src/main.ts +19 -19
  70. package/src/pages/NSAHomePage.module.css +22 -22
  71. package/src/pages/NSAHomePage.tsx +27 -27
  72. package/src/pages/NSALoginPage.module.css +19 -19
  73. package/src/pages/NSALoginPage.tsx +65 -65
  74. package/src/pages/NSAVerificationPage.module.css +22 -22
  75. package/src/pages/NSAVerificationPage.tsx +59 -59
  76. package/tsconfig.json +43 -43
@@ -1,143 +1,143 @@
1
- import queryString, { ParsedQuery } from 'query-string';
2
- import rrd from 'react-router-dom';
3
- import axios from "axios";
4
- import { EnvService, IStorageCookie, ObjectService, ParsedNameValue, URLOperation } from "namirasoft-core";
5
- import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
6
- import { INSRouterProps, NSRouterMaker } from 'namirasoft-site-react';
7
- import { INSARouterProps } from "./INSARouterProps";
8
- import { INSARouterMaker } from "./INSARouterMaker";
9
- import { INSARouterState } from "./INSARouterState";
10
-
11
- export class NSARouterMaker
12
- {
13
- private ns_router_maker_props!: INSRouterProps;
14
- private state: INSARouterState | undefined;
15
- private setState: React.Dispatch<React.SetStateAction<INSARouterState | undefined>>;
16
- private location: rrd.Location;
17
- private navigate: rrd.NavigateFunction;
18
- private component: INSARouterMaker;
19
- constructor(state: INSARouterState | undefined, setState: React.Dispatch<React.SetStateAction<INSARouterState | undefined>>,
20
- location: rrd.Location, navigate: rrd.NavigateFunction,
21
- component: INSARouterMaker)
22
- {
23
- this.state = state;
24
- this.setState = setState;
25
- this.location = location;
26
- this.navigate = navigate;
27
- this.component = component;
28
- this.init = this.init.bind(this);
29
- this.getQueryStrings = this.getQueryStrings.bind(this);
30
- this.getQuery = this.getQuery.bind(this);
31
- this.getLink = this.getLink.bind(this);
32
- this.redirect = this.redirect.bind(this);
33
- this.onComponentDidMount = this.onComponentDidMount.bind(this);
34
- this.onRender = this.onRender.bind(this);
35
- }
36
- private init(): { props: INSARouterProps, inited: boolean }
37
- {
38
- let qToken: string = this.getQuery("token");
39
- let Cookies = process.env.REACT_APP_ACCOUNT_TOKEN;
40
- let storage = new IStorageCookie({ domain: ".namirasoft.com", path: "/" }, Cookies);
41
- let token_manager = new TokenManager(storage, () => this.setState({}));
42
- if (qToken)
43
- token_manager.setValue(qToken, true);
44
-
45
-
46
- let REACT_APP_BASE_URL_ACCOUNT = new EnvService("REACT_APP_BASE_URL_ACCOUNT", true).getString();
47
- let REACT_APP_BASE_URL_ACCOUNT_CONSOLE = new EnvService("REACT_APP_BASE_URL_ACCOUNT_CONSOLE", true).getString();
48
- let server = new NamirasoftAccountServer(REACT_APP_BASE_URL_ACCOUNT, token_manager, (error: Error) =>
49
- {
50
- if (axios.isAxiosError(error))
51
- if (error.response)
52
- if (error.response?.status === 401)
53
- {
54
- token_manager.del();
55
- window.location.href = REACT_APP_BASE_URL_ACCOUNT_CONSOLE;
56
- return;
57
- }
58
- this.ns_router_maker_props.notifier.onError(error);
59
- });
60
- let props: INSARouterProps = {
61
- account: {
62
- token_manager,
63
- server,
64
- },
65
- url: {
66
- getLink: this.getLink,
67
- redirect: this.redirect,
68
- getQueryStrings: this.getQueryStrings,
69
- getQuery: this.getQuery,
70
- },
71
- ...this.ns_router_maker_props
72
- };
73
- let inited = true;
74
- if (qToken)
75
- inited = this.state?.inited ?? false;
76
- return { props, inited };
77
- }
78
- getQueryStrings(): ParsedQuery
79
- {
80
- return queryString.parse(this.location.search);
81
- }
82
- getQuery(name: string): string
83
- {
84
- let query = this.getQueryStrings();
85
- let item = query[name];
86
- return new ObjectService(item).getString();
87
- }
88
- getLink(sub: string, customQuery: { [name: string]: ParsedNameValue })
89
- {
90
- if (!customQuery)
91
- customQuery = {};
92
- return URLOperation.getLink("", sub, customQuery);
93
- }
94
- redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void
95
- {
96
- let ans = this.getLink(sub, customQuery);
97
- this.navigate(ans);
98
- }
99
- onComponentDidMount(): void
100
- {
101
- let { inited, props } = this.init();
102
- this.setState({ notifications: [], inited });
103
- let token = this.getQuery("token");
104
- if (token)
105
- {
106
- if (!props.account.token_manager.getUserData(u => u.id, ""))
107
- {
108
- props.account.server.session.Current()
109
- .then(response =>
110
- {
111
- props.account.token_manager.set(response, false);
112
- this.setState({ inited: true });
113
- })
114
- .catch(() =>
115
- {
116
- this.setState({ inited: true });
117
- });
118
- }
119
- }
120
- }
121
- onRender(): React.JSX.Element
122
- {
123
- let maker = new NSRouterMaker(this.state, this.setState, {
124
- onRender: (ns_router_maker_props: INSRouterProps) =>
125
- {
126
- this.ns_router_maker_props = ns_router_maker_props;
127
- let { inited, props } = this.init();
128
- if (!inited)
129
- return <></>;
130
- let banned = false;
131
- if (props.account.token_manager.exists())
132
- {
133
- banned = props.account.token_manager.getUserData(user => user.banned, false);
134
- if (!banned)
135
- return this.component.onRenderOnLogin(props);
136
- }
137
- return this.component.onRenderOnLogout(props, banned);
138
- }
139
- });
140
-
141
- return maker.onRender();
142
- }
1
+ import queryString, { ParsedQuery } from 'query-string';
2
+ import rrd from 'react-router-dom';
3
+ import axios from "axios";
4
+ import { EnvService, IStorageCookie, ObjectService, ParsedNameValue, URLOperation } from "namirasoft-core";
5
+ import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
6
+ import { INSRouterProps, NSRouterMaker } from 'namirasoft-site-react';
7
+ import { INSARouterProps } from "./INSARouterProps";
8
+ import { INSARouterMaker } from "./INSARouterMaker";
9
+ import { INSARouterState } from "./INSARouterState";
10
+
11
+ export class NSARouterMaker
12
+ {
13
+ private ns_router_maker_props!: INSRouterProps;
14
+ private state: INSARouterState | undefined;
15
+ private setState: React.Dispatch<React.SetStateAction<INSARouterState | undefined>>;
16
+ private location: rrd.Location;
17
+ private navigate: rrd.NavigateFunction;
18
+ private component: INSARouterMaker;
19
+ constructor(state: INSARouterState | undefined, setState: React.Dispatch<React.SetStateAction<INSARouterState | undefined>>,
20
+ location: rrd.Location, navigate: rrd.NavigateFunction,
21
+ component: INSARouterMaker)
22
+ {
23
+ this.state = state;
24
+ this.setState = setState;
25
+ this.location = location;
26
+ this.navigate = navigate;
27
+ this.component = component;
28
+ this.init = this.init.bind(this);
29
+ this.getQueryStrings = this.getQueryStrings.bind(this);
30
+ this.getQuery = this.getQuery.bind(this);
31
+ this.getLink = this.getLink.bind(this);
32
+ this.redirect = this.redirect.bind(this);
33
+ this.onComponentDidMount = this.onComponentDidMount.bind(this);
34
+ this.onRender = this.onRender.bind(this);
35
+ }
36
+ private init(): { props: INSARouterProps, inited: boolean }
37
+ {
38
+ let qToken: string = this.getQuery("token");
39
+ let Cookies = process.env.REACT_APP_ACCOUNT_TOKEN;
40
+ let storage = new IStorageCookie({ domain: ".namirasoft.com", path: "/" }, Cookies);
41
+ let token_manager = new TokenManager(storage, () => this.setState({}));
42
+ if (qToken)
43
+ token_manager.setValue(qToken, true);
44
+
45
+
46
+ let REACT_APP_BASE_URL_ACCOUNT = new EnvService("REACT_APP_BASE_URL_ACCOUNT", true).getString();
47
+ let REACT_APP_BASE_URL_ACCOUNT_CONSOLE = new EnvService("REACT_APP_BASE_URL_ACCOUNT_CONSOLE", true).getString();
48
+ let server = new NamirasoftAccountServer(REACT_APP_BASE_URL_ACCOUNT, token_manager, (error: Error) =>
49
+ {
50
+ if (axios.isAxiosError(error))
51
+ if (error.response)
52
+ if (error.response?.status === 401)
53
+ {
54
+ token_manager.del();
55
+ window.location.href = REACT_APP_BASE_URL_ACCOUNT_CONSOLE;
56
+ return;
57
+ }
58
+ this.ns_router_maker_props.notifier.onError(error);
59
+ });
60
+ let props: INSARouterProps = {
61
+ account: {
62
+ token_manager,
63
+ server,
64
+ },
65
+ url: {
66
+ getLink: this.getLink,
67
+ redirect: this.redirect,
68
+ getQueryStrings: this.getQueryStrings,
69
+ getQuery: this.getQuery,
70
+ },
71
+ ...this.ns_router_maker_props
72
+ };
73
+ let inited = true;
74
+ if (qToken)
75
+ inited = this.state?.inited ?? false;
76
+ return { props, inited };
77
+ }
78
+ getQueryStrings(): ParsedQuery
79
+ {
80
+ return queryString.parse(this.location.search);
81
+ }
82
+ getQuery(name: string): string
83
+ {
84
+ let query = this.getQueryStrings();
85
+ let item = query[name];
86
+ return new ObjectService(item).getString();
87
+ }
88
+ getLink(sub: string, customQuery: { [name: string]: ParsedNameValue })
89
+ {
90
+ if (!customQuery)
91
+ customQuery = {};
92
+ return URLOperation.getLink("", sub, customQuery);
93
+ }
94
+ redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void
95
+ {
96
+ let ans = this.getLink(sub, customQuery);
97
+ this.navigate(ans);
98
+ }
99
+ onComponentDidMount(): void
100
+ {
101
+ let { inited, props } = this.init();
102
+ this.setState({ notifications: [], inited });
103
+ let token = this.getQuery("token");
104
+ if (token)
105
+ {
106
+ if (!props.account.token_manager.getUserData(u => u.id, ""))
107
+ {
108
+ props.account.server.session.Current()
109
+ .then(response =>
110
+ {
111
+ props.account.token_manager.set(response, false);
112
+ this.setState({ inited: true });
113
+ })
114
+ .catch(() =>
115
+ {
116
+ this.setState({ inited: true });
117
+ });
118
+ }
119
+ }
120
+ }
121
+ onRender(): React.JSX.Element
122
+ {
123
+ let maker = new NSRouterMaker(this.state, this.setState, {
124
+ onRender: (ns_router_maker_props: INSRouterProps) =>
125
+ {
126
+ this.ns_router_maker_props = ns_router_maker_props;
127
+ let { inited, props } = this.init();
128
+ if (!inited)
129
+ return <></>;
130
+ let banned = false;
131
+ if (props.account.token_manager.exists())
132
+ {
133
+ banned = props.account.token_manager.getUserData(user => user.banned, false);
134
+ if (!banned)
135
+ return this.component.onRenderOnLogin(props);
136
+ }
137
+ return this.component.onRenderOnLogout(props, banned);
138
+ }
139
+ });
140
+
141
+ return maker.onRender();
142
+ }
143
143
  };
package/src/Router.tsx CHANGED
@@ -1,40 +1,40 @@
1
- import { NSARouterMaker } from './NSARouterMaker';
2
- import { INSARouterState } from './INSARouterState';
3
- import { INSARouterProps } from './INSARouterProps';
4
- import { useEffect, useState } from 'react';
5
- import { Routes, Route, useLocation, useNavigate } from 'react-router-dom';
6
- import { NSNotFoundPage } from 'namirasoft-site-react';
7
- import { App } from './App';
8
-
9
-
10
- export default function Router()
11
- {
12
- let [state, setState] = useState<INSARouterState>();
13
- let location = useLocation();
14
- let navigate = useNavigate();
15
- const maker = new NSARouterMaker(state, setState, location, navigate, {
16
- onRenderOnLogin: (props: INSARouterProps) =>
17
- {
18
- return (
19
- <>
20
- <Routes>
21
- <Route path="*" element={<App {...props}></App>} />
22
- </Routes>
23
- </>
24
- );
25
- },
26
- onRenderOnLogout: (_: INSARouterProps, __: boolean) =>
27
- {
28
- return (
29
- <Routes>
30
- <Route path="*" element={<NSNotFoundPage></NSNotFoundPage>} />
31
- </Routes>
32
- );
33
- }
34
- });
35
-
36
- // eslint-disable-next-line react-hooks/exhaustive-deps
37
- useEffect(maker.onComponentDidMount, []);
38
-
39
- return maker.onRender();
1
+ import { NSARouterMaker } from './NSARouterMaker';
2
+ import { INSARouterState } from './INSARouterState';
3
+ import { INSARouterProps } from './INSARouterProps';
4
+ import { useEffect, useState } from 'react';
5
+ import { Routes, Route, useLocation, useNavigate } from 'react-router-dom';
6
+ import { NSNotFoundPage } from 'namirasoft-site-react';
7
+ import { App } from './App';
8
+
9
+
10
+ export default function Router()
11
+ {
12
+ let [state, setState] = useState<INSARouterState>();
13
+ let location = useLocation();
14
+ let navigate = useNavigate();
15
+ const maker = new NSARouterMaker(state, setState, location, navigate, {
16
+ onRenderOnLogin: (props: INSARouterProps) =>
17
+ {
18
+ return (
19
+ <>
20
+ <Routes>
21
+ <Route path="*" element={<App {...props}></App>} />
22
+ </Routes>
23
+ </>
24
+ );
25
+ },
26
+ onRenderOnLogout: (_: INSARouterProps, __: boolean) =>
27
+ {
28
+ return (
29
+ <Routes>
30
+ <Route path="*" element={<NSNotFoundPage></NSNotFoundPage>} />
31
+ </Routes>
32
+ );
33
+ }
34
+ });
35
+
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ useEffect(maker.onComponentDidMount, []);
38
+
39
+ return maker.onRender();
40
40
  }
@@ -1,87 +1,87 @@
1
- .ns_access_container {
2
- width: 300px;
3
- }
4
-
5
- .ns_access_container h6 {
6
- color: rgba(20, 27, 92, 1);
7
- text-align: left;
8
- font-weight: 300;
9
- font-size: 16px;
10
- cursor: default;
11
- }
12
-
13
- .ns_access_container h2 {
14
- color: rgba(3, 119, 255, 1);
15
- text-align: center;
16
- font-weight: 600;
17
- font-size: 16px;
18
- cursor: default;
19
- margin: 0;
20
- }
21
-
22
- .ns_access_container h4 {
23
- color: rgba(20, 27, 92, 1);
24
- font-weight: 600;
25
- font-size: 16px;
26
- text-align: left;
27
- cursor: default;
28
- }
29
-
30
- .ns_access_content h6 {
31
- text-align: center;
32
- padding: 0;
33
- margin: 0;
34
- }
35
-
36
- .ns_access_account_container {
37
- display: flex;
38
- cursor: pointer;
39
- border: none;
40
- background-color: rgba(244, 246, 255, 1);
41
- border-radius: 8px;
42
- align-items: center;
43
- gap: 10px;
44
- width: 326px;
45
- max-width: 100%;
46
- }
47
-
48
- .ns_access_account_container:hover {
49
- background-color: rgba(178, 187, 217, 1);
50
- transition: all 0.3s ease-in-out;
51
- }
52
-
53
-
54
- .ns_access_account_container img {
55
- cursor: pointer;
56
- }
57
-
58
- .ns_access_account_info {
59
- display: flex;
60
- flex-direction: row;
61
- justify-content: left;
62
- align-items: flex-start;
63
- padding: 8px;
64
- }
65
-
66
- .nsa_close_icon {
67
- cursor: pointer;
68
- }
69
-
70
- .nsa_toast_background {
71
- width: 100vw;
72
- height: 100vh;
73
- background-color: #00000059;
74
- position: fixed;
75
- top: 0;
76
- left: 0;
77
- display: flex;
78
- justify-content: center;
79
- align-items: center;
80
- cursor: default;
81
- }
82
-
83
- .ns_line {
84
- border-left: none !important;
85
- border-right: none !important;
86
- width: 100% !important;
1
+ .ns_access_container {
2
+ width: 300px;
3
+ }
4
+
5
+ .ns_access_container h6 {
6
+ color: rgba(20, 27, 92, 1);
7
+ text-align: left;
8
+ font-weight: 300;
9
+ font-size: 16px;
10
+ cursor: default;
11
+ }
12
+
13
+ .ns_access_container h2 {
14
+ color: rgba(3, 119, 255, 1);
15
+ text-align: center;
16
+ font-weight: 600;
17
+ font-size: 16px;
18
+ cursor: default;
19
+ margin: 0;
20
+ }
21
+
22
+ .ns_access_container h4 {
23
+ color: rgba(20, 27, 92, 1);
24
+ font-weight: 600;
25
+ font-size: 16px;
26
+ text-align: left;
27
+ cursor: default;
28
+ }
29
+
30
+ .ns_access_content h6 {
31
+ text-align: center;
32
+ padding: 0;
33
+ margin: 0;
34
+ }
35
+
36
+ .ns_access_account_container {
37
+ display: flex;
38
+ cursor: pointer;
39
+ border: none;
40
+ background-color: rgba(244, 246, 255, 1);
41
+ border-radius: 8px;
42
+ align-items: center;
43
+ gap: 10px;
44
+ width: 326px;
45
+ max-width: 100%;
46
+ }
47
+
48
+ .ns_access_account_container:hover {
49
+ background-color: rgba(178, 187, 217, 1);
50
+ transition: all 0.3s ease-in-out;
51
+ }
52
+
53
+
54
+ .ns_access_account_container img {
55
+ cursor: pointer;
56
+ }
57
+
58
+ .ns_access_account_info {
59
+ display: flex;
60
+ flex-direction: row;
61
+ justify-content: left;
62
+ align-items: flex-start;
63
+ padding: 8px;
64
+ }
65
+
66
+ .nsa_close_icon {
67
+ cursor: pointer;
68
+ }
69
+
70
+ .nsa_toast_background {
71
+ width: 100vw;
72
+ height: 100vh;
73
+ background-color: #00000059;
74
+ position: fixed;
75
+ top: 0;
76
+ left: 0;
77
+ display: flex;
78
+ justify-content: center;
79
+ align-items: center;
80
+ cursor: default;
81
+ }
82
+
83
+ .ns_line {
84
+ border-left: none !important;
85
+ border-right: none !important;
86
+ width: 100% !important;
87
87
  }