namirasoft-account-react 1.5.21 → 1.5.22

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 (141) hide show
  1. package/.env.template +15 -15
  2. package/SKILL.md +514 -514
  3. package/config-overrides.js +72 -72
  4. package/dist/App.d.ts +1 -1
  5. package/dist/Router.d.ts +1 -1
  6. package/dist/UseParams.d.ts +1 -1
  7. package/dist/components/NSAAccessListDialog.d.ts +2 -2
  8. package/dist/components/NSAAccessListDialog.module.css +71 -71
  9. package/dist/components/NSABoxSecret.d.ts +1 -1
  10. package/dist/components/NSABoxSecret.module.css +23 -23
  11. package/dist/components/NSAMasterMenu.d.ts +1 -1
  12. package/dist/components/NSAMasterMenu.module.css +250 -250
  13. package/dist/components/NSAMasterMenuItem.d.ts +1 -1
  14. package/dist/components/NSAMessageListDialog.d.ts +1 -1
  15. package/dist/components/NSAMessageListDialog.module.css +99 -99
  16. package/dist/components/NSANavigationGuard.d.ts +1 -1
  17. package/dist/components/NSAProductListDialog.d.ts +1 -1
  18. package/dist/components/NSAProductListDialog.module.css +44 -44
  19. package/dist/components/NSATaskBar.d.ts +1 -1
  20. package/dist/components/NSATaskBar.module.css +57 -57
  21. package/dist/components/NSAUserDialog.d.ts +1 -1
  22. package/dist/components/NSAUserDialog.module.css +67 -67
  23. package/dist/components/NSAWorkspaceListDialog.d.ts +1 -1
  24. package/dist/components/NSAWorkspaceListDialog.module.css +41 -41
  25. package/dist/components/NSFBoxCategoryScope.d.ts +1 -1
  26. package/dist/components/NSFBoxField.d.ts +1 -1
  27. package/dist/components/NSFBoxSlot.d.ts +1 -1
  28. package/dist/components/NSFBoxWrapper.d.ts +1 -1
  29. package/dist/components/NSLabelSecret.d.ts +1 -1
  30. package/dist/components/quickfilter/NSAFilterBoxEnum.module.css +44 -44
  31. package/dist/components/quickfilter/NSAQuickFilterBar.d.ts +1 -1
  32. package/dist/components/quickfilter/NSAQuickFilterBar.module.css +19 -19
  33. package/dist/components/quickfilter/NSAQuickFilterDialog.d.ts +1 -1
  34. package/dist/components/quickfilter/NSAQuickFilterDialog.module.css +74 -74
  35. package/dist/layouts/NSALayout.d.ts +1 -1
  36. package/dist/layouts/NSASectionEdit.d.ts +1 -1
  37. package/dist/layouts/NSASectionEditTabPage.d.ts +1 -1
  38. package/dist/layouts/NSASectionEditTabPage.module.css +4 -4
  39. package/dist/layouts/NSASectionList.d.ts +1 -1
  40. package/dist/layouts/NSASectionList.module.css +31 -31
  41. package/dist/layouts/NSASectionView.d.ts +1 -1
  42. package/dist/layouts/NSASectionViewTabMore.d.ts +1 -1
  43. package/dist/layouts/NSASectionViewTabPage.d.ts +1 -1
  44. package/dist/layouts/NSASectionViewTabPage.js +1 -0
  45. package/dist/layouts/NSASectionViewTabPage.js.map +1 -1
  46. package/dist/layouts/NSASectionViewTabPage.module.css +47 -47
  47. package/dist/pages/NSAConsentPage.module.css +26 -26
  48. package/dist/pages/NSAEmailVerificationPage.d.ts +1 -1
  49. package/dist/pages/NSAHomePage.d.ts +1 -1
  50. package/dist/pages/NSAHomePage.module.css +41 -41
  51. package/dist/pages/NSALoginPage.d.ts +1 -1
  52. package/dist/pages/NSALoginPage.module.css +26 -26
  53. package/dist/pages/NSAPhoneVerificationPage.d.ts +1 -1
  54. package/dist/pages/NSAVerificationPage.d.ts +1 -1
  55. package/dist/pages/NSAVerificationPage.module.css +31 -31
  56. package/package.json +95 -95
  57. package/public/index.html +21 -21
  58. package/src/App.tsx +19 -19
  59. package/src/CTFRow.ts +7 -7
  60. package/src/FieldCacheService.tsx +84 -84
  61. package/src/IEntityInfo.ts +33 -33
  62. package/src/NSACacheService.ts +120 -120
  63. package/src/NSAFilterOperators.ts +92 -92
  64. package/src/NSARouterMaker.tsx +140 -140
  65. package/src/NSARouterMakerProps.ts +23 -23
  66. package/src/NSARouterMakerResult.ts +24 -24
  67. package/src/NSFRouterMaker.tsx +35 -35
  68. package/src/NSFRouterProps.ts +7 -7
  69. package/src/NSFRoutes.ts +30 -30
  70. package/src/Router.tsx +48 -48
  71. package/src/UseParams.tsx +17 -17
  72. package/src/components/NSAAccessListDialog.module.css +71 -71
  73. package/src/components/NSAAccessListDialog.tsx +178 -178
  74. package/src/components/NSABoxSecret.module.css +23 -23
  75. package/src/components/NSABoxSecret.tsx +264 -264
  76. package/src/components/NSAMasterMenu.module.css +250 -250
  77. package/src/components/NSAMasterMenu.tsx +169 -169
  78. package/src/components/NSAMasterMenuItem.tsx +250 -250
  79. package/src/components/NSAMessageListDialog.module.css +99 -99
  80. package/src/components/NSAMessageListDialog.tsx +142 -142
  81. package/src/components/NSANavigationGuard.tsx +79 -79
  82. package/src/components/NSAProductListDialog.module.css +44 -44
  83. package/src/components/NSAProductListDialog.tsx +88 -88
  84. package/src/components/NSATable.tsx +494 -494
  85. package/src/components/NSATaskBar.module.css +57 -57
  86. package/src/components/NSATaskBar.tsx +193 -193
  87. package/src/components/NSAUserDialog.module.css +67 -67
  88. package/src/components/NSAUserDialog.tsx +122 -122
  89. package/src/components/NSAWorkspaceListDialog.module.css +41 -41
  90. package/src/components/NSAWorkspaceListDialog.tsx +147 -147
  91. package/src/components/NSFBoxCategoryScope.tsx +52 -52
  92. package/src/components/NSFBoxField.tsx +37 -37
  93. package/src/components/NSFBoxSlot.tsx +71 -71
  94. package/src/components/NSFBoxWrapper.tsx +69 -69
  95. package/src/components/NSLabelSecret.tsx +37 -37
  96. package/src/components/quickfilter/NSAFilterBoxBase.tsx +89 -89
  97. package/src/components/quickfilter/NSAFilterBoxBoolean.tsx +66 -66
  98. package/src/components/quickfilter/NSAFilterBoxDate.tsx +110 -110
  99. package/src/components/quickfilter/NSAFilterBoxDateTime.tsx +110 -110
  100. package/src/components/quickfilter/NSAFilterBoxEnum.module.css +44 -44
  101. package/src/components/quickfilter/NSAFilterBoxEnum.tsx +79 -79
  102. package/src/components/quickfilter/NSAFilterBoxNumber.tsx +145 -145
  103. package/src/components/quickfilter/NSAFilterBoxString.tsx +83 -83
  104. package/src/components/quickfilter/NSAFilterBoxTime.tsx +106 -106
  105. package/src/components/quickfilter/NSAQuickFilterBar.module.css +19 -19
  106. package/src/components/quickfilter/NSAQuickFilterBar.tsx +142 -142
  107. package/src/components/quickfilter/NSAQuickFilterDialog.module.css +74 -74
  108. package/src/components/quickfilter/NSAQuickFilterDialog.tsx +260 -260
  109. package/src/css.d.ts +13 -13
  110. package/src/formatters/SecretFormatter.tsx +24 -24
  111. package/src/index.tsx +26 -26
  112. package/src/layouts/Actions.ts +146 -146
  113. package/src/layouts/CFTUtil.ts +18 -18
  114. package/src/layouts/NSALayout.tsx +744 -744
  115. package/src/layouts/NSALayout_Field.ts +125 -125
  116. package/src/layouts/NSASectionEdit.tsx +281 -281
  117. package/src/layouts/NSASectionEditTabPage.module.css +4 -4
  118. package/src/layouts/NSASectionEditTabPage.tsx +256 -256
  119. package/src/layouts/NSASectionList.module.css +31 -31
  120. package/src/layouts/NSASectionList.tsx +147 -147
  121. package/src/layouts/NSASectionView.tsx +98 -98
  122. package/src/layouts/NSASectionViewTabMore.tsx +78 -78
  123. package/src/layouts/NSASectionViewTabPage.module.css +47 -47
  124. package/src/layouts/NSASectionViewTabPage.tsx +400 -399
  125. package/src/main.ts +52 -52
  126. package/src/pages/NSAConsentPage.module.css +26 -26
  127. package/src/pages/NSAConsentPage.tsx +120 -120
  128. package/src/pages/NSAEmailVerificationPage.tsx +30 -30
  129. package/src/pages/NSAHomePage.module.css +41 -41
  130. package/src/pages/NSAHomePage.tsx +124 -124
  131. package/src/pages/NSALoginPage.module.css +26 -26
  132. package/src/pages/NSALoginPage.tsx +87 -87
  133. package/src/pages/NSAPhoneVerificationPage.tsx +94 -94
  134. package/src/pages/NSAVerificationPage.module.css +31 -31
  135. package/src/pages/NSAVerificationPage.tsx +185 -185
  136. package/src/pages/NSFCategoryEditPage.tsx +87 -87
  137. package/src/pages/NSFCategoryListPage.tsx +23 -23
  138. package/src/pages/NSFCategoryViewPage.tsx +23 -23
  139. package/src/pages/NSFEntities.ts +58 -58
  140. package/src/pages/PaymentRequired.tsx +80 -80
  141. package/tsconfig.json +43 -43
