@etsoo/materialui 1.4.53 → 1.4.55

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.
@@ -73,7 +73,7 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
73
73
  * @param fromOrganizationId From organization ID
74
74
  * @param payload Payload
75
75
  */
76
- switchOrg(organizationId: number, fromOrganizationId?: number, payload?: IApiPayload<IActionResult<U & ServiceUserToken>>): Promise<void>;
76
+ switchOrg(organizationId: number, fromOrganizationId?: number, payload?: IApiPayload<IActionResult<U & ServiceUserToken>>): Promise<IActionResult<U & ServiceUserToken> | undefined>;
77
77
  /**
78
78
  * Try login
79
79
  * @param params Login parameters
@@ -167,9 +167,15 @@ export class ServiceApp extends ReactApp {
167
167
  if (!this.coreAccessToken) {
168
168
  throw new Error("Core access token is required to switch organization.");
169
169
  }
170
- const [result, refreshToken] = await new AuthApi(this, this.coreApi).switchOrg({ organizationId, fromOrganizationId, token: this.coreAccessToken }, payload);
171
- if (result == null || result.data == null)
170
+ const [result, refreshToken] = await new AuthApi(this).switchOrg({ organizationId, fromOrganizationId, token: this.coreAccessToken }, payload);
171
+ if (result == null)
172
172
  return;
173
+ if (!result.ok) {
174
+ return result;
175
+ }
176
+ if (result.data == null) {
177
+ throw new Error("Invalid switch organization result.");
178
+ }
173
179
  let core;
174
180
  if ("core" in result.data && typeof result.data.core === "string") {
175
181
  core = JSON.parse(result.data.core);
@@ -179,6 +185,7 @@ export class ServiceApp extends ReactApp {
179
185
  const user = refreshToken ? { ...result.data, refreshToken } : result.data;
180
186
  // User login
181
187
  this.userLoginEx(user, core, true);
188
+ return result;
182
189
  }
183
190
  /**
184
191
  * Try login
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.53",
3
+ "version": "1.4.55",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -39,8 +39,8 @@
39
39
  "@etsoo/notificationbase": "^1.1.54",
40
40
  "@etsoo/react": "^1.8.15",
41
41
  "@etsoo/shared": "^1.2.55",
42
- "@mui/icons-material": "^6.3.0",
43
- "@mui/material": "^6.3.0",
42
+ "@mui/icons-material": "^6.3.1",
43
+ "@mui/material": "^6.3.1",
44
44
  "@mui/x-data-grid": "^7.23.5",
45
45
  "chart.js": "^4.4.7",
46
46
  "chartjs-plugin-datalabels": "^2.2.0",
@@ -220,15 +220,20 @@ export class ServiceApp<
220
220
  throw new Error("Core access token is required to switch organization.");
221
221
  }
222
222
 
223
- const [result, refreshToken] = await new AuthApi(
224
- this,
225
- this.coreApi
226
- ).switchOrg(
223
+ const [result, refreshToken] = await new AuthApi(this).switchOrg(
227
224
  { organizationId, fromOrganizationId, token: this.coreAccessToken },
228
225
  payload
229
226
  );
230
227
 
231
- if (result == null || result.data == null) return;
228
+ if (result == null) return;
229
+
230
+ if (!result.ok) {
231
+ return result;
232
+ }
233
+
234
+ if (result.data == null) {
235
+ throw new Error("Invalid switch organization result.");
236
+ }
232
237
 
233
238
  let core: ApiRefreshTokenDto | undefined;
234
239
  if ("core" in result.data && typeof result.data.core === "string") {
@@ -241,6 +246,8 @@ export class ServiceApp<
241
246
 
242
247
  // User login
243
248
  this.userLoginEx(user, core, true);
249
+
250
+ return result;
244
251
  }
245
252
 
246
253
  /**