@etsoo/react 1.3.61 → 1.3.65

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.
@@ -24,26 +24,24 @@ export function ReactAppStateDetector(props) {
24
24
  const { state } = globalApp == null
25
25
  ? { state: {} }
26
26
  : React.useContext(globalApp.userState.context);
27
- // Match fields
28
- const authorized = state.authorized;
29
- const changedFields = state.lastChangedFields;
30
- let matchedFields;
31
- if (targetFields == null || changedFields == null) {
32
- matchedFields = changedFields;
33
- }
34
- else {
35
- matchedFields = [];
36
- targetFields.forEach((targetField) => {
37
- if (changedFields.includes(targetField))
38
- matchedFields === null || matchedFields === void 0 ? void 0 : matchedFields.push(targetField);
39
- });
40
- }
41
- console.log('ReactAppStateDetector', state);
42
27
  // Ready
43
28
  React.useEffect(() => {
29
+ // Match fields
30
+ const changedFields = state.lastChangedFields;
31
+ let matchedFields;
32
+ if (targetFields == null || changedFields == null) {
33
+ matchedFields = changedFields;
34
+ }
35
+ else {
36
+ matchedFields = [];
37
+ targetFields.forEach((targetField) => {
38
+ if (changedFields.includes(targetField))
39
+ matchedFields === null || matchedFields === void 0 ? void 0 : matchedFields.push(targetField);
40
+ });
41
+ }
44
42
  // Callback
45
- update(authorized, matchedFields);
46
- }, [authorized, matchedFields]);
43
+ update(state.authorized, matchedFields);
44
+ }, [state]);
47
45
  // return
48
46
  return React.createElement(React.Fragment);
49
47
  }
@@ -64,6 +62,7 @@ export class ReactApp extends CoreApp {
64
62
  this.userState = new UserState();
65
63
  this.cultureState = new CultureState(settings.currentCulture);
66
64
  this.pageState = new PageState();
65
+ globalApp = this;
67
66
  }
68
67
  /**
69
68
  * Get notifier provider
@@ -2,6 +2,10 @@
2
2
  * Refresh token request data
3
3
  */
