@fctc/edu-logic-lib 1.1.4 → 1.1.5
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.
- package/dist/hooks.d.mts +209 -4
- package/dist/hooks.d.ts +209 -4
- package/dist/hooks.js +1786 -14
- package/dist/hooks.mjs +1742 -15
- package/dist/index-C_nK1Mii.d.mts +19 -0
- package/dist/index-C_nK1Mii.d.ts +19 -0
- package/dist/index.d.mts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +903 -290
- package/dist/index.mjs +856 -288
- package/dist/models.d.mts +4 -21
- package/dist/models.d.ts +4 -21
- package/dist/services.d.mts +3 -15
- package/dist/services.d.ts +3 -15
- package/dist/store.d.mts +194 -194
- package/dist/store.d.ts +194 -194
- package/dist/types.d.mts +1 -2
- package/dist/types.d.ts +1 -2
- package/dist/use-get-selection-DFh6sc49.d.mts +26 -0
- package/dist/use-get-selection-DFh6sc49.d.ts +26 -0
- package/dist/{api-type-dNqOR_Yp.d.mts → view-type-BTzRpkT7.d.mts} +42 -1
- package/dist/{api-type-dNqOR_Yp.d.ts → view-type-BTzRpkT7.d.ts} +42 -1
- package/package.json +12 -12
- package/dist/view-type-BOk5F1Fj.d.mts +0 -42
- package/dist/view-type-BOk5F1Fj.d.ts +0 -42
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var axios = require('axios');
|
|
3
4
|
var reactRedux = require('react-redux');
|
|
4
5
|
var toolkit = require('@reduxjs/toolkit');
|
|
5
|
-
var axios = require('axios');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
|
-
var
|
|
7
|
+
var React = require('react');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
|
|
12
12
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
|
+
|
|
15
|
+
// src/config/axios-client.ts
|
|
13
16
|
|
|
14
17
|
// src/constants/api/key-constant.ts
|
|
15
18
|
var KeyConstants = /* @__PURE__ */ ((KeyConstants2) => {
|
|
@@ -67,6 +70,259 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
|
|
|
67
70
|
return UriConstants2;
|
|
68
71
|
})(UriConstants || {});
|
|
69
72
|
|
|
73
|
+
// src/config/axios-client.ts
|
|
74
|
+
var MAINT_KEY = "MAINTENANCE_ACTIVE";
|
|
75
|
+
var MAINT_AT = "MAINTENANCE_AT";
|
|
76
|
+
var MAINT_LAST_PATH = "MAINTENANCE_LAST_PATH";
|
|
77
|
+
var hasRedirectedToMaintenance = false;
|
|
78
|
+
function setMaintenanceFlags() {
|
|
79
|
+
if (typeof window === "undefined") return;
|
|
80
|
+
const { pathname, search } = window.location;
|
|
81
|
+
const lastPath = pathname + (search || "");
|
|
82
|
+
if (pathname !== "/maintenance" && !window.localStorage.getItem(MAINT_LAST_PATH)) {
|
|
83
|
+
window.localStorage.setItem(MAINT_LAST_PATH, lastPath);
|
|
84
|
+
}
|
|
85
|
+
window.localStorage.setItem(MAINT_KEY, "true");
|
|
86
|
+
window.localStorage.setItem(MAINT_AT, String(Date.now()));
|
|
87
|
+
}
|
|
88
|
+
async function clearMaintenanceAndExit(getToken, opts) {
|
|
89
|
+
if (typeof window === "undefined") return;
|
|
90
|
+
const forceLogin = opts?.forceLogin === true;
|
|
91
|
+
const clearTokenOnForce = opts?.clearTokenOnForce !== false;
|
|
92
|
+
window.localStorage.removeItem(MAINT_KEY);
|
|
93
|
+
window.localStorage.removeItem(MAINT_AT);
|
|
94
|
+
const lastPath = window.localStorage.getItem(MAINT_LAST_PATH);
|
|
95
|
+
window.localStorage.removeItem(MAINT_LAST_PATH);
|
|
96
|
+
try {
|
|
97
|
+
if (forceLogin) {
|
|
98
|
+
if (clearTokenOnForce) {
|
|
99
|
+
try {
|
|
100
|
+
await opts?.clearToken?.();
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
window.location.replace("/login");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const token = await getToken();
|
|
108
|
+
if (token) {
|
|
109
|
+
const target = lastPath && lastPath !== "/maintenance" ? lastPath : "/";
|
|
110
|
+
window.location.replace(target);
|
|
111
|
+
} else {
|
|
112
|
+
window.location.replace("/login");
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
window.location.replace("/login");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var axiosClient = {
|
|
119
|
+
init(config) {
|
|
120
|
+
const localStorage2 = config.localStorageUtils;
|
|
121
|
+
const sessionStorage = config.sessionStorageUtils;
|
|
122
|
+
const db = config.db;
|
|
123
|
+
let isRefreshing = false;
|
|
124
|
+
let failedQueue = [];
|
|
125
|
+
const processQueue = (error, token = null) => {
|
|
126
|
+
failedQueue?.forEach((prom) => {
|
|
127
|
+
if (error) {
|
|
128
|
+
prom.reject(error);
|
|
129
|
+
} else {
|
|
130
|
+
prom.resolve(token);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
failedQueue = [];
|
|
134
|
+
};
|
|
135
|
+
const instance = axios__default.default.create({
|
|
136
|
+
adapter: axios__default.default.defaults.adapter,
|
|
137
|
+
baseURL: config.baseUrl,
|
|
138
|
+
timeout: 5e4,
|
|
139
|
+
paramsSerializer: (params) => new URLSearchParams(params).toString()
|
|
140
|
+
});
|
|
141
|
+
if (typeof window !== "undefined") {
|
|
142
|
+
const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
|
|
143
|
+
const onMaintenancePage = window.location.pathname === "/maintenance";
|
|
144
|
+
if (isMaint && !onMaintenancePage) {
|
|
145
|
+
hasRedirectedToMaintenance = true;
|
|
146
|
+
window.location.replace("/maintenance");
|
|
147
|
+
}
|
|
148
|
+
if (isMaint && onMaintenancePage) {
|
|
149
|
+
const healthUrl = config.healthUrl || `${(config.baseUrl || "").replace(/\/+$/, "")}/health`;
|
|
150
|
+
(async () => {
|
|
151
|
+
try {
|
|
152
|
+
await axios__default.default.get(healthUrl, { timeout: 8e3 });
|
|
153
|
+
await clearMaintenanceAndExit(() => localStorage2.getAccessToken(), {
|
|
154
|
+
forceLogin: true,
|
|
155
|
+
clearTokenOnForce: true,
|
|
156
|
+
clearToken: () => localStorage2.clearToken()
|
|
157
|
+
});
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
})();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
instance.interceptors.request.use(
|
|
164
|
+
async (configReq) => {
|
|
165
|
+
const token = await localStorage2.getAccessToken();
|
|
166
|
+
if (token) {
|
|
167
|
+
configReq.headers["Authorization"] = "Bearer " + token;
|
|
168
|
+
}
|
|
169
|
+
return configReq;
|
|
170
|
+
},
|
|
171
|
+
(error) => Promise.reject(error)
|
|
172
|
+
);
|
|
173
|
+
instance.interceptors.response.use(
|
|
174
|
+
(response) => {
|
|
175
|
+
if (typeof window !== "undefined") {
|
|
176
|
+
const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
|
|
177
|
+
const onMaintenancePage = window.location.pathname === "/maintenance";
|
|
178
|
+
if (isMaint && onMaintenancePage) {
|
|
179
|
+
(async () => {
|
|
180
|
+
await clearMaintenanceAndExit(
|
|
181
|
+
() => localStorage2.getAccessToken(),
|
|
182
|
+
{
|
|
183
|
+
forceLogin: true,
|
|
184
|
+
clearTokenOnForce: true,
|
|
185
|
+
clearToken: () => localStorage2.clearToken()
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
})();
|
|
189
|
+
} else if (isMaint) {
|
|
190
|
+
window.localStorage.removeItem(MAINT_KEY);
|
|
191
|
+
window.localStorage.removeItem(MAINT_AT);
|
|
192
|
+
window.localStorage.removeItem(MAINT_LAST_PATH);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return handleResponse(response);
|
|
196
|
+
},
|
|
197
|
+
async (error) => {
|
|
198
|
+
const status = error?.response?.status;
|
|
199
|
+
if (status === 503) {
|
|
200
|
+
if (typeof window !== "undefined") {
|
|
201
|
+
setMaintenanceFlags();
|
|
202
|
+
if (!hasRedirectedToMaintenance && window.location.pathname !== "/maintenance") {
|
|
203
|
+
hasRedirectedToMaintenance = true;
|
|
204
|
+
window.location.replace("/maintenance");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return Promise.reject({
|
|
208
|
+
code: 503,
|
|
209
|
+
message: "SERVICE_UNAVAILABLE",
|
|
210
|
+
original: error?.response?.data
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
const handleError = async (err) => {
|
|
214
|
+
if (!err.response) {
|
|
215
|
+
return err;
|
|
216
|
+
}
|
|
217
|
+
const { data } = err.response;
|
|
218
|
+
if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
|
|
219
|
+
await clearAuthToken();
|
|
220
|
+
}
|
|
221
|
+
return data;
|
|
222
|
+
};
|
|
223
|
+
const originalRequest = error.config;
|
|
224
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
|
225
|
+
error.response.data.code
|
|
226
|
+
)) {
|
|
227
|
+
if (isRefreshing) {
|
|
228
|
+
return new Promise(function(resolve, reject) {
|
|
229
|
+
failedQueue.push({ resolve, reject });
|
|
230
|
+
}).then((token) => {
|
|
231
|
+
originalRequest.headers["Authorization"] = "Bearer " + token;
|
|
232
|
+
return instance.request(originalRequest);
|
|
233
|
+
}).catch(async (err) => {
|
|
234
|
+
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
235
|
+
await clearAuthToken();
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
const browserSession = await sessionStorage.getBrowserSession();
|
|
240
|
+
const refreshToken = await localStorage2.getRefreshToken();
|
|
241
|
+
const accessTokenExp = await localStorage2.getAccessToken();
|
|
242
|
+
isRefreshing = true;
|
|
243
|
+
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
244
|
+
await clearAuthToken();
|
|
245
|
+
} else {
|
|
246
|
+
const payload = Object.fromEntries(
|
|
247
|
+
Object.entries({
|
|
248
|
+
refresh_token: refreshToken,
|
|
249
|
+
grant_type: "refresh_token",
|
|
250
|
+
client_id: config.config.clientId,
|
|
251
|
+
client_secret: config.config.clientSecret
|
|
252
|
+
}).filter(([_, value]) => !!value)
|
|
253
|
+
);
|
|
254
|
+
return new Promise(function(resolve) {
|
|
255
|
+
axios__default.default.post(
|
|
256
|
+
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
257
|
+
payload,
|
|
258
|
+
{
|
|
259
|
+
headers: {
|
|
260
|
+
"Content-Type": "multipart/form-data",
|
|
261
|
+
Authorization: `Bearer ${accessTokenExp}`
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
).then(async (res) => {
|
|
265
|
+
const data = res.data;
|
|
266
|
+
await localStorage2.setToken(data.access_token);
|
|
267
|
+
await localStorage2.setRefreshToken(data.refresh_token);
|
|
268
|
+
axios__default.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
269
|
+
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
270
|
+
processQueue(null, data.access_token);
|
|
271
|
+
resolve(instance.request(originalRequest));
|
|
272
|
+
}).catch(async (err) => {
|
|
273
|
+
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
|
274
|
+
await clearAuthToken();
|
|
275
|
+
}
|
|
276
|
+
if (err && err.response) {
|
|
277
|
+
const { error_code } = err.response?.data || {};
|
|
278
|
+
if (error_code === "AUTHEN_FAIL") {
|
|
279
|
+
await clearAuthToken();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
processQueue(err, null);
|
|
283
|
+
}).finally(() => {
|
|
284
|
+
isRefreshing = false;
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return Promise.reject(await handleError(error));
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
const handleResponse = (res) => {
|
|
293
|
+
if (res && res.data) {
|
|
294
|
+
return res.data;
|
|
295
|
+
}
|
|
296
|
+
return res;
|
|
297
|
+
};
|
|
298
|
+
const clearAuthToken = async () => {
|
|
299
|
+
await localStorage2.clearToken();
|
|
300
|
+
if (typeof window !== "undefined") {
|
|
301
|
+
window.location.href = `/login`;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
function formatUrl(url, db2) {
|
|
305
|
+
return url + (db2 ? "?db=" + db2 : "");
|
|
306
|
+
}
|
|
307
|
+
const responseBody = (response) => response;
|
|
308
|
+
const requests = {
|
|
309
|
+
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
|
310
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
|
|
311
|
+
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
|
312
|
+
responseType: "arraybuffer",
|
|
313
|
+
headers: {
|
|
314
|
+
"Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
|
|
315
|
+
Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
316
|
+
}
|
|
317
|
+
}).then(responseBody),
|
|
318
|
+
put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
|
|
319
|
+
patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
|
|
320
|
+
delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
|
|
321
|
+
};
|
|
322
|
+
return requests;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
70
326
|
// src/constants/field/field-type-constant.ts
|
|
71
327
|
var FieldTypeConstants = /* @__PURE__ */ ((FieldTypeConstants2) => {
|
|
72
328
|
FieldTypeConstants2["CHAR"] = "char";
|
|
@@ -663,257 +919,6 @@ var envStore = toolkit.configureStore({
|
|
|
663
919
|
// src/store/index.ts
|
|
664
920
|
var useAppDispatch = reactRedux.useDispatch;
|
|
665
921
|
var useAppSelector = reactRedux.useSelector;
|
|
666
|
-
var MAINT_KEY = "MAINTENANCE_ACTIVE";
|
|
667
|
-
var MAINT_AT = "MAINTENANCE_AT";
|
|
668
|
-
var MAINT_LAST_PATH = "MAINTENANCE_LAST_PATH";
|
|
669
|
-
var hasRedirectedToMaintenance = false;
|
|
670
|
-
function setMaintenanceFlags() {
|
|
671
|
-
if (typeof window === "undefined") return;
|
|
672
|
-
const { pathname, search } = window.location;
|
|
673
|
-
const lastPath = pathname + (search || "");
|
|
674
|
-
if (pathname !== "/maintenance" && !window.localStorage.getItem(MAINT_LAST_PATH)) {
|
|
675
|
-
window.localStorage.setItem(MAINT_LAST_PATH, lastPath);
|
|
676
|
-
}
|
|
677
|
-
window.localStorage.setItem(MAINT_KEY, "true");
|
|
678
|
-
window.localStorage.setItem(MAINT_AT, String(Date.now()));
|
|
679
|
-
}
|
|
680
|
-
async function clearMaintenanceAndExit(getToken, opts) {
|
|
681
|
-
if (typeof window === "undefined") return;
|
|
682
|
-
const forceLogin = opts?.forceLogin === true;
|
|
683
|
-
const clearTokenOnForce = opts?.clearTokenOnForce !== false;
|
|
684
|
-
window.localStorage.removeItem(MAINT_KEY);
|
|
685
|
-
window.localStorage.removeItem(MAINT_AT);
|
|
686
|
-
const lastPath = window.localStorage.getItem(MAINT_LAST_PATH);
|
|
687
|
-
window.localStorage.removeItem(MAINT_LAST_PATH);
|
|
688
|
-
try {
|
|
689
|
-
if (forceLogin) {
|
|
690
|
-
if (clearTokenOnForce) {
|
|
691
|
-
try {
|
|
692
|
-
await opts?.clearToken?.();
|
|
693
|
-
} catch {
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
window.location.replace("/login");
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
const token = await getToken();
|
|
700
|
-
if (token) {
|
|
701
|
-
const target = lastPath && lastPath !== "/maintenance" ? lastPath : "/";
|
|
702
|
-
window.location.replace(target);
|
|
703
|
-
} else {
|
|
704
|
-
window.location.replace("/login");
|
|
705
|
-
}
|
|
706
|
-
} catch {
|
|
707
|
-
window.location.replace("/login");
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
var axiosClient = {
|
|
711
|
-
init(config) {
|
|
712
|
-
const localStorage2 = config.localStorageUtils;
|
|
713
|
-
const sessionStorage = config.sessionStorageUtils;
|
|
714
|
-
const db = config.db;
|
|
715
|
-
let isRefreshing = false;
|
|
716
|
-
let failedQueue = [];
|
|
717
|
-
const processQueue = (error, token = null) => {
|
|
718
|
-
failedQueue?.forEach((prom) => {
|
|
719
|
-
if (error) {
|
|
720
|
-
prom.reject(error);
|
|
721
|
-
} else {
|
|
722
|
-
prom.resolve(token);
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
failedQueue = [];
|
|
726
|
-
};
|
|
727
|
-
const instance = axios__default.default.create({
|
|
728
|
-
adapter: axios__default.default.defaults.adapter,
|
|
729
|
-
baseURL: config.baseUrl,
|
|
730
|
-
timeout: 5e4,
|
|
731
|
-
paramsSerializer: (params) => new URLSearchParams(params).toString()
|
|
732
|
-
});
|
|
733
|
-
if (typeof window !== "undefined") {
|
|
734
|
-
const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
|
|
735
|
-
const onMaintenancePage = window.location.pathname === "/maintenance";
|
|
736
|
-
if (isMaint && !onMaintenancePage) {
|
|
737
|
-
hasRedirectedToMaintenance = true;
|
|
738
|
-
window.location.replace("/maintenance");
|
|
739
|
-
}
|
|
740
|
-
if (isMaint && onMaintenancePage) {
|
|
741
|
-
const healthUrl = config.healthUrl || `${(config.baseUrl || "").replace(/\/+$/, "")}/health`;
|
|
742
|
-
(async () => {
|
|
743
|
-
try {
|
|
744
|
-
await axios__default.default.get(healthUrl, { timeout: 8e3 });
|
|
745
|
-
await clearMaintenanceAndExit(() => localStorage2.getAccessToken(), {
|
|
746
|
-
forceLogin: true,
|
|
747
|
-
clearTokenOnForce: true,
|
|
748
|
-
clearToken: () => localStorage2.clearToken()
|
|
749
|
-
});
|
|
750
|
-
} catch {
|
|
751
|
-
}
|
|
752
|
-
})();
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
instance.interceptors.request.use(
|
|
756
|
-
async (configReq) => {
|
|
757
|
-
const token = await localStorage2.getAccessToken();
|
|
758
|
-
if (token) {
|
|
759
|
-
configReq.headers["Authorization"] = "Bearer " + token;
|
|
760
|
-
}
|
|
761
|
-
return configReq;
|
|
762
|
-
},
|
|
763
|
-
(error) => Promise.reject(error)
|
|
764
|
-
);
|
|
765
|
-
instance.interceptors.response.use(
|
|
766
|
-
(response) => {
|
|
767
|
-
if (typeof window !== "undefined") {
|
|
768
|
-
const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
|
|
769
|
-
const onMaintenancePage = window.location.pathname === "/maintenance";
|
|
770
|
-
if (isMaint && onMaintenancePage) {
|
|
771
|
-
(async () => {
|
|
772
|
-
await clearMaintenanceAndExit(
|
|
773
|
-
() => localStorage2.getAccessToken(),
|
|
774
|
-
{
|
|
775
|
-
forceLogin: true,
|
|
776
|
-
clearTokenOnForce: true,
|
|
777
|
-
clearToken: () => localStorage2.clearToken()
|
|
778
|
-
}
|
|
779
|
-
);
|
|
780
|
-
})();
|
|
781
|
-
} else if (isMaint) {
|
|
782
|
-
window.localStorage.removeItem(MAINT_KEY);
|
|
783
|
-
window.localStorage.removeItem(MAINT_AT);
|
|
784
|
-
window.localStorage.removeItem(MAINT_LAST_PATH);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
return handleResponse(response);
|
|
788
|
-
},
|
|
789
|
-
async (error) => {
|
|
790
|
-
const status = error?.response?.status;
|
|
791
|
-
if (status === 503) {
|
|
792
|
-
if (typeof window !== "undefined") {
|
|
793
|
-
setMaintenanceFlags();
|
|
794
|
-
if (!hasRedirectedToMaintenance && window.location.pathname !== "/maintenance") {
|
|
795
|
-
hasRedirectedToMaintenance = true;
|
|
796
|
-
window.location.replace("/maintenance");
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
return Promise.reject({
|
|
800
|
-
code: 503,
|
|
801
|
-
message: "SERVICE_UNAVAILABLE",
|
|
802
|
-
original: error?.response?.data
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
const handleError = async (err) => {
|
|
806
|
-
if (!err.response) {
|
|
807
|
-
return err;
|
|
808
|
-
}
|
|
809
|
-
const { data } = err.response;
|
|
810
|
-
if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
|
|
811
|
-
await clearAuthToken();
|
|
812
|
-
}
|
|
813
|
-
return data;
|
|
814
|
-
};
|
|
815
|
-
const originalRequest = error.config;
|
|
816
|
-
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
|
817
|
-
error.response.data.code
|
|
818
|
-
)) {
|
|
819
|
-
if (isRefreshing) {
|
|
820
|
-
return new Promise(function(resolve, reject) {
|
|
821
|
-
failedQueue.push({ resolve, reject });
|
|
822
|
-
}).then((token) => {
|
|
823
|
-
originalRequest.headers["Authorization"] = "Bearer " + token;
|
|
824
|
-
return instance.request(originalRequest);
|
|
825
|
-
}).catch(async (err) => {
|
|
826
|
-
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
827
|
-
await clearAuthToken();
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
const browserSession = await sessionStorage.getBrowserSession();
|
|
832
|
-
const refreshToken = await localStorage2.getRefreshToken();
|
|
833
|
-
const accessTokenExp = await localStorage2.getAccessToken();
|
|
834
|
-
isRefreshing = true;
|
|
835
|
-
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
836
|
-
await clearAuthToken();
|
|
837
|
-
} else {
|
|
838
|
-
const payload = Object.fromEntries(
|
|
839
|
-
Object.entries({
|
|
840
|
-
refresh_token: refreshToken,
|
|
841
|
-
grant_type: "refresh_token",
|
|
842
|
-
client_id: config.config.clientId,
|
|
843
|
-
client_secret: config.config.clientSecret
|
|
844
|
-
}).filter(([_, value]) => !!value)
|
|
845
|
-
);
|
|
846
|
-
return new Promise(function(resolve) {
|
|
847
|
-
axios__default.default.post(
|
|
848
|
-
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
849
|
-
payload,
|
|
850
|
-
{
|
|
851
|
-
headers: {
|
|
852
|
-
"Content-Type": "multipart/form-data",
|
|
853
|
-
Authorization: `Bearer ${accessTokenExp}`
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
).then(async (res) => {
|
|
857
|
-
const data = res.data;
|
|
858
|
-
await localStorage2.setToken(data.access_token);
|
|
859
|
-
await localStorage2.setRefreshToken(data.refresh_token);
|
|
860
|
-
axios__default.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
861
|
-
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
862
|
-
processQueue(null, data.access_token);
|
|
863
|
-
resolve(instance.request(originalRequest));
|
|
864
|
-
}).catch(async (err) => {
|
|
865
|
-
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
|
866
|
-
await clearAuthToken();
|
|
867
|
-
}
|
|
868
|
-
if (err && err.response) {
|
|
869
|
-
const { error_code } = err.response?.data || {};
|
|
870
|
-
if (error_code === "AUTHEN_FAIL") {
|
|
871
|
-
await clearAuthToken();
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
processQueue(err, null);
|
|
875
|
-
}).finally(() => {
|
|
876
|
-
isRefreshing = false;
|
|
877
|
-
});
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
return Promise.reject(await handleError(error));
|
|
882
|
-
}
|
|
883
|
-
);
|
|
884
|
-
const handleResponse = (res) => {
|
|
885
|
-
if (res && res.data) {
|
|
886
|
-
return res.data;
|
|
887
|
-
}
|
|
888
|
-
return res;
|
|
889
|
-
};
|
|
890
|
-
const clearAuthToken = async () => {
|
|
891
|
-
await localStorage2.clearToken();
|
|
892
|
-
if (typeof window !== "undefined") {
|
|
893
|
-
window.location.href = `/login`;
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
function formatUrl(url, db2) {
|
|
897
|
-
return url + (db2 ? "?db=" + db2 : "");
|
|
898
|
-
}
|
|
899
|
-
const responseBody = (response) => response;
|
|
900
|
-
const requests = {
|
|
901
|
-
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
|
902
|
-
post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
|
|
903
|
-
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
|
904
|
-
responseType: "arraybuffer",
|
|
905
|
-
headers: {
|
|
906
|
-
"Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
|
|
907
|
-
Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
908
|
-
}
|
|
909
|
-
}).then(responseBody),
|
|
910
|
-
put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
|
|
911
|
-
patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
|
|
912
|
-
delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
|
|
913
|
-
};
|
|
914
|
-
return requests;
|
|
915
|
-
}
|
|
916
|
-
};
|
|
917
922
|
|
|
918
923
|
// src/environment/EnvStore.ts
|
|
919
924
|
var EnvStore = class {
|
|
@@ -4394,12 +4399,370 @@ var ViewService = {
|
|
|
4394
4399
|
};
|
|
4395
4400
|
var view_service_default = ViewService;
|
|
4396
4401
|
|
|
4397
|
-
// src/
|
|
4398
|
-
var
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4402
|
+
// src/hooks/auth/use-forgot-password.ts
|
|
4403
|
+
var useForgotPassword = () => {
|
|
4404
|
+
return reactQuery.useMutation({
|
|
4405
|
+
mutationFn: (email) => {
|
|
4406
|
+
return auth_service_default.forgotPassword(email);
|
|
4407
|
+
}
|
|
4408
|
+
});
|
|
4409
|
+
};
|
|
4410
|
+
var use_forgot_password_default = useForgotPassword;
|
|
4411
|
+
var useGetProvider = () => {
|
|
4412
|
+
return reactQuery.useMutation({
|
|
4413
|
+
mutationFn: (data) => {
|
|
4414
|
+
return auth_service_default.getProviders(data?.db);
|
|
4415
|
+
}
|
|
4416
|
+
});
|
|
4417
|
+
};
|
|
4418
|
+
var use_get_provider_default = useGetProvider;
|
|
4419
|
+
var useIsValidToken = () => {
|
|
4420
|
+
return reactQuery.useMutation({
|
|
4421
|
+
mutationFn: (token) => {
|
|
4422
|
+
return auth_service_default.isValidToken(token);
|
|
4423
|
+
}
|
|
4424
|
+
});
|
|
4425
|
+
};
|
|
4426
|
+
var use_isvalid_token_default = useIsValidToken;
|
|
4427
|
+
var useLoginCredential = () => {
|
|
4428
|
+
return reactQuery.useMutation({
|
|
4429
|
+
mutationFn: (data) => {
|
|
4430
|
+
return auth_service_default.login(data);
|
|
4431
|
+
}
|
|
4432
|
+
});
|
|
4433
|
+
};
|
|
4434
|
+
var use_login_credential_default = useLoginCredential;
|
|
4435
|
+
var useLoginSocial = () => {
|
|
4436
|
+
return reactQuery.useMutation({
|
|
4437
|
+
mutationFn: (data) => {
|
|
4438
|
+
return auth_service_default.loginSocial(data);
|
|
4439
|
+
}
|
|
4440
|
+
});
|
|
4441
|
+
};
|
|
4442
|
+
var use_login_socical_default = useLoginSocial;
|
|
4443
|
+
var useResetPassword = () => {
|
|
4444
|
+
return reactQuery.useMutation({
|
|
4445
|
+
mutationFn: (request) => {
|
|
4446
|
+
return auth_service_default.resetPassword(request.data, request.token);
|
|
4447
|
+
}
|
|
4448
|
+
});
|
|
4449
|
+
};
|
|
4450
|
+
var use_reset_password_default = useResetPassword;
|
|
4451
|
+
var useUpdatePassword = () => {
|
|
4452
|
+
return reactQuery.useMutation({
|
|
4453
|
+
mutationFn: (request) => {
|
|
4454
|
+
return auth_service_default.updatePassword(request.data, request.token);
|
|
4455
|
+
}
|
|
4456
|
+
});
|
|
4457
|
+
};
|
|
4458
|
+
var use_update_password_default = useUpdatePassword;
|
|
4459
|
+
var useField = (props) => {
|
|
4460
|
+
const [invisible, setInvisible] = React__default.default.useState(true);
|
|
4461
|
+
const [required, setRequired] = React__default.default.useState(false);
|
|
4462
|
+
const [readonly, setReadOnly] = React__default.default.useState(false);
|
|
4463
|
+
const {
|
|
4464
|
+
invisible: inv,
|
|
4465
|
+
required: req,
|
|
4466
|
+
readonly: rea,
|
|
4467
|
+
onchangeData,
|
|
4468
|
+
rootField,
|
|
4469
|
+
index,
|
|
4470
|
+
name
|
|
4471
|
+
} = props;
|
|
4472
|
+
const nameField = rootField ? `${rootField?.name}.${index}.${name}` : null;
|
|
4473
|
+
React.useEffect(() => {
|
|
4474
|
+
if (onchangeData && Object.keys(onchangeData).length > 0) {
|
|
4475
|
+
setRequired(
|
|
4476
|
+
typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
|
|
4477
|
+
);
|
|
4478
|
+
setInvisible(matchDomains(onchangeData, inv));
|
|
4479
|
+
setReadOnly(
|
|
4480
|
+
typeof req === "object" ? matchDomains(onchangeData, rea) : checkDomain(onchangeData, rea)
|
|
4481
|
+
);
|
|
4482
|
+
}
|
|
4483
|
+
}, [onchangeData]);
|
|
4484
|
+
return {
|
|
4485
|
+
invisible,
|
|
4486
|
+
required,
|
|
4487
|
+
readonly,
|
|
4488
|
+
nameField
|
|
4489
|
+
};
|
|
4490
|
+
};
|
|
4491
|
+
var use_field_default = useField;
|
|
4492
|
+
var useGetCompanyInfo = () => {
|
|
4493
|
+
return reactQuery.useMutation({
|
|
4494
|
+
mutationFn: (id) => company_service_default.getInfoCompany(id)
|
|
4495
|
+
});
|
|
4496
|
+
};
|
|
4497
|
+
var use_get_company_info_default = useGetCompanyInfo;
|
|
4498
|
+
var useGetCurrentCompany = () => {
|
|
4499
|
+
return reactQuery.useMutation({
|
|
4500
|
+
mutationFn: () => company_service_default.getCurrentCompany()
|
|
4501
|
+
});
|
|
4502
|
+
};
|
|
4503
|
+
var use_get_current_company_default = useGetCurrentCompany;
|
|
4504
|
+
var useChangeStatus = () => {
|
|
4505
|
+
return reactQuery.useMutation({
|
|
4506
|
+
mutationFn: ({ data }) => {
|
|
4507
|
+
return form_service_default.changeStatus({
|
|
4508
|
+
data
|
|
4509
|
+
});
|
|
4510
|
+
}
|
|
4511
|
+
});
|
|
4512
|
+
};
|
|
4513
|
+
var use_change_status_default = useChangeStatus;
|
|
4514
|
+
var useDeleteComment = () => {
|
|
4515
|
+
return reactQuery.useMutation({
|
|
4516
|
+
mutationFn: ({ data }) => form_service_default.deleteComment({
|
|
4517
|
+
data
|
|
4518
|
+
})
|
|
4519
|
+
});
|
|
4520
|
+
};
|
|
4521
|
+
var use_delete_comment_default = useDeleteComment;
|
|
4522
|
+
var useGetComment = ({ data, queryKey }) => {
|
|
4523
|
+
return reactQuery.useQuery({
|
|
4524
|
+
queryKey,
|
|
4525
|
+
queryFn: () => form_service_default.getComment({ data }).then((res) => {
|
|
4526
|
+
if (res) {
|
|
4527
|
+
return res;
|
|
4528
|
+
}
|
|
4529
|
+
}),
|
|
4530
|
+
enabled: !!data.thread_id && !isNaN(data.thread_id),
|
|
4531
|
+
refetchOnWindowFocus: false
|
|
4532
|
+
});
|
|
4533
|
+
};
|
|
4534
|
+
var use_get_comment_default = useGetComment;
|
|
4535
|
+
var useGetFormView = ({
|
|
4536
|
+
data,
|
|
4537
|
+
queryKey,
|
|
4538
|
+
enabled
|
|
4539
|
+
}) => {
|
|
4540
|
+
return reactQuery.useQuery({
|
|
4541
|
+
queryKey,
|
|
4542
|
+
queryFn: () => form_service_default.getFormView({ data }).then((res) => {
|
|
4543
|
+
if (res) {
|
|
4544
|
+
return res;
|
|
4545
|
+
}
|
|
4546
|
+
}),
|
|
4547
|
+
enabled,
|
|
4548
|
+
refetchOnWindowFocus: false
|
|
4549
|
+
});
|
|
4550
|
+
};
|
|
4551
|
+
var use_get_form_view_default = useGetFormView;
|
|
4552
|
+
var useGetImage = ({
|
|
4553
|
+
data,
|
|
4554
|
+
queryKey,
|
|
4555
|
+
src
|
|
4556
|
+
}) => {
|
|
4557
|
+
return reactQuery.useQuery({
|
|
4558
|
+
queryKey,
|
|
4559
|
+
queryFn: () => form_service_default.getImage({ data }).then((res) => {
|
|
4560
|
+
if (res) {
|
|
4561
|
+
return res;
|
|
4562
|
+
}
|
|
4563
|
+
}),
|
|
4564
|
+
enabled: !src && !isBase64File(src),
|
|
4565
|
+
refetchOnWindowFocus: false
|
|
4566
|
+
});
|
|
4567
|
+
};
|
|
4568
|
+
var use_get_image_default = useGetImage;
|
|
4569
|
+
var useSendComment = () => {
|
|
4570
|
+
return reactQuery.useMutation({
|
|
4571
|
+
mutationFn: ({ data }) => form_service_default.sentComment({
|
|
4572
|
+
data
|
|
4573
|
+
})
|
|
4574
|
+
});
|
|
4575
|
+
};
|
|
4576
|
+
var use_send_comment_default = useSendComment;
|
|
4577
|
+
var useUploadImage = () => {
|
|
4578
|
+
return reactQuery.useMutation({
|
|
4579
|
+
mutationFn: ({ data }) => form_service_default.uploadImage({
|
|
4580
|
+
data
|
|
4581
|
+
})
|
|
4582
|
+
});
|
|
4583
|
+
};
|
|
4584
|
+
var use_upload_image_default = useUploadImage;
|
|
4585
|
+
var useExportExcel = () => {
|
|
4586
|
+
return reactQuery.useMutation({
|
|
4587
|
+
mutationFn: ({
|
|
4588
|
+
model,
|
|
4589
|
+
domain,
|
|
4590
|
+
ids,
|
|
4591
|
+
fields,
|
|
4592
|
+
type,
|
|
4593
|
+
importCompat,
|
|
4594
|
+
context,
|
|
4595
|
+
groupby
|
|
4596
|
+
}) => excel_service_default.exportExcel({
|
|
4597
|
+
model,
|
|
4598
|
+
domain,
|
|
4599
|
+
ids,
|
|
4600
|
+
fields,
|
|
4601
|
+
type,
|
|
4602
|
+
importCompat,
|
|
4603
|
+
context,
|
|
4604
|
+
groupby
|
|
4605
|
+
})
|
|
4606
|
+
});
|
|
4607
|
+
};
|
|
4608
|
+
var use_export_excel_default = useExportExcel;
|
|
4609
|
+
var useGetFieldExport = () => {
|
|
4610
|
+
return reactQuery.useMutation({
|
|
4611
|
+
mutationFn: ({
|
|
4612
|
+
ids,
|
|
4613
|
+
model,
|
|
4614
|
+
isShow,
|
|
4615
|
+
parentField,
|
|
4616
|
+
fieldType,
|
|
4617
|
+
parentName,
|
|
4618
|
+
prefix,
|
|
4619
|
+
name,
|
|
4620
|
+
context,
|
|
4621
|
+
importCompat
|
|
4622
|
+
}) => excel_service_default.getFieldExport({
|
|
4623
|
+
ids,
|
|
4624
|
+
model,
|
|
4625
|
+
isShow,
|
|
4626
|
+
parentField,
|
|
4627
|
+
fieldType,
|
|
4628
|
+
parentName,
|
|
4629
|
+
prefix,
|
|
4630
|
+
name,
|
|
4631
|
+
context,
|
|
4632
|
+
importCompat
|
|
4633
|
+
})
|
|
4634
|
+
});
|
|
4635
|
+
};
|
|
4636
|
+
var use_get_field_export_default = useGetFieldExport;
|
|
4637
|
+
var useGetFileExcel = ({
|
|
4638
|
+
model,
|
|
4639
|
+
context
|
|
4640
|
+
}) => {
|
|
4641
|
+
return reactQuery.useQuery({
|
|
4642
|
+
queryKey: [],
|
|
4643
|
+
queryFn: () => excel_service_default.getFileExcel({
|
|
4644
|
+
model,
|
|
4645
|
+
context
|
|
4646
|
+
}).then((res) => {
|
|
4647
|
+
if (res) {
|
|
4648
|
+
return res;
|
|
4649
|
+
}
|
|
4650
|
+
return [];
|
|
4651
|
+
}),
|
|
4652
|
+
refetchOnWindowFocus: false
|
|
4653
|
+
});
|
|
4654
|
+
};
|
|
4655
|
+
var use_get_file_excel_default = useGetFileExcel;
|
|
4656
|
+
var useParsePreview = () => {
|
|
4657
|
+
return reactQuery.useMutation({
|
|
4658
|
+
mutationFn: ({
|
|
4659
|
+
id,
|
|
4660
|
+
selectedSheet,
|
|
4661
|
+
isHeader,
|
|
4662
|
+
context
|
|
4663
|
+
}) => excel_service_default.parsePreview({
|
|
4664
|
+
id,
|
|
4665
|
+
selectedSheet,
|
|
4666
|
+
isHeader,
|
|
4667
|
+
context
|
|
4668
|
+
})
|
|
4669
|
+
});
|
|
4670
|
+
};
|
|
4671
|
+
var use_parse_preview_default = useParsePreview;
|
|
4672
|
+
var useUploadFile = () => {
|
|
4673
|
+
return reactQuery.useMutation({
|
|
4674
|
+
mutationFn: ({ formData }) => excel_service_default.uploadFile({
|
|
4675
|
+
formData
|
|
4676
|
+
})
|
|
4677
|
+
});
|
|
4678
|
+
};
|
|
4679
|
+
var use_upload_file_default = useUploadFile;
|
|
4680
|
+
var useUploadIdFile = () => {
|
|
4681
|
+
return reactQuery.useMutation({
|
|
4682
|
+
mutationFn: ({ formData }) => excel_service_default.uploadIdFile({
|
|
4683
|
+
formData
|
|
4684
|
+
})
|
|
4685
|
+
});
|
|
4686
|
+
};
|
|
4687
|
+
var use_upload_id_file_default = useUploadIdFile;
|
|
4688
|
+
var useExecuteImport = () => {
|
|
4689
|
+
return reactQuery.useMutation({
|
|
4690
|
+
mutationFn: ({
|
|
4691
|
+
fields,
|
|
4692
|
+
columns,
|
|
4693
|
+
idFile,
|
|
4694
|
+
options,
|
|
4695
|
+
dryrun,
|
|
4696
|
+
context
|
|
4697
|
+
}) => excel_service_default.executeImport({
|
|
4698
|
+
fields,
|
|
4699
|
+
columns,
|
|
4700
|
+
idFile,
|
|
4701
|
+
options,
|
|
4702
|
+
dryrun,
|
|
4703
|
+
context
|
|
4704
|
+
})
|
|
4705
|
+
});
|
|
4706
|
+
};
|
|
4707
|
+
var uss_execute_import_default = useExecuteImport;
|
|
4708
|
+
var useDelete = () => {
|
|
4709
|
+
return reactQuery.useMutation({
|
|
4710
|
+
mutationFn: ({ ids, model }) => model_service_default.delete({ ids, model })
|
|
4711
|
+
});
|
|
4712
|
+
};
|
|
4713
|
+
var use_delete_default = useDelete;
|
|
4714
|
+
var useGetAll = ({ data, queryKey, viewResponse }) => {
|
|
4715
|
+
return reactQuery.useQuery({
|
|
4716
|
+
queryKey,
|
|
4717
|
+
queryFn: () => model_service_default.getAll({ data }).then((res) => {
|
|
4718
|
+
if (res) {
|
|
4719
|
+
return res;
|
|
4720
|
+
}
|
|
4721
|
+
}),
|
|
4722
|
+
enabled: !!data.specification && !!data.model && !!data.domain && !!viewResponse,
|
|
4723
|
+
refetchOnWindowFocus: false
|
|
4724
|
+
// placeholderData: keepPreviousData,
|
|
4725
|
+
});
|
|
4726
|
+
};
|
|
4727
|
+
var use_get_all_default = useGetAll;
|
|
4728
|
+
var useGetDetail = () => {
|
|
4729
|
+
return reactQuery.useMutation({
|
|
4730
|
+
mutationFn: ({
|
|
4731
|
+
model,
|
|
4732
|
+
ids,
|
|
4733
|
+
specification,
|
|
4734
|
+
context
|
|
4735
|
+
}) => model_service_default.getDetail({
|
|
4736
|
+
model,
|
|
4737
|
+
ids,
|
|
4738
|
+
specification,
|
|
4739
|
+
context
|
|
4740
|
+
})
|
|
4741
|
+
});
|
|
4742
|
+
};
|
|
4743
|
+
var use_get_detail_default = useGetDetail;
|
|
4744
|
+
var useGetFieldOnChange = ({ model }) => {
|
|
4745
|
+
return reactQuery.useQuery({
|
|
4746
|
+
queryKey: [`field-onchange-${model}`, model],
|
|
4747
|
+
queryFn: () => model_service_default.getListFieldsOnchange({
|
|
4748
|
+
model
|
|
4749
|
+
}).then((res) => {
|
|
4750
|
+
if (res) {
|
|
4751
|
+
return res;
|
|
4752
|
+
}
|
|
4753
|
+
}),
|
|
4754
|
+
refetchOnWindowFocus: false,
|
|
4755
|
+
staleTime: Infinity
|
|
4756
|
+
});
|
|
4757
|
+
};
|
|
4758
|
+
var use_get_field_onchange_default = useGetFieldOnChange;
|
|
4759
|
+
|
|
4760
|
+
// src/models/base-model/index.ts
|
|
4761
|
+
var BaseModel = class {
|
|
4762
|
+
name;
|
|
4763
|
+
view;
|
|
4764
|
+
actContext;
|
|
4765
|
+
fields;
|
|
4403
4766
|
constructor(init) {
|
|
4404
4767
|
this.name = init.name;
|
|
4405
4768
|
this.view = init.view;
|
|
@@ -4510,7 +4873,88 @@ var BaseModel = class {
|
|
|
4510
4873
|
}
|
|
4511
4874
|
};
|
|
4512
4875
|
var base_model_default = BaseModel;
|
|
4513
|
-
|
|
4876
|
+
|
|
4877
|
+
// src/hooks/model/use-model.ts
|
|
4878
|
+
var useModel = () => {
|
|
4879
|
+
const initModel = (modelData) => {
|
|
4880
|
+
switch (modelData?.name) {
|
|
4881
|
+
default:
|
|
4882
|
+
return new base_model_default(modelData);
|
|
4883
|
+
}
|
|
4884
|
+
};
|
|
4885
|
+
return {
|
|
4886
|
+
initModel
|
|
4887
|
+
};
|
|
4888
|
+
};
|
|
4889
|
+
var use_model_default = useModel;
|
|
4890
|
+
|
|
4891
|
+
// src/hooks/model/use-odoo-data-transform.ts
|
|
4892
|
+
var useOdooDataTransform = () => {
|
|
4893
|
+
return {
|
|
4894
|
+
toDataJS: model_service_default.toDataJS,
|
|
4895
|
+
parseORM: model_service_default.parseORMOdoo
|
|
4896
|
+
};
|
|
4897
|
+
};
|
|
4898
|
+
var use_odoo_data_transform_default = useOdooDataTransform;
|
|
4899
|
+
var useOnChangeForm = () => {
|
|
4900
|
+
return reactQuery.useMutation({
|
|
4901
|
+
mutationFn: ({
|
|
4902
|
+
ids,
|
|
4903
|
+
model,
|
|
4904
|
+
specification,
|
|
4905
|
+
context,
|
|
4906
|
+
object,
|
|
4907
|
+
fieldChange
|
|
4908
|
+
}) => model_service_default.onChange({
|
|
4909
|
+
ids,
|
|
4910
|
+
model,
|
|
4911
|
+
specification,
|
|
4912
|
+
context,
|
|
4913
|
+
object,
|
|
4914
|
+
fieldChange
|
|
4915
|
+
})
|
|
4916
|
+
});
|
|
4917
|
+
};
|
|
4918
|
+
var use_onchange_form_default = useOnChangeForm;
|
|
4919
|
+
var useSave = () => {
|
|
4920
|
+
return reactQuery.useMutation({
|
|
4921
|
+
mutationFn: ({
|
|
4922
|
+
ids,
|
|
4923
|
+
model,
|
|
4924
|
+
data,
|
|
4925
|
+
specification,
|
|
4926
|
+
context
|
|
4927
|
+
}) => model_service_default.save({ ids, model, data, specification, context })
|
|
4928
|
+
});
|
|
4929
|
+
};
|
|
4930
|
+
var use_save_default = useSave;
|
|
4931
|
+
var useGetProfile = () => {
|
|
4932
|
+
return reactQuery.useMutation({
|
|
4933
|
+
mutationFn: () => user_service_default.getProfile()
|
|
4934
|
+
});
|
|
4935
|
+
};
|
|
4936
|
+
var use_get_profile_default = useGetProfile;
|
|
4937
|
+
var useGetUser = () => {
|
|
4938
|
+
return reactQuery.useMutation({
|
|
4939
|
+
mutationFn: ({ id, context }) => user_service_default.getUser({
|
|
4940
|
+
id,
|
|
4941
|
+
context
|
|
4942
|
+
})
|
|
4943
|
+
});
|
|
4944
|
+
};
|
|
4945
|
+
var use_get_user_default = useGetUser;
|
|
4946
|
+
var useSwitchLocale = () => {
|
|
4947
|
+
return reactQuery.useMutation({
|
|
4948
|
+
mutationFn: ({ data }) => {
|
|
4949
|
+
return user_service_default.switchUserLocale({
|
|
4950
|
+
id: data.id,
|
|
4951
|
+
values: data.values
|
|
4952
|
+
});
|
|
4953
|
+
}
|
|
4954
|
+
});
|
|
4955
|
+
};
|
|
4956
|
+
var use_switch_locale_default = useSwitchLocale;
|
|
4957
|
+
var useButton = () => {
|
|
4514
4958
|
return reactQuery.useMutation({
|
|
4515
4959
|
mutationFn: ({
|
|
4516
4960
|
model,
|
|
@@ -4522,11 +4966,161 @@ function useButton() {
|
|
|
4522
4966
|
ids,
|
|
4523
4967
|
context,
|
|
4524
4968
|
method
|
|
4969
|
+
}),
|
|
4970
|
+
onSuccess: (response) => {
|
|
4971
|
+
return response;
|
|
4972
|
+
}
|
|
4973
|
+
});
|
|
4974
|
+
};
|
|
4975
|
+
var use_button_default = useButton;
|
|
4976
|
+
var useDuplicateRecord = () => {
|
|
4977
|
+
return reactQuery.useMutation({
|
|
4978
|
+
mutationFn: ({
|
|
4979
|
+
id,
|
|
4980
|
+
model,
|
|
4981
|
+
context
|
|
4982
|
+
}) => action_service_default.duplicateRecord({
|
|
4983
|
+
id,
|
|
4984
|
+
model,
|
|
4985
|
+
context
|
|
4525
4986
|
})
|
|
4526
4987
|
});
|
|
4527
|
-
}
|
|
4988
|
+
};
|
|
4989
|
+
var use_duplicate_record_default = useDuplicateRecord;
|
|
4990
|
+
var useGetListData = (listDataProps, queryKey, enabled) => {
|
|
4991
|
+
return reactQuery.useQuery({
|
|
4992
|
+
queryKey,
|
|
4993
|
+
queryFn: () => model_service_default.getAll({ data: listDataProps }).then((res) => {
|
|
4994
|
+
if (res) {
|
|
4995
|
+
return res;
|
|
4996
|
+
}
|
|
4997
|
+
return [];
|
|
4998
|
+
}),
|
|
4999
|
+
enabled,
|
|
5000
|
+
refetchOnWindowFocus: false,
|
|
5001
|
+
staleTime: 0
|
|
5002
|
+
});
|
|
5003
|
+
};
|
|
5004
|
+
var use_get_list_data_default = useGetListData;
|
|
5005
|
+
var useGetMenu = ({ context, enabled, queryKey }) => {
|
|
5006
|
+
return reactQuery.useQuery({
|
|
5007
|
+
queryKey,
|
|
5008
|
+
queryFn: async () => {
|
|
5009
|
+
const res = await view_service_default.getMenu(context);
|
|
5010
|
+
if (res?.records && Array.isArray(res.records) && res.records.length > 0) {
|
|
5011
|
+
return res.records;
|
|
5012
|
+
}
|
|
5013
|
+
return [];
|
|
5014
|
+
},
|
|
5015
|
+
refetchOnWindowFocus: false,
|
|
5016
|
+
staleTime: Infinity,
|
|
5017
|
+
enabled
|
|
5018
|
+
});
|
|
5019
|
+
};
|
|
5020
|
+
var use_get_menu_default = useGetMenu;
|
|
5021
|
+
var useGetSelection = ({
|
|
5022
|
+
data,
|
|
5023
|
+
queryKey,
|
|
5024
|
+
enabled
|
|
5025
|
+
}) => {
|
|
5026
|
+
return reactQuery.useQuery({
|
|
5027
|
+
queryKey,
|
|
5028
|
+
queryFn: () => view_service_default.getSelectionItem({ data }),
|
|
5029
|
+
enabled,
|
|
5030
|
+
refetchOnWindowFocus: false
|
|
5031
|
+
});
|
|
5032
|
+
};
|
|
5033
|
+
var use_get_selection_default = useGetSelection;
|
|
5034
|
+
var useGetView = (viewParams, actData) => {
|
|
5035
|
+
return reactQuery.useQuery({
|
|
5036
|
+
queryKey: ["get_view_by_action" /* GET_VIEW_BY_ACTION */, viewParams],
|
|
5037
|
+
queryFn: () => view_service_default.getView(viewParams),
|
|
5038
|
+
enabled: !!actData,
|
|
5039
|
+
refetchOnWindowFocus: false,
|
|
5040
|
+
staleTime: Infinity
|
|
5041
|
+
});
|
|
5042
|
+
};
|
|
5043
|
+
var use_get_view_default = useGetView;
|
|
5044
|
+
var useLoadAction = ({
|
|
5045
|
+
idAction,
|
|
5046
|
+
context
|
|
5047
|
+
}) => {
|
|
5048
|
+
return reactQuery.useQuery({
|
|
5049
|
+
queryKey: ["load_action", idAction],
|
|
5050
|
+
queryFn: () => action_service_default.loadAction({
|
|
5051
|
+
idAction,
|
|
5052
|
+
context
|
|
5053
|
+
}),
|
|
5054
|
+
enabled: false,
|
|
5055
|
+
staleTime: Infinity,
|
|
5056
|
+
gcTime: Infinity
|
|
5057
|
+
});
|
|
5058
|
+
};
|
|
5059
|
+
var use_load_action_default = useLoadAction;
|
|
5060
|
+
var usePrint = () => {
|
|
5061
|
+
return reactQuery.useMutation({
|
|
5062
|
+
mutationFn: ({ id, report, db }) => action_service_default.print({
|
|
5063
|
+
id,
|
|
5064
|
+
report,
|
|
5065
|
+
db
|
|
5066
|
+
})
|
|
5067
|
+
});
|
|
5068
|
+
};
|
|
5069
|
+
var use_print_default = usePrint;
|
|
5070
|
+
var useRemoveRow = () => {
|
|
5071
|
+
return reactQuery.useMutation({
|
|
5072
|
+
mutationFn: ({
|
|
5073
|
+
model,
|
|
5074
|
+
ids,
|
|
5075
|
+
context
|
|
5076
|
+
}) => action_service_default.removeRows({
|
|
5077
|
+
model,
|
|
5078
|
+
ids,
|
|
5079
|
+
context
|
|
5080
|
+
})
|
|
5081
|
+
});
|
|
5082
|
+
};
|
|
5083
|
+
var use_remove_row_default = useRemoveRow;
|
|
5084
|
+
var useRunAction = ({ idAction, context }) => {
|
|
5085
|
+
return reactQuery.useQuery({
|
|
5086
|
+
queryKey: ["run_action", idAction],
|
|
5087
|
+
queryFn: () => action_service_default.runAction({
|
|
5088
|
+
idAction,
|
|
5089
|
+
context
|
|
5090
|
+
}),
|
|
5091
|
+
enabled: false,
|
|
5092
|
+
staleTime: Infinity,
|
|
5093
|
+
gcTime: Infinity
|
|
5094
|
+
});
|
|
5095
|
+
};
|
|
5096
|
+
var use_run_action_default = useRunAction;
|
|
5097
|
+
|
|
5098
|
+
// src/models/company-model/index.ts
|
|
5099
|
+
var CompanyModel = class extends base_model_default {
|
|
5100
|
+
constructor(init) {
|
|
5101
|
+
super(init);
|
|
5102
|
+
}
|
|
5103
|
+
async getCurrentCompany() {
|
|
5104
|
+
return await company_service_default.getCurrentCompany();
|
|
5105
|
+
}
|
|
5106
|
+
async getUserCompany(id) {
|
|
5107
|
+
return await company_service_default.getInfoCompany(id);
|
|
5108
|
+
}
|
|
5109
|
+
};
|
|
5110
|
+
var company_model_default = CompanyModel;
|
|
5111
|
+
|
|
5112
|
+
// src/models/user-model/index.ts
|
|
5113
|
+
var UserModel = class extends base_model_default {
|
|
5114
|
+
constructor(init) {
|
|
5115
|
+
super(init);
|
|
5116
|
+
}
|
|
5117
|
+
async getProfile() {
|
|
5118
|
+
return await user_service_default.getProfile();
|
|
5119
|
+
}
|
|
5120
|
+
};
|
|
5121
|
+
var user_model_default = UserModel;
|
|
4528
5122
|
var ReactQueryProvider = ({ children }) => {
|
|
4529
|
-
const [queryClient] =
|
|
5123
|
+
const [queryClient] = React.useState(
|
|
4530
5124
|
() => new reactQuery.QueryClient({
|
|
4531
5125
|
defaultOptions: {
|
|
4532
5126
|
queries: {
|
|
@@ -4548,8 +5142,8 @@ var MainProvider = ({ children }) => {
|
|
|
4548
5142
|
};
|
|
4549
5143
|
var VersionGate = ({ children }) => {
|
|
4550
5144
|
const queryClient = reactQuery.useQueryClient();
|
|
4551
|
-
const [ready, setReady] =
|
|
4552
|
-
|
|
5145
|
+
const [ready, setReady] = React.useState(false);
|
|
5146
|
+
React.useEffect(() => {
|
|
4553
5147
|
const clearVersion = () => {
|
|
4554
5148
|
queryClient.clear();
|
|
4555
5149
|
localStorage.removeItem("__api_version__");
|
|
@@ -4579,31 +5173,6 @@ var VersionGate = ({ children }) => {
|
|
|
4579
5173
|
return ready ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) : null;
|
|
4580
5174
|
};
|
|
4581
5175
|
|
|
4582
|
-
// src/models/company-model/index.ts
|
|
4583
|
-
var CompanyModel = class extends base_model_default {
|
|
4584
|
-
constructor(init) {
|
|
4585
|
-
super(init);
|
|
4586
|
-
}
|
|
4587
|
-
async getCurrentCompany() {
|
|
4588
|
-
return await company_service_default.getCurrentCompany();
|
|
4589
|
-
}
|
|
4590
|
-
async getUserCompany(id) {
|
|
4591
|
-
return await company_service_default.getInfoCompany(id);
|
|
4592
|
-
}
|
|
4593
|
-
};
|
|
4594
|
-
var company_model_default = CompanyModel;
|
|
4595
|
-
|
|
4596
|
-
// src/models/user-model/index.ts
|
|
4597
|
-
var UserModel = class extends base_model_default {
|
|
4598
|
-
constructor(init) {
|
|
4599
|
-
super(init);
|
|
4600
|
-
}
|
|
4601
|
-
async getProfile() {
|
|
4602
|
-
return await user_service_default.getProfile();
|
|
4603
|
-
}
|
|
4604
|
-
};
|
|
4605
|
-
var user_model_default = UserModel;
|
|
4606
|
-
|
|
4607
5176
|
exports.ActionService = action_service_default;
|
|
4608
5177
|
exports.AuthService = auth_service_default;
|
|
4609
5178
|
exports.BaseModel = base_model_default;
|
|
@@ -4710,5 +5279,49 @@ exports.toQueryString = toQueryString;
|
|
|
4710
5279
|
exports.updateSearchMap = updateSearchMap;
|
|
4711
5280
|
exports.useAppDispatch = useAppDispatch;
|
|
4712
5281
|
exports.useAppSelector = useAppSelector;
|
|
4713
|
-
exports.useButton =
|
|
5282
|
+
exports.useButton = use_button_default;
|
|
5283
|
+
exports.useChangeStatus = use_change_status_default;
|
|
5284
|
+
exports.useDelete = use_delete_default;
|
|
5285
|
+
exports.useDeleteComment = use_delete_comment_default;
|
|
5286
|
+
exports.useDuplicateRecord = use_duplicate_record_default;
|
|
5287
|
+
exports.useExecuteImport = uss_execute_import_default;
|
|
5288
|
+
exports.useExportExcel = use_export_excel_default;
|
|
5289
|
+
exports.useField = use_field_default;
|
|
5290
|
+
exports.useForgotPassword = use_forgot_password_default;
|
|
5291
|
+
exports.useGetAll = use_get_all_default;
|
|
5292
|
+
exports.useGetComment = use_get_comment_default;
|
|
5293
|
+
exports.useGetCompanyInfo = use_get_company_info_default;
|
|
5294
|
+
exports.useGetCurrentCompany = use_get_current_company_default;
|
|
5295
|
+
exports.useGetDetail = use_get_detail_default;
|
|
5296
|
+
exports.useGetFieldExport = use_get_field_export_default;
|
|
5297
|
+
exports.useGetFieldOnChange = use_get_field_onchange_default;
|
|
5298
|
+
exports.useGetFileExcel = use_get_file_excel_default;
|
|
5299
|
+
exports.useGetFormView = use_get_form_view_default;
|
|
5300
|
+
exports.useGetImage = use_get_image_default;
|
|
5301
|
+
exports.useGetListData = use_get_list_data_default;
|
|
5302
|
+
exports.useGetMenu = use_get_menu_default;
|
|
5303
|
+
exports.useGetProfile = use_get_profile_default;
|
|
5304
|
+
exports.useGetProvider = use_get_provider_default;
|
|
5305
|
+
exports.useGetSelection = use_get_selection_default;
|
|
5306
|
+
exports.useGetUser = use_get_user_default;
|
|
5307
|
+
exports.useGetView = use_get_view_default;
|
|
5308
|
+
exports.useIsValidToken = use_isvalid_token_default;
|
|
5309
|
+
exports.useLoadAction = use_load_action_default;
|
|
5310
|
+
exports.useLoginCredential = use_login_credential_default;
|
|
5311
|
+
exports.useLoginSocial = use_login_socical_default;
|
|
5312
|
+
exports.useModel = use_model_default;
|
|
5313
|
+
exports.useOdooDataTransform = use_odoo_data_transform_default;
|
|
5314
|
+
exports.useOnChangeForm = use_onchange_form_default;
|
|
5315
|
+
exports.useParsePreview = use_parse_preview_default;
|
|
5316
|
+
exports.usePrint = use_print_default;
|
|
5317
|
+
exports.useRemoveRow = use_remove_row_default;
|
|
5318
|
+
exports.useResetPassword = use_reset_password_default;
|
|
5319
|
+
exports.useRunAction = use_run_action_default;
|
|
5320
|
+
exports.useSave = use_save_default;
|
|
5321
|
+
exports.useSendComment = use_send_comment_default;
|
|
5322
|
+
exports.useSwitchLocale = use_switch_locale_default;
|
|
4714
5323
|
exports.useTabModel = useTabModel;
|
|
5324
|
+
exports.useUpdatePassword = use_update_password_default;
|
|
5325
|
+
exports.useUploadFile = use_upload_file_default;
|
|
5326
|
+
exports.useUploadIdFile = use_upload_id_file_default;
|
|
5327
|
+
exports.useUploadImage = use_upload_image_default;
|