@etsoo/react 1.5.55 → 1.5.58

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.
@@ -29,7 +29,6 @@ export declare abstract class CommonApp<U extends IUser = IUser, P extends IPage
29
29
  * @param props Props
30
30
  */
31
31
  refreshToken<D = RefreshTokenRQ>(props?: RefreshTokenProps<D>): Promise<boolean>;
32
- private loginFailed;
33
32
  /**
34
33
  * Try login
35
34
  * @param data Additional data
@@ -127,10 +127,6 @@ export class CommonApp extends ReactApp {
127
127
  }
128
128
  return success(result, callback);
129
129
  }
130
- loginFailed() {
131
- this.userUnauthorized();
132
- this.toLoginPage();
133
- }
134
130
  /**
135
131
  * Try login
136
132
  * @param data Additional data
@@ -144,18 +140,7 @@ export class CommonApp extends ReactApp {
144
140
  return false;
145
141
  // Refresh token
146
142
  return await this.refreshToken({
147
- callback: (result) => {
148
- if (result === true)
149
- return;
150
- const message = this.formatRefreshTokenResult(result);
151
- if (message == null) {
152
- this.loginFailed();
153
- return;
154
- }
155
- this.notifier.alert(message, () => {
156
- this.loginFailed();
157
- });
158
- },
143
+ callback: (result) => this.doRefreshTokenResult(result),
159
144
  data,
160
145
  showLoading,
161
146
  relogin: true
@@ -1,4 +1,4 @@
1
- import { CoreApp, IActionResult, IAppSettings, ICoreApp, IUser, IUserData } from '@etsoo/appscript';
1
+ import { CoreApp, IActionResult, IAppSettings, ICoreApp, IUser } from '@etsoo/appscript';
2
2
  import { NotificationRenderProps, NotificationReturn } from '@etsoo/notificationbase';
3
3
  import { DataTypes } from '@etsoo/shared';
4
4
  import React from 'react';
@@ -28,7 +28,7 @@ export declare function ReactAppStateDetector(props: IStateProps): React.Functio
28
28
  /**
29
29
  * Core application interface
30
30
  */
