namirasoft-account-react 1.5.37 → 1.5.39

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