@@ -1,93 +1,93 @@
1
- import { FilterItemColumnType, FilterItemOperator } from "namirasoft-core";
2
- import { VariableType } from "namirasoft-schema";
3
-
4
- const all = FilterItemOperator.all as any;
5
-
6
- if (!all["between"])
7
- all["between"] = new FilterItemOperator(
8
- "Between", "><", 2,
9
- (type: FilterItemColumnType) => [FilterItemColumnType.Number, FilterItemColumnType.Date, FilterItemColumnType.DateTime, FilterItemColumnType.Time].includes(type)
10
- );
11
-
12
- if (!all["notequals"])
13
- all["notequals"] = new FilterItemOperator(
14
- "Not Equals", "!=", 1,
15
- (type: FilterItemColumnType) => type !== FilterItemColumnType.Unknown
16
- );
17
-
18
- if (!all["notcontains"])
19
- all["notcontains"] = new FilterItemOperator(
20
- "Not Contains", "!:", 1,
21
- (type: FilterItemColumnType) => type !== FilterItemColumnType.Unknown && type !== FilterItemColumnType.Boolean
22
- );
23
-
24
- export const NUMERIC_OPERATORS = ["equals", "notequals", "lessthan", "lessthanequal", "morethan", "morethanequal", "between", "empty", "exists"] as const;
25
- export const STRING_OPERATORS = ["contains", "equals", "startswith", "empty", "exists", "notequals", "notcontains"] as const;
26
- export const DATE_OPERATORS = ["equals", "lessthan", "lessthanequal", "morethan", "morethanequal", "between", "empty", "exists"] as const;
27
- export const ENUM_OPERATORS = ["equals", "empty", "exists"] as const;
28
-
29
- export type NumericOperatorKey = typeof NUMERIC_OPERATORS[number];
30
- export type StringOperatorKey = typeof STRING_OPERATORS[number];
31
- export type DateOperatorKey = typeof DATE_OPERATORS[number];
32
- export type EnumOperatorKey = typeof ENUM_OPERATORS[number];
33
-
34
- type OperatorKeyForType<T> =
35
- T extends boolean ? never :
36
- T extends number ? NumericOperatorKey :
37
- T extends Date ? DateOperatorKey :
38
- T extends string ? StringOperatorKey :
39
- keyof typeof FilterItemOperator.all;
40
-
41
- export type QuickFilterDef<EntityType> = NonNullable<{
42
- [K in keyof EntityType]:
43
- NonNullable<EntityType[K]> extends boolean
44
- ? { column: K; operator?: never }
45
- : { column: K; operator: OperatorKeyForType<NonNullable<EntityType[K]>> };
46
- }[keyof EntityType]>;
47
-
48
- export class NSAFilterOperators
49
- {
50
- private static readonly NUMERIC_TYPES = new Set<VariableType>([
51
- VariableType.TinyInt, VariableType.SmallInt, VariableType.MediumInt,
52
- VariableType.Integer, VariableType.BigInt, VariableType.Float,
53
- VariableType.Double, VariableType.Decimal, VariableType.Real, VariableType.Money,
54
- ]);
55
-
56
- private static readonly STRING_TYPES = new Set<VariableType>([
57
- VariableType.String, VariableType.Email, VariableType.Phone, VariableType.URL,
58
- VariableType.Color, VariableType.Font, VariableType.FilePath, VariableType.Version,
59
- VariableType.IPV4, VariableType.IPV6, VariableType.IPV4Range, VariableType.IPV6Range,
60
- ]);
61
-
62
- private static pick(keys: readonly string[]): FilterItemOperator[]
63
- {
64
- return keys.map(k => all[k]).filter(Boolean);
65
- }
66
-
67
- static getQuickFilterOperators(type: VariableType): FilterItemOperator[]
68
- {
69
- if (NSAFilterOperators.NUMERIC_TYPES.has(type))
70
- return NSAFilterOperators.pick(NUMERIC_OPERATORS);
71
-
72
- if (NSAFilterOperators.STRING_TYPES.has(type))
73
- return NSAFilterOperators.pick(STRING_OPERATORS);
74
-
75
- switch (type)
76
- {
77
- case VariableType.Date:
78
- case VariableType.DateTime:
79
- case VariableType.Time:
80
- return NSAFilterOperators.pick(DATE_OPERATORS);
81
- case VariableType.Enum:
82
- case VariableType.Entity:
83
- return NSAFilterOperators.pick(ENUM_OPERATORS);
84
- default:
85
- return [];
86
- }
87
- }
88
-
89
- static getOperatorKey(op: FilterItemOperator): string
90
- {
91
- return Object.keys(all).find(k => all[k] === op) ?? op.name.toLowerCase().replace(/\s+/g, "");
92
- }
1
+ import { FilterItemColumnType, FilterItemOperator } from "namirasoft-core";
2
+ import { VariableType } from "namirasoft-schema";
3
+
4
+ const all = FilterItemOperator.all as any;
5
+
6
+ if (!all["between"])
7
+ all["between"] = new FilterItemOperator(
8
+ "Between", "><", 2,
9
+ (type: FilterItemColumnType) => [FilterItemColumnType.Number, FilterItemColumnType.Date, FilterItemColumnType.DateTime, FilterItemColumnType.Time].includes(type)
10
+ );
11
+
12
+ if (!all["notequals"])
13
+ all["notequals"] = new FilterItemOperator(
14
+ "Not Equals", "!=", 1,
15
+ (type: FilterItemColumnType) => type !== FilterItemColumnType.Unknown
16
+ );
17
+
18
+ if (!all["notcontains"])
19
+ all["notcontains"] = new FilterItemOperator(
20
+ "Not Contains", "!:", 1,
21
+ (type: FilterItemColumnType) => type !== FilterItemColumnType.Unknown && type !== FilterItemColumnType.Boolean
22
+ );
23
+
24
+ export const NUMERIC_OPERATORS = ["equals", "notequals", "lessthan", "lessthanequal", "morethan", "morethanequal", "between", "empty", "exists"] as const;
25
+ export const STRING_OPERATORS = ["contains", "equals", "startswith", "empty", "exists", "notequals", "notcontains"] as const;
26
+ export const DATE_OPERATORS = ["equals", "lessthan", "lessthanequal", "morethan", "morethanequal", "between", "empty", "exists"] as const;
27
+ export const ENUM_OPERATORS = ["equals", "empty", "exists"] as const;
28
+
29
+ export type NumericOperatorKey = typeof NUMERIC_OPERATORS[number];
30
+ export type StringOperatorKey = typeof STRING_OPERATORS[number];
31
+ export type DateOperatorKey = typeof DATE_OPERATORS[number];
32
+ export type EnumOperatorKey = typeof ENUM_OPERATORS[number];
33
+
34
+ type OperatorKeyForType<T> =
35
+ T extends boolean ? never :
36
+ T extends number ? NumericOperatorKey :
37
+ T extends Date ? DateOperatorKey :
38
+ T extends string ? StringOperatorKey :
39
+ keyof typeof FilterItemOperator.all;
40
+
41
+ export type QuickFilterDef<EntityType> = NonNullable<{
42
+ [K in keyof EntityType]:
43
+ NonNullable<EntityType[K]> extends boolean
44
+ ? { column: K; operator?: never }
45
+ : { column: K; operator: OperatorKeyForType<NonNullable<EntityType[K]>> };
46
+ }[keyof EntityType]>;
47
+
48
+ export class NSAFilterOperators
49
+ {
50
+ private static readonly NUMERIC_TYPES = new Set<VariableType>([
51
+ VariableType.TinyInt, VariableType.SmallInt, VariableType.MediumInt,
52
+ VariableType.Integer, VariableType.BigInt, VariableType.Float,
53
+ VariableType.Double, VariableType.Decimal, VariableType.Real, VariableType.Money,
54
+ ]);
55
+
56
+ private static readonly STRING_TYPES = new Set<VariableType>([
57
+ VariableType.String, VariableType.Email, VariableType.Phone, VariableType.URL,
58
+ VariableType.Color, VariableType.Font, VariableType.FilePath, VariableType.Version,
59
+ VariableType.IPV4, VariableType.IPV6, VariableType.IPV4Range, VariableType.IPV6Range,
60
+ ]);
61
+
62
+ private static pick(keys: readonly string[]): FilterItemOperator[]
63
+ {
64
+ return keys.map(k => all[k]).filter(Boolean);
65
+ }
66
+
67
+ static getQuickFilterOperators(type: VariableType): FilterItemOperator[]
68
+ {
69
+ if (NSAFilterOperators.NUMERIC_TYPES.has(type))
70
+ return NSAFilterOperators.pick(NUMERIC_OPERATORS);
71
+
72
+ if (NSAFilterOperators.STRING_TYPES.has(type))
73
+ return NSAFilterOperators.pick(STRING_OPERATORS);
74
+
75
+ switch (type)
76
+ {
77
+ case VariableType.Date:
78
+ case VariableType.DateTime:
79
+ case VariableType.Time:
80
+ return NSAFilterOperators.pick(DATE_OPERATORS);
81
+ case VariableType.Enum:
82
+ case VariableType.Entity:
83
+ return NSAFilterOperators.pick(ENUM_OPERATORS);
84
+ default:
85
+ return [];
86
+ }
87
+ }
88
+
89
+ static getOperatorKey(op: FilterItemOperator): string
90
+ {
91
+ return Object.keys(all).find(k => all[k] === op) ?? op.name.toLowerCase().replace(/\s+/g, "");
92
+ }
93
93
  }
@@ -1,141 +1,141 @@
1
- import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
2
- import { EncodingOperation, EnvService, IStorageCookie, ObjectService, ParsedNameValue, URLOperation } from "namirasoft-core";
3
- import { KeyOperation, LinkOperation, NSRouterMaker, NSRouterMakerResult } from 'namirasoft-site-react';
4
- import queryString, { ParsedQuery } from 'query-string';
5
- import React, { cloneElement } from 'react';
6
- import { NSALayoutCustomProps } from "./main";
7
- import { NSARouterMakerProps } from "./NSARouterMakerProps";
8
- import { NSARouterMakerResult } from "./NSARouterMakerResult";
9
- import { NSAConsentPage } from './pages/NSAConsentPage';
10
- import { NSAEmailVerificationPage } from './pages/NSAEmailVerificationPage';
11
- import { NSAPhoneVerificationPage } from './pages/NSAPhoneVerificationPage';
12
-
13
- export class NSARouterMaker extends React.Component<NSARouterMakerProps>
14
- {
15
- constructor(props: NSARouterMakerProps)
16
- {
17
- super(props);
18
- LinkOperation.setNavigate(props.navigate);
19
- KeyOperation.start();
20
- this.getResult = this.getResult.bind(this);
21
- this.getQueryStrings = this.getQueryStrings.bind(this);
22
- this.getQuery = this.getQuery.bind(this);
23
- this.getLink = this.getLink.bind(this);
24
- this.redirect = this.redirect.bind(this);
25
- this.render = this.render.bind(this);
26
- }
27
- private getResult(ns_router_maker_props: NSRouterMakerResult): NSARouterMakerResult
28
- {
29
- let Cookies = process.env.REACT_APP_ACCOUNT_TOKEN;
30
- let storage = new IStorageCookie({ domain: ".namirasoft.com", path: "/" }, Cookies);
31
- let token_manager = new TokenManager(storage, () => { });
32
-
33
- let REACT_APP_BASE_URL_ACCOUNT = new EnvService("REACT_APP_BASE_URL_ACCOUNT", true).getString();
34
- let server = new NamirasoftAccountServer(REACT_APP_BASE_URL_ACCOUNT, token_manager, ns_router_maker_props.notifier.onError);
35
-
36
- return {
37
- product_id: this.props.product_id,
38
- account: {
39
- token_manager,
40
- server,
41
- },
42
- url: {
43
- getLink: this.getLink,
44
- redirect: this.redirect,
45
- getQueryStrings: this.getQueryStrings,
46
- getQuery: this.getQuery,
47
- navigate: this.props.navigate,
48
- },
49
- layout: {
50
- getNSALayout: (props: NSALayoutCustomProps<any, any>, key: string) =>
51
- {
52
- let layout = this.props.getNSALayout(props);
53
- return cloneElement(layout, { key });
54
- }
55
- },
56
- ...ns_router_maker_props
57
- };
58
- }
59
- getQueryStrings(): ParsedQuery
60
- {
61
- return queryString.parse(window.location.search);
62
- }
63
- getQuery(name: string, base64: boolean = false, remove: boolean = false): string
64
- {
65
- let query = this.getQueryStrings();
66
- let item = query[name];
67
- let ans = new ObjectService(item).getString();
68
- if (base64)
69
- try
70
- {
71
- ans = EncodingOperation.Base64Decode(ans);
72
- } catch (error)
73
- {
74
- ans = "";
75
- }
76
- if (remove)
77
- {
78
- const url = new URL(window.location.href);
79
- url.searchParams.delete(name);
80
- window.history.replaceState({}, '', url);
81
- }
82
-
83
- return ans;
84
- }
85
- getLink(sub: string, customQuery: { [name: string]: ParsedNameValue })
86
- {
87
- if (!customQuery)
88
- customQuery = {};
89
- return URLOperation.getLink("", sub, customQuery);
90
- }
91
- redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void
92
- {
93
- let ans = this.getLink(sub, customQuery);
94
- LinkOperation.open(ans);
95
- }
96
- override render(): React.JSX.Element
97
- {
98
- return <NSRouterMaker
99
- notifier_storage={this.props.notifier_storage}
100
- page_force_update={this.props.page_force_update}
101
- render={(ns_result: NSRouterMakerResult) =>
102
- {
103
- let nsa_result = this.getResult(ns_result);
104
-
105
- let banned = false;
106
- if (nsa_result.account.token_manager.exists())
107
- {
108
- banned = nsa_result.account.token_manager.getUserData(user => user.banned, false);
109
- if (!banned)
110
- {
111
- let custom_render = this.props.getCustomRender?.(nsa_result);
112
- if (custom_render)
113
- return custom_render;
114
- return <NSAConsentPage
115
- {...nsa_result}
116
- product_id={this.props.product_id}
117
- onAccepted={() =>
118
- {
119
- if (this.props.requirement.verification.email)
120
- {
121
- let e_verified = nsa_result.account.token_manager.getUserData(u => u.e_verified, false);
122
- if (!e_verified)
123
- return nsa_result.layout.getNSALayout({ ...nsa_result, children: <NSAEmailVerificationPage {...nsa_result} callback='' /> }, "nsa-page-email-verification");
124
- }
125
- if (this.props.requirement.verification.phone)
126
- {
127
- let p_verified = nsa_result.account.token_manager.getUserData(u => u.p_verified, false);
128
- if (!p_verified)
129
- return nsa_result.layout.getNSALayout({ ...nsa_result, children: <NSAPhoneVerificationPage {...nsa_result} callback='' /> }, "nsa-page-phone-verification");
130
- }
131
- return this.props.renderOnLogin(nsa_result);
132
- }}
133
- />;
134
- }
135
- }
136
- return this.props.renderOnLogout(nsa_result, banned);
137
-
138
- }}
139
- />;
140
- }
1
+ import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
2
+ import { EncodingOperation, EnvService, IStorageCookie, ObjectService, ParsedNameValue, URLOperation } from "namirasoft-core";
3
+ import { KeyOperation, LinkOperation, NSRouterMaker, NSRouterMakerResult } from 'namirasoft-site-react';
4
+ import queryString, { ParsedQuery } from 'query-string';
5
+ import React, { cloneElement } from 'react';
6
+ import { NSALayoutCustomProps } from "./main";
7
+ import { NSARouterMakerProps } from "./NSARouterMakerProps";
8
+ import { NSARouterMakerResult } from "./NSARouterMakerResult";
9
+ import { NSAConsentPage } from './pages/NSAConsentPage';
10
+ import { NSAEmailVerificationPage } from './pages/NSAEmailVerificationPage';
11
+ import { NSAPhoneVerificationPage } from './pages/NSAPhoneVerificationPage';
12
+
13
+ export class NSARouterMaker extends React.Component<NSARouterMakerProps>
14
+ {
15
+ constructor(props: NSARouterMakerProps)
16
+ {
17
+ super(props);
18
+ LinkOperation.setNavigate(props.navigate);
19
+ KeyOperation.start();
20
+ this.getResult = this.getResult.bind(this);
21
+ this.getQueryStrings = this.getQueryStrings.bind(this);
22
+ this.getQuery = this.getQuery.bind(this);
23
+ this.getLink = this.getLink.bind(this);
24
+ this.redirect = this.redirect.bind(this);
25
+ this.render = this.render.bind(this);
26
+ }
27
+ private getResult(ns_router_maker_props: NSRouterMakerResult): NSARouterMakerResult
28
+ {
29
+ let Cookies = process.env.REACT_APP_ACCOUNT_TOKEN;
30
+ let storage = new IStorageCookie({ domain: ".namirasoft.com", path: "/" }, Cookies);
31
+ let token_manager = new TokenManager(storage, () => { });
32
+
33
+ let REACT_APP_BASE_URL_ACCOUNT = new EnvService("REACT_APP_BASE_URL_ACCOUNT", true).getString();
34
+ let server = new NamirasoftAccountServer(REACT_APP_BASE_URL_ACCOUNT, token_manager, ns_router_maker_props.notifier.onError);
35
+
36
+ return {
37
+ product_id: this.props.product_id,
38
+ account: {
39
+ token_manager,
40
+ server,
41
+ },
42
+ url: {
43
+ getLink: this.getLink,
44
+ redirect: this.redirect,
45
+ getQueryStrings: this.getQueryStrings,
46
+ getQuery: this.getQuery,
47
+ navigate: this.props.navigate,
48
+ },
49
+ layout: {
50
+ getNSALayout: (props: NSALayoutCustomProps<any, any>, key: string) =>
51
+ {
52
+ let layout = this.props.getNSALayout(props);
53
+ return cloneElement(layout, { key });
54
+ }
55
+ },
56
+ ...ns_router_maker_props
57
+ };
58
+ }
59
+ getQueryStrings(): ParsedQuery
60
+ {
61
+ return queryString.parse(window.location.search);
62
+ }
63
+ getQuery(name: string, base64: boolean = false, remove: boolean = false): string
64
+ {
65
+ let query = this.getQueryStrings();
66
+ let item = query[name];
67
+ let ans = new ObjectService(item).getString();
68
+ if (base64)
69
+ try
70
+ {
71
+ ans = EncodingOperation.Base64Decode(ans);
72
+ } catch (error)
73
+ {
74
+ ans = "";
75
+ }
76
+ if (remove)
77
+ {
78
+ const url = new URL(window.location.href);
79
+ url.searchParams.delete(name);
80
+ window.history.replaceState({}, '', url);
81
+ }
82
+
83
+ return ans;
84
+ }
85
+ getLink(sub: string, customQuery: { [name: string]: ParsedNameValue })
86
+ {
87
+ if (!customQuery)
88
+ customQuery = {};
89
+ return URLOperation.getLink("", sub, customQuery);
90
+ }
91
+ redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void
92
+ {
93
+ let ans = this.getLink(sub, customQuery);
94
+ LinkOperation.open(ans);
95
+ }
96
+ override render(): React.JSX.Element
97
+ {
98
+ return <NSRouterMaker
99
+ notifier_storage={this.props.notifier_storage}
100
+ page_force_update={this.props.page_force_update}
101
+ render={(ns_result: NSRouterMakerResult) =>
102
+ {
103
+ let nsa_result = this.getResult(ns_result);
104
+
105
+ let banned = false;
106
+ if (nsa_result.account.token_manager.exists())
107
+ {
108
+ banned = nsa_result.account.token_manager.getUserData(user => user.banned, false);
109
+ if (!banned)
110
+ {
111
+ let custom_render = this.props.getCustomRender?.(nsa_result);
112
+ if (custom_render)
113
+ return custom_render;
114
+ return <NSAConsentPage
115
+ {...nsa_result}
116
+ product_id={this.props.product_id}
117
+ onAccepted={() =>
118
+ {
119
+ if (this.props.requirement.verification.email)
120
+ {
121
+ let e_verified = nsa_result.account.token_manager.getUserData(u => u.e_verified, false);
122
+ if (!e_verified)
123
+ return nsa_result.layout.getNSALayout({ ...nsa_result, children: <NSAEmailVerificationPage {...nsa_result} callback='' /> }, "nsa-page-email-verification");
124
+ }
125
+ if (this.props.requirement.verification.phone)
126
+ {
127
+ let p_verified = nsa_result.account.token_manager.getUserData(u => u.p_verified, false);
128
+ if (!p_verified)
129
+ return nsa_result.layout.getNSALayout({ ...nsa_result, children: <NSAPhoneVerificationPage {...nsa_result} callback='' /> }, "nsa-page-phone-verification");
130
+ }
131
+ return this.props.renderOnLogin(nsa_result);
132
+ }}
133
+ />;
134
+ }
135
+ }
136
+ return this.props.renderOnLogout(nsa_result, banned);
137
+
138
+ }}
139
+ />;
140
+ }
141
141
  };
@@ -1,24 +1,24 @@
1
- import { IStorage } from "namirasoft-core";
2
- import { ReactElement } from "react";
3
- import type { NavigateFunction } from "react-router-dom";
4
- import { NSARouterMakerResult } from "./NSARouterMakerResult";
5
- import { NSALayoutCustomProps } from "./layouts/NSALayout";
6
-
7
- export interface NSARouterMakerProps
8
- {
9
- notifier_storage: IStorage;
10
- page_force_update: () => void;
11
-
12
- product_id: string;
13
- navigate: NavigateFunction;
14
- renderOnLogin(result: NSARouterMakerResult): ReactElement;
15
- renderOnLogout(result: NSARouterMakerResult, banned: boolean): ReactElement;
16
- getNSALayout<RowType extends { id: string }, RowTypeInput = RowType>(props: NSALayoutCustomProps<RowType, RowTypeInput>): ReactElement;
17
- requirement: {
18
- verification: {
19
- email: boolean;
20
- phone: boolean;
21
- };
22
- };
23
- getCustomRender?: (result: NSARouterMakerResult) => ReactElement | null;
1
+ import { IStorage } from "namirasoft-core";
2
+ import { ReactElement } from "react";
3
+ import type { NavigateFunction } from "react-router-dom";
4
+ import { NSARouterMakerResult } from "./NSARouterMakerResult";
5
+ import { NSALayoutCustomProps } from "./layouts/NSALayout";
6
+
7
+ export interface NSARouterMakerProps
8
+ {
9
+ notifier_storage: IStorage;
10
+ page_force_update: () => void;
11
+
12
+ product_id: string;
13
+ navigate: NavigateFunction;
14
+ renderOnLogin(result: NSARouterMakerResult): ReactElement;
15
+ renderOnLogout(result: NSARouterMakerResult, banned: boolean): ReactElement;
16
+ getNSALayout<RowType extends { id: string }, RowTypeInput = RowType>(props: NSALayoutCustomProps<RowType, RowTypeInput>): ReactElement;
17
+ requirement: {
18
+ verification: {
19
+ email: boolean;
20
+ phone: boolean;
21
+ };
22
+ };
23
+ getCustomRender?: (result: NSARouterMakerResult) => ReactElement | null;
24
24
  }
@@ -1,25 +1,25 @@
1
- import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
2
- import { ParsedNameValue } from "namirasoft-core";
3
- import { NSRouterMakerResult } from "namirasoft-site-react";
4
- import { ParsedQuery } from "query-string";
5
- import { NavigateFunction } from "react-router-dom";
6
- import { NSALayoutCustomProps } from "./layouts/NSALayout";
7
-
8
- export interface NSARouterMakerResult extends NSRouterMakerResult
9
- {
10
- product_id: string;
11
- account: {
12
- token_manager: TokenManager
13
- server: NamirasoftAccountServer;
14
- },
15
- url: {
16
- getQueryStrings(): ParsedQuery;
17
- getQuery(name: string, base64?: boolean, remove?: boolean): string;
18
- getLink(sub: string, customQuery: { [name: string]: ParsedNameValue }): string;
19
- redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void;
20
- navigate: NavigateFunction;
21
- },
22
- layout: {
23
- getNSALayout<RowType extends { id: string }, RowTypeInput = RowType>(props: NSALayoutCustomProps<RowType, RowTypeInput>, key: string): React.JSX.Element;
24
- }
1
+ import { NamirasoftAccountServer, TokenManager } from "namirasoft-account";
2
+ import { ParsedNameValue } from "namirasoft-core";
3
+ import { NSRouterMakerResult } from "namirasoft-site-react";
4
+ import { ParsedQuery } from "query-string";
5
+ import { NavigateFunction } from "react-router-dom";
6
+ import { NSALayoutCustomProps } from "./layouts/NSALayout";
7
+
8
+ export interface NSARouterMakerResult extends NSRouterMakerResult
9
+ {
10
+ product_id: string;
11
+ account: {
12
+ token_manager: TokenManager
13
+ server: NamirasoftAccountServer;
14
+ },
15
+ url: {
16
+ getQueryStrings(): ParsedQuery;
17
+ getQuery(name: string, base64?: boolean, remove?: boolean): string;
18
+ getLink(sub: string, customQuery: { [name: string]: ParsedNameValue }): string;
19
+ redirect(sub: string, customQuery: { [name: string]: ParsedNameValue }): void;
20
+ navigate: NavigateFunction;
21
+ },
22
+ layout: {
23
+ getNSALayout<RowType extends { id: string }, RowTypeInput = RowType>(props: NSALayoutCustomProps<RowType, RowTypeInput>, key: string): React.JSX.Element;
24
+ }
25
25
  }
@@ -1,36 +1,36 @@
1
- import { EnvService } from 'namirasoft-core';
2
- import { CategoryScopeRow, EntityResolveResponseRow, NamirasoftFieldServer, SlotEntityType, SlotRow } from 'namirasoft-field';
3
- import { ReactNode } from 'react';
4
- import { Route } from 'react-router-dom';
5
- import { NSALayoutCustomProps } from './main';
6
- import { NSFRoutes } from './NSFRoutes';
7
- import { NSFCategoryEditPage } from './pages/NSFCategoryEditPage';
8
- import { NSFCategoryListPage } from './pages/NSFCategoryListPage';
9
- import { NSFCategoryViewPage } from './pages/NSFCategoryViewPage';
10
-
11
- export interface NSFRouterMakerProps extends NSALayoutCustomProps<any, any>
12
- {
13
- rows: EntityResolveResponseRow;
14
- }
15
-
16
- export class NSFRouterMaker
17
- {
18
- static getRoutes(props: NSFRouterMakerProps): ReactNode[]
19
- {
20
- const { rows } = props;
21
- const scope_slots = rows?.slots.filter(s => s.entity_type === SlotEntityType.CategoryScope) ?? [];
22
- let pairs = scope_slots.map(slot => ({ slot, category_scope: rows?.category_scopes.find(c => c.id === slot.entity_id) })).filter(i => i.category_scope) as { slot: SlotRow, category_scope: CategoryScopeRow }[];
23
-
24
- let REACT_APP_BASE_URL_FIELD = new EnvService("REACT_APP_BASE_URL_FIELD", true).getString();
25
- let field = new NamirasoftFieldServer(REACT_APP_BASE_URL_FIELD, props.account.token_manager, props.notifier.onError);
26
- let servers = { field };
27
-
28
- return pairs.flatMap(({ slot, category_scope }) => [
29
- <Route key={`${slot.id}-category-list`} path={NSFRoutes.CategoryList(slot.id, slot.name)} element={<NSFCategoryListPage {...props} servers={servers} slot={slot} category_scope={category_scope} />} />,
30
- <Route key={`${slot.id}-category-new`} path={NSFRoutes.CategoryNew(slot.id, slot.name)} element={<NSFCategoryEditPage {...props} servers={servers} isEdit={false} slot={slot} category_scope={category_scope} />} />,
31
- <Route key={`${slot.id}-category-copy`} path={NSFRoutes.CategoryCopy(slot.id, slot.name, ":id")} element={<NSFCategoryEditPage {...props} servers={servers} isEdit={false} slot={slot} category_scope={category_scope} />} />,
32
- <Route key={`${slot.id}-category-edit`} path={NSFRoutes.CategoryEdit(slot.id, slot.name, ":id")} element={<NSFCategoryEditPage {...props} servers={servers} isEdit={true} slot={slot} category_scope={category_scope} />} />,
33
- <Route key={`${slot.id}-category-view`} path={NSFRoutes.CategoryView(slot.id, slot.name, ":id")} element={<NSFCategoryViewPage {...props} servers={servers} slot={slot} category_scope={category_scope} />} />,
34
- ]);
35
- }
1
+ import { EnvService } from 'namirasoft-core';
2
+ import { CategoryScopeRow, EntityResolveResponseRow, NamirasoftFieldServer, SlotEntityType, SlotRow } from 'namirasoft-field';
3
+ import { ReactNode } from 'react';
4
+ import { Route } from 'react-router-dom';
5
+ import { NSALayoutCustomProps } from './main';
6
+ import { NSFRoutes } from './NSFRoutes';
7
+ import { NSFCategoryEditPage } from './pages/NSFCategoryEditPage';
8
+ import { NSFCategoryListPage } from './pages/NSFCategoryListPage';
9
+ import { NSFCategoryViewPage } from './pages/NSFCategoryViewPage';
10
+
11
+ export interface NSFRouterMakerProps extends NSALayoutCustomProps<any, any>
12
+ {
13
+ rows: EntityResolveResponseRow;
14
+ }
15
+
16
+ export class NSFRouterMaker
17
+ {
18
+ static getRoutes(props: NSFRouterMakerProps): ReactNode[]
19
+ {
20
+ const { rows } = props;
21
+ const scope_slots = rows?.slots.filter(s => s.entity_type === SlotEntityType.CategoryScope) ?? [];
22
+ let pairs = scope_slots.map(slot => ({ slot, category_scope: rows?.category_scopes.find(c => c.id === slot.entity_id) })).filter(i => i.category_scope) as { slot: SlotRow, category_scope: CategoryScopeRow }[];
23
+
24
+ let REACT_APP_BASE_URL_FIELD = new EnvService("REACT_APP_BASE_URL_FIELD", true).getString();
25
+ let field = new NamirasoftFieldServer(REACT_APP_BASE_URL_FIELD, props.account.token_manager, props.notifier.onError);
26
+ let servers = { field };
27
+
28
+ return pairs.flatMap(({ slot, category_scope }) => [
29
+ <Route key={`${slot.id}-category-list`} path={NSFRoutes.CategoryList(slot.id, slot.name)} element={<NSFCategoryListPage {...props} servers={servers} slot={slot} category_scope={category_scope} />} />,
30
+ <Route key={`${slot.id}-category-new`} path={NSFRoutes.CategoryNew(slot.id, slot.name)} element={<NSFCategoryEditPage {...props} servers={servers} isEdit={false} slot={slot} category_scope={category_scope} />} />,
31
+ <Route key={`${slot.id}-category-copy`} path={NSFRoutes.CategoryCopy(slot.id, slot.name, ":id")} element={<NSFCategoryEditPage {...props} servers={servers} isEdit={false} slot={slot} category_scope={category_scope} />} />,
32
+ <Route key={`${slot.id}-category-edit`} path={NSFRoutes.CategoryEdit(slot.id, slot.name, ":id")} element={<NSFCategoryEditPage {...props} servers={servers} isEdit={true} slot={slot} category_scope={category_scope} />} />,
33
+ <Route key={`${slot.id}-category-view`} path={NSFRoutes.CategoryView(slot.id, slot.name, ":id")} element={<NSFCategoryViewPage {...props} servers={servers} slot={slot} category_scope={category_scope} />} />,
34
+ ]);
35
+ }
36
36
  }