@etsoo/smarterp-core 1.0.21 → 1.0.23
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.
|
@@ -39,16 +39,40 @@ function AppSwitchPopover(props) {
|
|
|
39
39
|
if (index >= 0)
|
|
40
40
|
data.splice(index, 1);
|
|
41
41
|
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "column", margin: 2, children: [data.map((appData) => ((0, jsx_runtime_1.jsx)(material_1.Button, { onClick: async () => {
|
|
42
|
-
|
|
42
|
+
/*
|
|
43
|
+
// Method 1, get the login URL and redirect
|
|
44
|
+
const tasks = appData.urls.map((u) =>
|
|
45
|
+
app.core.authApi.getLogInUrl(
|
|
46
|
+
"APP",
|
|
47
|
+
{ showLoading: false, onError: () => false },
|
|
48
|
+
u.api
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
|
|
43
52
|
const result = await Promise.allSettled(tasks);
|
|
44
|
-
const success = result.find(
|
|
53
|
+
const success = result.find(
|
|
54
|
+
(r) => r.status === "fulfilled" && r.value != null
|
|
55
|
+
) as PromiseFulfilledResult<string> | undefined;
|
|
45
56
|
if (success) {
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
app.clearSession();
|
|
58
|
+
app.loadUrlEx(success.value);
|
|
59
|
+
} else {
|
|
60
|
+
app.notifier.alert(app.get("networkFailure"));
|
|
48
61
|
}
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
*/
|
|
63
|
+
// Method 2, get the RequestAuth, sign in and redirect
|
|
64
|
+
const tasks = appData.urls.map((u) => app.core.authApi.getAuthRequest("APP", { showLoading: false, onError: () => false }, u.api));
|
|
65
|
+
const result = await Promise.allSettled(tasks);
|
|
66
|
+
const success = result.find((r) => r.status === "fulfilled" && r.value != null);
|
|
67
|
+
if (success) {
|
|
68
|
+
const url = await app.core.authApi.authRequest(success.value);
|
|
69
|
+
if (url) {
|
|
70
|
+
app.clearSession();
|
|
71
|
+
app.loadUrlEx(url);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
51
74
|
}
|
|
75
|
+
app.notifier.alert(app.get("networkFailure"));
|
|
52
76
|
}, children: app.core.getAppName(appData) }, appData.id))), (data.length === 0 || data.length === maxItems) && ((0, jsx_runtime_1.jsxs)(material_1.Button, { onClick: () => navigate("./app/my"), children: [labels.more, "..."] }))] }));
|
|
53
77
|
} }));
|
|
54
78
|
}
|
|
@@ -33,16 +33,40 @@ export function AppSwitchPopover(props) {
|
|
|
33
33
|
if (index >= 0)
|
|
34
34
|
data.splice(index, 1);
|
|
35
35
|
return (_jsxs(Stack, { direction: "column", margin: 2, children: [data.map((appData) => (_jsx(Button, { onClick: async () => {
|
|
36
|
-
|
|
36
|
+
/*
|
|
37
|
+
// Method 1, get the login URL and redirect
|
|
38
|
+
const tasks = appData.urls.map((u) =>
|
|
39
|
+
app.core.authApi.getLogInUrl(
|
|
40
|
+
"APP",
|
|
41
|
+
{ showLoading: false, onError: () => false },
|
|
42
|
+
u.api
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
|
|
37
46
|
const result = await Promise.allSettled(tasks);
|
|
38
|
-
const success = result.find(
|
|
47
|
+
const success = result.find(
|
|
48
|
+
(r) => r.status === "fulfilled" && r.value != null
|
|
49
|
+
) as PromiseFulfilledResult<string> | undefined;
|
|
39
50
|
if (success) {
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
app.clearSession();
|
|
52
|
+
app.loadUrlEx(success.value);
|
|
53
|
+
} else {
|
|
54
|
+
app.notifier.alert(app.get("networkFailure"));
|
|
42
55
|
}
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
*/
|
|
57
|
+
// Method 2, get the RequestAuth, sign in and redirect
|
|
58
|
+
const tasks = appData.urls.map((u) => app.core.authApi.getAuthRequest("APP", { showLoading: false, onError: () => false }, u.api));
|
|
59
|
+
const result = await Promise.allSettled(tasks);
|
|
60
|
+
const success = result.find((r) => r.status === "fulfilled" && r.value != null);
|
|
61
|
+
if (success) {
|
|
62
|
+
const url = await app.core.authApi.authRequest(success.value);
|
|
63
|
+
if (url) {
|
|
64
|
+
app.clearSession();
|
|
65
|
+
app.loadUrlEx(url);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
45
68
|
}
|
|
69
|
+
app.notifier.alert(app.get("networkFailure"));
|
|
46
70
|
}, children: app.core.getAppName(appData) }, appData.id))), (data.length === 0 || data.length === maxItems) && (_jsxs(Button, { onClick: () => navigate("./app/my"), children: [labels.more, "..."] }))] }));
|
|
47
71
|
} }));
|
|
48
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/smarterp-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "TypeScript APIs for SmartERP Core",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
"@types/react-dom": "^18.3.1",
|
|
50
50
|
"@vitejs/plugin-react": "^4.3.4",
|
|
51
51
|
"jsdom": "^26.0.0",
|
|
52
|
-
"typescript": "^5.
|
|
52
|
+
"typescript": "^5.8.2",
|
|
53
53
|
"vitest": "^3.0.7"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@etsoo/appscript": "^1.6.
|
|
57
|
-
"@etsoo/materialui": "^1.4.
|
|
56
|
+
"@etsoo/appscript": "^1.6.17",
|
|
57
|
+
"@etsoo/materialui": "^1.4.97",
|
|
58
58
|
"@etsoo/react": "^1.8.32",
|
|
59
59
|
"@etsoo/shared": "^1.2.62",
|
|
60
|
-
"@etsoo/toolpad": "^1.0.
|
|
61
|
-
"@mui/material": "^6.4.
|
|
60
|
+
"@etsoo/toolpad": "^1.0.19",
|
|
61
|
+
"@mui/material": "^6.4.6",
|
|
62
62
|
"react": "^18.3.1",
|
|
63
63
|
"react-dom": "^18.3.1"
|
|
64
64
|
}
|
|
@@ -5,6 +5,7 @@ import { ButtonPopover } from "@etsoo/materialui";
|
|
|
5
5
|
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
6
6
|
import { IdentityType } from "../../dto/IdentityType";
|
|
7
7
|
import { AppData } from "../../dto/app/AppData";
|
|
8
|
+
import { AuthRequest } from "@etsoo/appscript";
|
|
8
9
|
|
|
9
10
|
export type AppSwitchPopoverProps = {
|
|
10
11
|
appName: string;
|
|
@@ -69,6 +70,8 @@ export function AppSwitchPopover(props: AppSwitchPopoverProps) {
|
|
|
69
70
|
<Button
|
|
70
71
|
key={appData.id}
|
|
71
72
|
onClick={async () => {
|
|
73
|
+
/*
|
|
74
|
+
// Method 1, get the login URL and redirect
|
|
72
75
|
const tasks = appData.urls.map((u) =>
|
|
73
76
|
app.core.authApi.getLogInUrl(
|
|
74
77
|
"APP",
|
|
@@ -87,6 +90,33 @@ export function AppSwitchPopover(props: AppSwitchPopoverProps) {
|
|
|
87
90
|
} else {
|
|
88
91
|
app.notifier.alert(app.get("networkFailure"));
|
|
89
92
|
}
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
// Method 2, get the RequestAuth, sign in and redirect
|
|
96
|
+
const tasks = appData.urls.map((u) =>
|
|
97
|
+
app.core.authApi.getAuthRequest(
|
|
98
|
+
"APP",
|
|
99
|
+
{ showLoading: false, onError: () => false },
|
|
100
|
+
u.api
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const result = await Promise.allSettled(tasks);
|
|
105
|
+
const success = result.find(
|
|
106
|
+
(r) => r.status === "fulfilled" && r.value != null
|
|
107
|
+
) as PromiseFulfilledResult<AuthRequest> | undefined;
|
|
108
|
+
if (success) {
|
|
109
|
+
const url = await app.core.authApi.authRequest(
|
|
110
|
+
success.value
|
|
111
|
+
);
|
|
112
|
+
if (url) {
|
|
113
|
+
app.clearSession();
|
|
114
|
+
app.loadUrlEx(url);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
app.notifier.alert(app.get("networkFailure"));
|
|
90
120
|
}}
|
|
91
121
|
>
|
|
92
122
|
{app.core.getAppName(appData)}
|