31
- export interface IReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends ICoreApp<S, React.ReactNode, NotificationReactCallProps> {
31
+ export interface IReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends ICoreApp<D, S, React.ReactNode, NotificationReactCallProps> {
32
32
  /**
33
33
  * User state
34
34
  */
@@ -64,7 +64,7 @@ export interface IReactApp<S extends IAppSettings, D extends IUser, P extends IP
64
64
  /**
65
65
  * React application
66
66
  */
67
- export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends CoreApp<S, React.ReactNode, NotificationReactCallProps> implements IReactApp<S, D, P> {
67
+ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends IPageData> extends CoreApp<D, S, React.ReactNode, NotificationReactCallProps> implements IReactApp<S, D, P> {
68
68
  private static _notifierProvider;
69
69
  /**
70
70
  * Get notifier provider
@@ -181,7 +181,7 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
181
181
  * @param keep Keep in local storage or not
182
182
  * @param dispatch User state dispatch
183
183
  */
184
- userLogin(user: IUserData, refreshToken: string, keep?: boolean, dispatch?: boolean): void;
184
+ userLogin(user: D, refreshToken: string, keep?: boolean, dispatch?: boolean): void;
185
185
  /**
186
186
  * User logout
187
187
  * @param clearToken Clear refresh token or not
@@ -46,7 +46,6 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
46
46
  * @param props Props
47
47
  */
48
48
  refreshToken<D = RefreshTokenRQ>(props?: RefreshTokenProps<D>): Promise<boolean>;
49
- private loginFailed;
50
49
  /**
51
50
  * Service decrypt message
52
51
  * @param messageEncrypted Encrypted message
@@ -184,10 +184,6 @@ export class ServiceApp extends ReactApp {
184
184
  }
185
185
  return await success(result, callback);
186
186
  }
187
- loginFailed() {
188
- this.userUnauthorized();
189
- this.toLoginPage();
190
- }
191
187
  /**
192
188
  * Service decrypt message
193
189
  * @param messageEncrypted Encrypted message
@@ -220,21 +216,7 @@ export class ServiceApp extends ReactApp {
220
216
  return false;
221
217
  // Refresh token
222
218
  return await this.refreshToken({
223
- callback: (result) => {
224
- // Success
225
- if (result === true)
226
- return;
227
- // Clear cache
228
- this.clearCacheData();
229
- const message = this.formatRefreshTokenResult(result);
230
- if (message == null) {
231
- this.loginFailed();
232
- return;
233
- }
234
- this.notifier.alert(message, () => {
235
- this.loginFailed();
236
- });
237
- },
219
+ callback: (result) => this.doRefreshTokenResult(result),
238
220
  data,
239
221
  showLoading,
240
222
  relogin: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.55",
3
+ "version": "1.5.58",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -49,11 +49,11 @@
49
49
  "@emotion/css": "^11.10.0",
50
50
  "@emotion/react": "^11.10.0",
51
51
  "@emotion/styled": "^11.10.0",
52
- "@etsoo/appscript": "^1.2.65",
53
- "@etsoo/notificationbase": "^1.1.4",
54
- "@etsoo/shared": "^1.1.40",
52
+ "@etsoo/appscript": "^1.2.72",
53
+ "@etsoo/notificationbase": "^1.1.5",
54
+ "@etsoo/shared": "^1.1.41",
55
55
  "@mui/icons-material": "^5.8.4",
56
- "@mui/material": "^5.9.2",
56
+ "@mui/material": "^5.9.3",
57
57
  "@types/pica": "^9.0.1",
58
58
  "@types/pulltorefreshjs": "^0.1.5",
59
59
  "@types/react": "^18.0.15",
@@ -74,16 +74,16 @@
74
74
  "react-window": "^1.8.7"
75
75
  },
76
76
  "devDependencies": {
77
- "@babel/cli": "^7.18.9",
78
- "@babel/core": "^7.18.9",
79
- "@babel/plugin-transform-runtime": "^7.18.9",
80
- "@babel/preset-env": "^7.18.9",
77
+ "@babel/cli": "^7.18.10",
78
+ "@babel/core": "^7.18.10",
79
+ "@babel/plugin-transform-runtime": "^7.18.10",
80
+ "@babel/preset-env": "^7.18.10",
81
81
  "@babel/runtime-corejs3": "^7.18.9",
82
82
  "@types/jest": "^28.1.6",
83
83
  "@types/react-test-renderer": "^18.0.0",
84
- "@typescript-eslint/eslint-plugin": "^5.31.0",
85
- "@typescript-eslint/parser": "^5.31.0",
86
- "eslint": "^8.20.0",
84
+ "@typescript-eslint/eslint-plugin": "^5.32.0",
85
+ "@typescript-eslint/parser": "^5.32.0",
86
+ "eslint": "^8.21.0",
87
87
  "eslint-config-airbnb-base": "^15.0.0",
88
88
  "eslint-plugin-import": "^2.26.0",
89
89
  "eslint-plugin-react": "^7.30.1",
@@ -200,11 +200,6 @@ export abstract class CommonApp<
200
200
  return success(result, callback);
201
201
  }
202
202
 
203
- private loginFailed() {
204
- this.userUnauthorized();
205
- this.toLoginPage();
206
- }
207
-
208
203
  /**
209
204
  * Try login
210
205
  * @param data Additional data
@@ -221,19 +216,7 @@ export abstract class CommonApp<
221
216
 
222
217
  // Refresh token
223
218
  return await this.refreshToken({
224
- callback: (result) => {
225
- if (result === true) return;
226
-
227
- const message = this.formatRefreshTokenResult(result);
228
- if (message == null) {
229
- this.loginFailed();
230
- return;
231
- }
232
-
233
- this.notifier.alert(message, () => {
234
- this.loginFailed();
235
- });
236
- },
219
+ callback: (result) => this.doRefreshTokenResult(result),
237
220
  data,
238
221
  showLoading,
239
222
  relogin: true
@@ -6,8 +6,7 @@ import {
6
6
  IActionResult,
7
7
  IAppSettings,
8
8
  ICoreApp,
9
- IUser,
10
- IUserData
9
+ IUser
11
10
  } from '@etsoo/appscript';
12
11
  import {
13
12
  NotificationMessageType,
@@ -94,7 +93,7 @@ export interface IReactApp<
94
93
  S extends IAppSettings,
95
94
  D extends IUser,
96
95
  P extends IPageData
97
- > extends ICoreApp<S, React.ReactNode, NotificationReactCallProps> {
96
+ > extends ICoreApp<D, S, React.ReactNode, NotificationReactCallProps> {
98
97
  /**
99
98
  * User state
100
99
  */
@@ -142,7 +141,7 @@ export class ReactApp<
142
141
  D extends IUser,
143
142
  P extends IPageData
144
143
  >
145
- extends CoreApp<S, React.ReactNode, NotificationReactCallProps>
144
+ extends CoreApp<D, S, React.ReactNode, NotificationReactCallProps>
146
145
  implements IReactApp<S, D, P>
147
146
  {
148
147
  private static _notifierProvider: React.FunctionComponent<NotificationRenderProps>;
@@ -453,7 +452,7 @@ export class ReactApp<
453
452
  * @param dispatch User state dispatch
454
453
  */
455
454
  override userLogin(
456
- user: IUserData,
455
+ user: D,
457
456
  refreshToken: string,
458
457
  keep?: boolean,
459
458
  dispatch?: boolean
@@ -271,11 +271,6 @@ export class ServiceApp<
271
271
  return await success(result, callback);
272
272
  }
273
273
 
274
- private loginFailed() {
275
- this.userUnauthorized();
276
- this.toLoginPage();
277
- }
278
-
279
274
  /**
280
275
  * Service decrypt message
281
276
  * @param messageEncrypted Encrypted message
@@ -320,23 +315,7 @@ export class ServiceApp<
320
315
 
321
316
  // Refresh token
322
317
  return await this.refreshToken({
323
- callback: (result) => {
324
- // Success
325
- if (result === true) return;
326
-
327
- // Clear cache
328
- this.clearCacheData();
329
-
330
- const message = this.formatRefreshTokenResult(result);
331
- if (message == null) {
332
- this.loginFailed();
333
- return;
334
- }
335
-
336
- this.notifier.alert(message, () => {
337
- this.loginFailed();
338
- });
339
- },
318
+ callback: (result) => this.doRefreshTokenResult(result),
340
319
  data,
341
320
  showLoading,
342
321
  relogin: true