4
4
  export declare type RefreshTokenRQ = {
5
+ /**
6
+ * Device id
7
+ */
8
+ deviceId: string;
5
9
  /**
6
10
  * Login password
7
11
  */
@@ -1,4 +1,4 @@
1
- import { IApi, RefreshTokenProps } from '@etsoo/appscript';
1
+ import { IApi, InitCallDto, InitCallResult, RefreshTokenProps } from '@etsoo/appscript';
2
2
  import { IServiceAppSettings } from './IServiceAppSettings';
3
3
  import { IServicePageData } from './IServicePage';
4
4
  import { IServiceUser } from './IServiceUser';
@@ -26,6 +26,12 @@ export declare class ServiceApp<P extends IServicePageData = IServicePageData, U
26
26
  * @param name Application name
27
27
  */
28
28
  constructor(settings: S, name: string);
29
+ /**
30
+ * Api init call, connect to the core Api
31
+ * @param data Data
32
+ * @returns Result
33
+ */
34
+ protected apiInitCall(data: InitCallDto): Promise<InitCallResult | undefined>;
29
35
  /**
30
36
  * Go to the login page
31
37
  */
@@ -26,6 +26,14 @@ export class ServiceApp extends ReactApp {
26
26
  this.setApi(api);
27
27
  this.coreApi = api;
28
28
  }
29
+ /**
30
+ * Api init call, connect to the core Api
31
+ * @param data Data
32
+ * @returns Result
33
+ */
34
+ async apiInitCall(data) {
35
+ return await this.coreApi.put(this.initCallApi, data);
36
+ }
29
37
  /**
30
38
  * Go to the login page
31
39
  */
@@ -57,6 +65,7 @@ export class ServiceApp extends ReactApp {
57
65
  // Reqest data
58
66
  // Merge additional data passed
59
67
  const rq = {
68
+ deviceId: this.deviceId,
60
69
  timezone: this.getTimeZone(),
61
70
  ...data
62
71
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.3.61",
3
+ "version": "1.3.65",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@emotion/react": "^11.7.1",
51
51
  "@emotion/style": "^0.8.0",
52
52
  "@emotion/styled": "^11.6.0",
53
- "@etsoo/appscript": "^1.1.80",
53
+ "@etsoo/appscript": "^1.1.82",
54
54
  "@etsoo/notificationbase": "^1.0.94",
55
55
  "@etsoo/shared": "^1.0.78",
56
56
  "@mui/icons-material": "^5.2.4",
@@ -53,27 +53,24 @@ export function ReactAppStateDetector(props: IStateProps) {
53
53
  (globalApp.userState as UserState<IUser>).context
54
54
  );
55
55
 
56
- // Match fields
57
- const authorized = state.authorized;
58
- const changedFields = state.lastChangedFields;
59
- let matchedFields: string[] | undefined;
60
- if (targetFields == null || changedFields == null) {
61
- matchedFields = changedFields;
62
- } else {
63
- matchedFields = [];
64
- targetFields.forEach((targetField) => {
65
- if (changedFields.includes(targetField))
66
- matchedFields?.push(targetField);
67
- });
68
- }
69
-
70
- console.log('ReactAppStateDetector', state);
71
-
72
56
  // Ready
73
57
  React.useEffect(() => {
58
+ // Match fields
59
+ const changedFields = state.lastChangedFields;
60
+ let matchedFields: string[] | undefined;
61
+ if (targetFields == null || changedFields == null) {
62
+ matchedFields = changedFields;
63
+ } else {
64
+ matchedFields = [];
65
+ targetFields.forEach((targetField) => {
66
+ if (changedFields.includes(targetField))
67
+ matchedFields?.push(targetField);
68
+ });
69
+ }
70
+
74
71
  // Callback
75
- update(authorized, matchedFields);
76
- }, [authorized, matchedFields]);
72
+ update(state.authorized, matchedFields);
73
+ }, [state]);
77
74
 
78
75
  // return
79
76
  return React.createElement(React.Fragment);
@@ -195,6 +192,8 @@ export class ReactApp<
195
192
  );
196
193
  this.cultureState = new CultureState(settings.currentCulture);
197
194
  this.pageState = new PageState<P>();
195
+
196
+ globalApp = this;
198
197
  }
199
198
 
200
199
  /**
@@ -2,6 +2,11 @@
2
2
  * Refresh token request data
3
3
  */
4
4
  export type RefreshTokenRQ = {
5
+ /**
6
+ * Device id
7
+ */
8
+ deviceId: string;
9
+
5
10
  /**
6
11
  * Login password
7
12
  */
@@ -2,6 +2,8 @@ import {
2
2
  createClient,
3
3
  IApi,
4
4
  IApiPayload,
5
+ InitCallDto,
6
+ InitCallResult,
5
7
  RefreshTokenProps,
6
8
  RefreshTokenResult
7
9
  } from '@etsoo/appscript';
@@ -56,6 +58,15 @@ export class ServiceApp<
56
58
  this.coreApi = api;
57
59
  }
58
60
 
61
+ /**
62
+ * Api init call, connect to the core Api
63
+ * @param data Data
64
+ * @returns Result
65
+ */
66
+ protected override async apiInitCall(data: InitCallDto) {
67
+ return await this.coreApi.put<InitCallResult>(this.initCallApi, data);
68
+ }
69
+
59
70
  /**
60
71
  * Go to the login page
61
72
  */
@@ -96,6 +107,7 @@ export class ServiceApp<
96
107
  // Reqest data
97
108
  // Merge additional data passed
98
109
  const rq: RefreshTokenRQ = {
110
+ deviceId: this.deviceId,
99
111
  timezone: this.getTimeZone(),
100
112
  ...data
101
113
  };