@fctc/interface-logic 1.10.8 → 1.10.9

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/services.js CHANGED
@@ -30,18 +30,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/services.ts
31
31
  var services_exports = {};
32
32
  __export(services_exports, {
33
- ActionService: () => action_service_default,
34
- AuthService: () => auth_service_default,
35
- CompanyService: () => company_service_default,
36
- ExcelService: () => excel_service_default,
37
- FormService: () => form_service_default,
38
- KanbanService: () => kanban_service_default,
39
- ModelService: () => model_service_default,
40
- UserService: () => user_service_default,
41
- ViewService: () => view_service_default
33
+ useActionService: () => useActionService,
34
+ useAuthService: () => useAuthService,
35
+ useCompanyService: () => useCompanyService,
36
+ useExcelService: () => useExcelService,
37
+ useFormService: () => useFormService,
38
+ useKanbanService: () => useKanbanService,
39
+ useModelService: () => useModelService,
40
+ useUserService: () => useUserService,
41
+ useViewService: () => useViewService
42
42
  });
43
43
  module.exports = __toCommonJS(services_exports);
44
44
 
45
+ // src/services/action-service/index.ts
46
+ var import_react5 = require("react");
47
+
45
48
  // src/constants/api/uri-constant.ts
46
49
  var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
47
50
  UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
@@ -72,9 +75,6 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
72
75
  return UriConstants2;
73
76
  })(UriConstants || {});
74
77
 
75
- // src/configs/axios-client.ts
76
- var import_axios = __toESM(require("axios"));
77
-
78
78
  // src/utils/format.ts
79
79
  var import_moment = __toESM(require("moment"));
80
80
 
@@ -2191,880 +2191,1443 @@ var toQueryString = (params) => {
2191
2191
  (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2192
2192
  ).join("&");
2193
2193
  };
2194
- var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2195
- if (!originalRequest.data) return originalRequest.data;
2196
- if (typeof originalRequest.data === "string") {
2197
- try {
2198
- const parsedData = JSON.parse(originalRequest.data);
2199
- if (parsedData.with_context && typeof parsedData.with_context === "object") {
2200
- parsedData.with_context.token = newAccessToken;
2201
- }
2202
- return JSON.stringify(parsedData);
2203
- } catch (e) {
2204
- console.warn("Failed to parse originalRequest.data", e);
2205
- return originalRequest.data;
2194
+
2195
+ // src/provider/react-query-provider.tsx
2196
+ var import_react_query = require("@tanstack/react-query");
2197
+ var import_jsx_runtime = require("react/jsx-runtime");
2198
+
2199
+ // src/provider/redux-provider.tsx
2200
+ var import_react_redux2 = require("react-redux");
2201
+
2202
+ // src/store/index.ts
2203
+ var import_react_redux = require("react-redux");
2204
+
2205
+ // src/store/reducers/breadcrums-slice/index.ts
2206
+ var import_toolkit = require("@reduxjs/toolkit");
2207
+ var initialState = {
2208
+ breadCrumbs: []
2209
+ };
2210
+ var breadcrumbsSlice = (0, import_toolkit.createSlice)({
2211
+ name: "breadcrumbs",
2212
+ initialState,
2213
+ reducers: {
2214
+ setBreadCrumbs: (state, action) => {
2215
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
2206
2216
  }
2207
2217
  }
2208
- if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2209
- originalRequest.data.with_context.token = newAccessToken;
2218
+ });
2219
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
2220
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
2221
+
2222
+ // src/store/reducers/env-slice/index.ts
2223
+ var import_toolkit2 = require("@reduxjs/toolkit");
2224
+ var initialState2 = {
2225
+ baseUrl: "",
2226
+ companies: [],
2227
+ user: {},
2228
+ db: "",
2229
+ refreshTokenEndpoint: "",
2230
+ config: null,
2231
+ envFile: null,
2232
+ requests: null,
2233
+ defaultCompany: {
2234
+ id: null,
2235
+ logo: "",
2236
+ secondary_color: "",
2237
+ primary_color: ""
2238
+ },
2239
+ context: {
2240
+ uid: null,
2241
+ allowed_company_ids: [],
2242
+ lang: "vi_VN",
2243
+ tz: "Asia/Saigon"
2210
2244
  }
2211
- return originalRequest.data;
2212
2245
  };
2246
+ var envSlice = (0, import_toolkit2.createSlice)({
2247
+ name: "env",
2248
+ initialState: initialState2,
2249
+ reducers: {
2250
+ setEnv: (state, action) => {
2251
+ Object.assign(state, action.payload);
2252
+ },
2253
+ setUid: (state, action) => {
2254
+ state.context.uid = action.payload;
2255
+ },
2256
+ setAllowCompanies: (state, action) => {
2257
+ state.context.allowed_company_ids = action.payload;
2258
+ },
2259
+ setCompanies: (state, action) => {
2260
+ state.companies = action.payload;
2261
+ },
2262
+ setDefaultCompany: (state, action) => {
2263
+ state.defaultCompany = action.payload;
2264
+ },
2265
+ setLang: (state, action) => {
2266
+ state.context.lang = action.payload;
2267
+ },
2268
+ setUser: (state, action) => {
2269
+ state.user = action.payload;
2270
+ },
2271
+ setConfig: (state, action) => {
2272
+ state.config = action.payload;
2273
+ },
2274
+ setEnvFile: (state, action) => {
2275
+ state.envFile = action.payload;
2276
+ }
2277
+ }
2278
+ });
2279
+ var {
2280
+ setEnv,
2281
+ setUid,
2282
+ setLang,
2283
+ setAllowCompanies,
2284
+ setCompanies,
2285
+ setDefaultCompany,
2286
+ setUser,
2287
+ setConfig,
2288
+ setEnvFile
2289
+ } = envSlice.actions;
2290
+ var env_slice_default = envSlice.reducer;
2213
2291
 
2214
- // src/utils/storage/local-storage.ts
2215
- var localStorageUtils = () => {
2216
- const setToken = async (access_token) => {
2217
- localStorage.setItem("accessToken", access_token);
2218
- };
2219
- const setRefreshToken = async (refresh_token) => {
2220
- localStorage.setItem("refreshToken", refresh_token);
2221
- };
2222
- const getAccessToken = async () => {
2223
- return localStorage.getItem("accessToken");
2224
- };
2225
- const getRefreshToken = async () => {
2226
- return localStorage.getItem("refreshToken");
2227
- };
2228
- const clearToken = async () => {
2229
- localStorage.removeItem("accessToken");
2230
- localStorage.removeItem("refreshToken");
2231
- };
2232
- return {
2233
- setToken,
2234
- setRefreshToken,
2235
- getAccessToken,
2236
- getRefreshToken,
2237
- clearToken
2238
- };
2292
+ // src/store/reducers/excel-slice/index.ts
2293
+ var import_toolkit3 = require("@reduxjs/toolkit");
2294
+ var initialState3 = {
2295
+ dataParse: null,
2296
+ idFile: null,
2297
+ isFileLoaded: false,
2298
+ loadingImport: false,
2299
+ selectedFile: null,
2300
+ errorData: null
2239
2301
  };
2302
+ var excelSlice = (0, import_toolkit3.createSlice)({
2303
+ name: "excel",
2304
+ initialState: initialState3,
2305
+ reducers: {
2306
+ setDataParse: (state, action) => {
2307
+ state.dataParse = action.payload;
2308
+ },
2309
+ setIdFile: (state, action) => {
2310
+ state.idFile = action.payload;
2311
+ },
2312
+ setIsFileLoaded: (state, action) => {
2313
+ state.isFileLoaded = action.payload;
2314
+ },
2315
+ setLoadingImport: (state, action) => {
2316
+ state.loadingImport = action.payload;
2317
+ },
2318
+ setSelectedFile: (state, action) => {
2319
+ state.selectedFile = action.payload;
2320
+ },
2321
+ setErrorData: (state, action) => {
2322
+ state.errorData = action.payload;
2323
+ }
2324
+ }
2325
+ });
2326
+ var {
2327
+ setDataParse,
2328
+ setIdFile,
2329
+ setIsFileLoaded,
2330
+ setLoadingImport,
2331
+ setSelectedFile,
2332
+ setErrorData
2333
+ } = excelSlice.actions;
2334
+ var excel_slice_default = excelSlice.reducer;
2240
2335
 
2241
- // src/utils/storage/session-storage.ts
2242
- var sessionStorageUtils = () => {
2243
- const getBrowserSession = async () => {
2244
- return sessionStorage.getItem("browserSession");
2245
- };
2246
- return {
2247
- getBrowserSession
2248
- };
2336
+ // src/store/reducers/form-slice/index.ts
2337
+ var import_toolkit4 = require("@reduxjs/toolkit");
2338
+ var initialState4 = {
2339
+ viewDataStore: {},
2340
+ isShowingModalDetail: false,
2341
+ isShowModalTranslate: false,
2342
+ formSubmitComponent: {},
2343
+ fieldTranslation: null,
2344
+ listSubject: {},
2345
+ dataUser: {}
2249
2346
  };
2347
+ var formSlice = (0, import_toolkit4.createSlice)({
2348
+ name: "form",
2349
+ initialState: initialState4,
2350
+ reducers: {
2351
+ setViewDataStore: (state, action) => {
2352
+ state.viewDataStore = action.payload;
2353
+ },
2354
+ setIsShowingModalDetail: (state, action) => {
2355
+ state.isShowingModalDetail = action.payload;
2356
+ },
2357
+ setIsShowModalTranslate: (state, action) => {
2358
+ state.isShowModalTranslate = action.payload;
2359
+ },
2360
+ setFormSubmitComponent: (state, action) => {
2361
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
2362
+ },
2363
+ setFieldTranslate: (state, action) => {
2364
+ state.fieldTranslation = action.payload;
2365
+ },
2366
+ setListSubject: (state, action) => {
2367
+ state.listSubject = action.payload;
2368
+ },
2369
+ setDataUser: (state, action) => {
2370
+ state.dataUser = action.payload;
2371
+ }
2372
+ }
2373
+ });
2374
+ var {
2375
+ setViewDataStore,
2376
+ setIsShowingModalDetail,
2377
+ setIsShowModalTranslate,
2378
+ setFormSubmitComponent,
2379
+ setFieldTranslate,
2380
+ setListSubject,
2381
+ setDataUser
2382
+ } = formSlice.actions;
2383
+ var form_slice_default = formSlice.reducer;
2250
2384
 
2251
- // src/configs/axios-client.ts
2252
- var axiosClient = {
2253
- init(config) {
2254
- const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2255
- const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2256
- const db = config?.db;
2257
- let isRefreshing = false;
2258
- let failedQueue = [];
2259
- const processQueue = (error, token = null) => {
2260
- failedQueue?.forEach((prom) => {
2261
- if (error) {
2262
- prom.reject(error);
2263
- } else {
2264
- prom.resolve(token);
2265
- }
2266
- });
2267
- failedQueue = [];
2268
- };
2269
- const instance = import_axios.default.create({
2270
- adapter: import_axios.default.defaults.adapter,
2271
- baseURL: config.baseUrl,
2272
- timeout: 5e4,
2273
- paramsSerializer: (params) => new URLSearchParams(params).toString()
2274
- });
2275
- instance.interceptors.request.use(async (config2) => {
2276
- const { useRefreshToken, useActionToken, actionToken } = config2;
2277
- if (useActionToken && actionToken) {
2278
- config2.headers["Action-Token"] = actionToken;
2279
- }
2280
- const getToken = useRefreshToken ? localStorage2.getRefreshToken : localStorage2.getAccessToken;
2281
- const token = await getToken?.();
2282
- if (token) config2.headers["Authorization"] = `Bearer ${token}`;
2283
- return config2;
2284
- }, Promise.reject);
2285
- instance.interceptors.response.use(
2286
- (response) => {
2287
- return handleResponse(response);
2288
- },
2289
- async (error) => {
2290
- const handleError3 = async (error2) => {
2291
- if (!error2.response) {
2292
- return error2;
2293
- }
2294
- const { data } = error2.response;
2295
- if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
2296
- await clearAuthToken();
2297
- }
2298
- return data;
2299
- };
2300
- const originalRequest = error.config;
2301
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2302
- error.response.data.code
2303
- )) {
2304
- if (isRefreshing) {
2305
- return new Promise(function(resolve, reject) {
2306
- failedQueue.push({ resolve, reject });
2307
- }).then((token) => {
2308
- originalRequest.headers["Authorization"] = "Bearer " + token;
2309
- originalRequest.data = updateTokenParamInOriginalRequest(
2310
- originalRequest,
2311
- token
2312
- );
2313
- return instance.request(originalRequest);
2314
- }).catch(async (err) => {
2315
- if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2316
- await clearAuthToken();
2317
- }
2318
- });
2319
- }
2320
- const browserSession = await sessionStorage2.getBrowserSession();
2321
- const refreshToken = await localStorage2.getRefreshToken();
2322
- const accessTokenExp = await localStorage2.getAccessToken();
2323
- isRefreshing = true;
2324
- if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2325
- await clearAuthToken();
2326
- } else {
2327
- const payload = Object.fromEntries(
2328
- Object.entries({
2329
- refresh_token: refreshToken,
2330
- grant_type: "refresh_token",
2331
- client_id: config.config.clientId,
2332
- client_secret: config.config.clientSecret
2333
- }).filter(([_, value]) => !!value)
2334
- );
2335
- return new Promise(function(resolve) {
2336
- import_axios.default.post(
2337
- `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2338
- payload,
2339
- {
2340
- headers: {
2341
- "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2342
- Authorization: `Bearer ${accessTokenExp}`
2343
- }
2344
- }
2345
- ).then(async (res) => {
2346
- const data = res.data;
2347
- await localStorage2.setToken(data.access_token);
2348
- await localStorage2.setRefreshToken(data.refresh_token);
2349
- import_axios.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2350
- originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2351
- originalRequest.data = updateTokenParamInOriginalRequest(
2352
- originalRequest,
2353
- data.access_token
2354
- );
2355
- processQueue(null, data.access_token);
2356
- resolve(instance.request(originalRequest));
2357
- }).catch(async (err) => {
2358
- if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST") || err?.error_code === "ERR_2FA_006") {
2359
- await clearAuthToken();
2360
- }
2361
- if (err && err.response) {
2362
- const { error_code } = err.response?.data || {};
2363
- if (error_code === "AUTHEN_FAIL") {
2364
- await clearAuthToken();
2365
- }
2366
- }
2367
- processQueue(err, null);
2368
- }).finally(() => {
2369
- isRefreshing = false;
2370
- });
2371
- });
2372
- }
2373
- }
2374
- return Promise.reject(await handleError3(error));
2375
- }
2376
- );
2377
- const handleResponse = (res) => {
2378
- if (res && res.data) {
2379
- return res.data;
2380
- }
2381
- return res;
2382
- };
2383
- const handleError2 = (error) => {
2384
- if (error.isAxiosError && error.code === "ECONNABORTED") {
2385
- console.error("Request Timeout Error:", error);
2386
- return "Request Timeout Error";
2387
- } else if (error.isAxiosError && !error.response) {
2388
- console.error("Network Error:", error);
2389
- return "Network Error";
2390
- } else {
2391
- console.error("Other Error:", error?.response);
2392
- const errorMessage = error?.response?.data?.message || "An error occurred";
2393
- return { message: errorMessage, status: error?.response?.status };
2394
- }
2395
- };
2396
- const clearAuthToken = async () => {
2397
- await localStorage2.clearToken();
2398
- if (typeof window !== "undefined") {
2399
- window.location.href = `/login`;
2400
- }
2401
- };
2402
- function formatUrl(url, db2) {
2403
- return url + (db2 ? "?db=" + db2 : "");
2385
+ // src/store/reducers/header-slice/index.ts
2386
+ var import_toolkit5 = require("@reduxjs/toolkit");
2387
+ var headerSlice = (0, import_toolkit5.createSlice)({
2388
+ name: "header",
2389
+ initialState: {
2390
+ value: { allowedCompanyIds: [] }
2391
+ },
2392
+ reducers: {
2393
+ setHeader: (state, action) => {
2394
+ state.value = { ...state.value, ...action.payload };
2395
+ },
2396
+ setAllowedCompanyIds: (state, action) => {
2397
+ state.value.allowedCompanyIds = action.payload;
2404
2398
  }
2405
- const responseBody = (response) => response;
2406
- const requests = {
2407
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2408
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2409
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2410
- responseType: "arraybuffer",
2411
- headers: {
2412
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2413
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2414
- }
2415
- }).then(responseBody),
2416
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2417
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2418
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2419
- };
2420
- return requests;
2421
2399
  }
2400
+ });
2401
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
2402
+ var header_slice_default = headerSlice.reducer;
2403
+
2404
+ // src/store/reducers/list-slice/index.ts
2405
+ var import_toolkit6 = require("@reduxjs/toolkit");
2406
+ var initialState5 = {
2407
+ pageLimit: 10,
2408
+ fields: {},
2409
+ order: "",
2410
+ selectedRowKeys: [],
2411
+ selectedRadioKey: 0,
2412
+ indexRowTableModal: -2,
2413
+ isUpdateTableModal: false,
2414
+ footerGroupTable: {},
2415
+ transferDetail: null,
2416
+ page: 0,
2417
+ domainTable: []
2422
2418
  };
2419
+ var listSlice = (0, import_toolkit6.createSlice)({
2420
+ name: "list",
2421
+ initialState: initialState5,
2422
+ reducers: {
2423
+ setPageLimit: (state, action) => {
2424
+ state.pageLimit = action.payload;
2425
+ },
2426
+ setFields: (state, action) => {
2427
+ state.fields = action.payload;
2428
+ },
2429
+ setOrder: (state, action) => {
2430
+ state.order = action.payload;
2431
+ },
2432
+ setSelectedRowKeys: (state, action) => {
2433
+ state.selectedRowKeys = action.payload;
2434
+ },
2435
+ setSelectedRadioKey: (state, action) => {
2436
+ state.selectedRadioKey = action.payload;
2437
+ },
2438
+ setIndexRowTableModal: (state, action) => {
2439
+ state.indexRowTableModal = action.payload;
2440
+ },
2441
+ setTransferDetail: (state, action) => {
2442
+ state.transferDetail = action.payload;
2443
+ },
2444
+ setIsUpdateTableModal: (state, action) => {
2445
+ state.isUpdateTableModal = action.payload;
2446
+ },
2447
+ setPage: (state, action) => {
2448
+ state.page = action.payload;
2449
+ },
2450
+ setDomainTable: (state, action) => {
2451
+ state.domainTable = action.payload;
2452
+ }
2453
+ }
2454
+ });
2455
+ var {
2456
+ setPageLimit,
2457
+ setFields,
2458
+ setOrder,
2459
+ setSelectedRowKeys,
2460
+ setIndexRowTableModal,
2461
+ setIsUpdateTableModal,
2462
+ setPage,
2463
+ setSelectedRadioKey,
2464
+ setTransferDetail,
2465
+ setDomainTable
2466
+ } = listSlice.actions;
2467
+ var list_slice_default = listSlice.reducer;
2423
2468
 
2424
- // src/environment/EnvStore.ts
2425
- var EventEmitter = class {
2426
- listeners = {};
2427
- on(event, callback) {
2428
- if (!this.listeners[event]) {
2429
- this.listeners[event] = [];
2469
+ // src/store/reducers/login-slice/index.ts
2470
+ var import_toolkit7 = require("@reduxjs/toolkit");
2471
+ var initialState6 = {
2472
+ db: "",
2473
+ redirectTo: "/",
2474
+ forgotPasswordUrl: "/"
2475
+ };
2476
+ var loginSlice = (0, import_toolkit7.createSlice)({
2477
+ name: "login",
2478
+ initialState: initialState6,
2479
+ reducers: {
2480
+ setDb: (state, action) => {
2481
+ state.db = action.payload;
2482
+ },
2483
+ setRedirectTo: (state, action) => {
2484
+ state.redirectTo = action.payload;
2485
+ },
2486
+ setForgotPasswordUrl: (state, action) => {
2487
+ state.forgotPasswordUrl = action.payload;
2430
2488
  }
2431
- this.listeners[event].push(callback);
2432
2489
  }
2433
- emit(event, data) {
2434
- if (this.listeners[event]) {
2435
- this.listeners[event].forEach((callback) => callback(data));
2490
+ });
2491
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
2492
+ var login_slice_default = loginSlice.reducer;
2493
+
2494
+ // src/store/reducers/navbar-slice/index.ts
2495
+ var import_toolkit8 = require("@reduxjs/toolkit");
2496
+ var initialState7 = {
2497
+ menuFocus: {},
2498
+ menuAction: {},
2499
+ navbarWidth: 250,
2500
+ menuList: []
2501
+ };
2502
+ var navbarSlice = (0, import_toolkit8.createSlice)({
2503
+ name: "navbar",
2504
+ initialState: initialState7,
2505
+ reducers: {
2506
+ setMenuFocus: (state, action) => {
2507
+ state.menuFocus = action.payload;
2508
+ },
2509
+ setMenuFocusAction: (state, action) => {
2510
+ state.menuAction = action.payload;
2511
+ },
2512
+ setNavbarWidth: (state, action) => {
2513
+ state.navbarWidth = action.payload;
2514
+ },
2515
+ setMenuList: (state, action) => {
2516
+ state.menuList = action.payload;
2436
2517
  }
2437
2518
  }
2519
+ });
2520
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
2521
+ var navbar_slice_default = navbarSlice.reducer;
2522
+
2523
+ // src/store/reducers/profile-slice/index.ts
2524
+ var import_toolkit9 = require("@reduxjs/toolkit");
2525
+ var initialState8 = {
2526
+ profile: {}
2438
2527
  };
2439
- var EnvStore = class {
2440
- state;
2441
- emitter;
2442
- localStorageUtil;
2443
- sessionStorageUtil;
2444
- constructor(localStorageUtil = localStorageUtils(), sessionStorageUtil = sessionStorageUtils()) {
2445
- this.state = {
2446
- baseUrl: "",
2447
- requests: null,
2448
- companies: [],
2449
- user: {},
2450
- config: null,
2451
- envFile: null,
2452
- defaultCompany: {
2453
- id: null,
2454
- logo: "",
2455
- secondary_color: "",
2456
- primary_color: ""
2457
- },
2458
- context: {
2459
- uid: null,
2460
- allowed_company_ids: [],
2461
- lang: "vi_VN",
2462
- tz: "Asia/Saigon"
2463
- },
2464
- localStorageUtils: localStorageUtil,
2465
- sessionStorageUtils: sessionStorageUtil
2466
- };
2467
- this.emitter = new EventEmitter();
2468
- this.localStorageUtil = localStorageUtil;
2469
- this.sessionStorageUtil = sessionStorageUtil;
2470
- }
2471
- getEnv() {
2472
- return { ...this.state };
2473
- }
2474
- onUpdate(callback) {
2475
- this.emitter.on("update", callback);
2476
- }
2477
- setupEnv(envConfig) {
2478
- this.state = {
2479
- ...this.state,
2480
- ...envConfig,
2481
- localStorageUtils: this.localStorageUtil,
2482
- sessionStorageUtils: this.sessionStorageUtil
2483
- };
2484
- this.state.requests = axiosClient.init(this.state);
2485
- this.emitter.emit("update", this.getEnv());
2486
- return this.getEnv();
2487
- }
2488
- setUid(uid) {
2489
- this.state = {
2490
- ...this.state,
2491
- context: { ...this.state.context, uid }
2492
- };
2493
- this.emitter.emit("update", this.getEnv());
2528
+ var profileSlice = (0, import_toolkit9.createSlice)({
2529
+ name: "profile",
2530
+ initialState: initialState8,
2531
+ reducers: {
2532
+ setProfile: (state, action) => {
2533
+ state.profile = action.payload;
2534
+ }
2494
2535
  }
2495
- setLang(lang) {
2496
- this.state = {
2497
- ...this.state,
2498
- context: { ...this.state.context, lang }
2499
- };
2500
- this.emitter.emit("update", this.getEnv());
2536
+ });
2537
+ var { setProfile } = profileSlice.actions;
2538
+ var profile_slice_default = profileSlice.reducer;
2539
+
2540
+ // src/store/reducers/search-slice/index.ts
2541
+ var import_toolkit10 = require("@reduxjs/toolkit");
2542
+ var initialState9 = {
2543
+ groupByDomain: null,
2544
+ searchBy: [],
2545
+ searchString: "",
2546
+ hoveredIndexSearchList: null,
2547
+ selectedTags: [],
2548
+ firstDomain: null,
2549
+ searchMap: {},
2550
+ filterBy: [],
2551
+ groupBy: []
2552
+ };
2553
+ var searchSlice = (0, import_toolkit10.createSlice)({
2554
+ name: "search",
2555
+ initialState: initialState9,
2556
+ reducers: {
2557
+ setGroupByDomain: (state, action) => {
2558
+ state.groupByDomain = action.payload;
2559
+ },
2560
+ setSearchBy: (state, action) => {
2561
+ state.searchBy = action.payload;
2562
+ },
2563
+ setSearchString: (state, action) => {
2564
+ state.searchString = action.payload;
2565
+ },
2566
+ setHoveredIndexSearchList: (state, action) => {
2567
+ state.hoveredIndexSearchList = action.payload;
2568
+ },
2569
+ setSelectedTags: (state, action) => {
2570
+ state.selectedTags = action.payload;
2571
+ },
2572
+ setFirstDomain: (state, action) => {
2573
+ state.firstDomain = action.payload;
2574
+ },
2575
+ setFilterBy: (state, action) => {
2576
+ state.filterBy = action.payload;
2577
+ },
2578
+ setGroupBy: (state, action) => {
2579
+ state.groupBy = action.payload;
2580
+ },
2581
+ setSearchMap: (state, action) => {
2582
+ state.searchMap = action.payload;
2583
+ },
2584
+ updateSearchMap: (state, action) => {
2585
+ if (!state.searchMap[action.payload.key]) {
2586
+ state.searchMap[action.payload.key] = [];
2587
+ }
2588
+ state.searchMap[action.payload.key].push(action.payload.value);
2589
+ },
2590
+ removeKeyFromSearchMap: (state, action) => {
2591
+ const { key, item } = action.payload;
2592
+ const values = state.searchMap[key];
2593
+ if (!values) return;
2594
+ if (item) {
2595
+ const filtered = values.filter((value) => value.name !== item.name);
2596
+ if (filtered.length > 0) {
2597
+ state.searchMap[key] = filtered;
2598
+ } else {
2599
+ delete state.searchMap[key];
2600
+ }
2601
+ } else {
2602
+ delete state.searchMap[key];
2603
+ }
2604
+ },
2605
+ clearSearchMap: (state) => {
2606
+ state.searchMap = {};
2607
+ }
2501
2608
  }
2502
- setAllowCompanies(allowed_company_ids) {
2503
- this.state = {
2504
- ...this.state,
2505
- context: { ...this.state.context, allowed_company_ids }
2506
- };
2507
- this.emitter.emit("update", this.getEnv());
2609
+ });
2610
+ var {
2611
+ setGroupByDomain,
2612
+ setSelectedTags,
2613
+ setSearchString,
2614
+ setHoveredIndexSearchList,
2615
+ setFirstDomain,
2616
+ setSearchBy,
2617
+ setFilterBy,
2618
+ setSearchMap,
2619
+ updateSearchMap,
2620
+ removeKeyFromSearchMap,
2621
+ setGroupBy,
2622
+ clearSearchMap
2623
+ } = searchSlice.actions;
2624
+ var search_slice_default = searchSlice.reducer;
2625
+
2626
+ // src/store/store.ts
2627
+ var import_toolkit11 = require("@reduxjs/toolkit");
2628
+
2629
+ // node_modules/redux/dist/redux.mjs
2630
+ function formatProdErrorMessage(code) {
2631
+ return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
2632
+ }
2633
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
2634
+ var ActionTypes = {
2635
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
2636
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
2637
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
2638
+ };
2639
+ var actionTypes_default = ActionTypes;
2640
+ function isPlainObject(obj) {
2641
+ if (typeof obj !== "object" || obj === null)
2642
+ return false;
2643
+ let proto = obj;
2644
+ while (Object.getPrototypeOf(proto) !== null) {
2645
+ proto = Object.getPrototypeOf(proto);
2508
2646
  }
2509
- setCompanies(companies) {
2510
- this.state = { ...this.state, companies };
2511
- this.emitter.emit("update", this.getEnv());
2647
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
2648
+ }
2649
+ function miniKindOf(val) {
2650
+ if (val === void 0)
2651
+ return "undefined";
2652
+ if (val === null)
2653
+ return "null";
2654
+ const type = typeof val;
2655
+ switch (type) {
2656
+ case "boolean":
2657
+ case "string":
2658
+ case "number":
2659
+ case "symbol":
2660
+ case "function": {
2661
+ return type;
2662
+ }
2512
2663
  }
2513
- setDefaultCompany(defaultCompany) {
2514
- this.state = { ...this.state, defaultCompany };
2515
- this.emitter.emit("update", this.getEnv());
2664
+ if (Array.isArray(val))
2665
+ return "array";
2666
+ if (isDate(val))
2667
+ return "date";
2668
+ if (isError(val))
2669
+ return "error";
2670
+ const constructorName = ctorName(val);
2671
+ switch (constructorName) {
2672
+ case "Symbol":
2673
+ case "Promise":
2674
+ case "WeakMap":
2675
+ case "WeakSet":
2676
+ case "Map":
2677
+ case "Set":
2678
+ return constructorName;
2679
+ }
2680
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
2681
+ }
2682
+ function ctorName(val) {
2683
+ return typeof val.constructor === "function" ? val.constructor.name : null;
2684
+ }
2685
+ function isError(val) {
2686
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
2687
+ }
2688
+ function isDate(val) {
2689
+ if (val instanceof Date)
2690
+ return true;
2691
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
2692
+ }
2693
+ function kindOf(val) {
2694
+ let typeOfVal = typeof val;
2695
+ if (process.env.NODE_ENV !== "production") {
2696
+ typeOfVal = miniKindOf(val);
2516
2697
  }
2517
- setUserInfo(user) {
2518
- this.state = { ...this.state, user };
2519
- this.emitter.emit("update", this.getEnv());
2698
+ return typeOfVal;
2699
+ }
2700
+ function warning(message) {
2701
+ if (typeof console !== "undefined" && typeof console.error === "function") {
2702
+ console.error(message);
2520
2703
  }
2521
- setConfig(config) {
2522
- this.state = { ...this.state, config };
2523
- this.emitter.emit("update", this.getEnv());
2704
+ try {
2705
+ throw new Error(message);
2706
+ } catch (e) {
2524
2707
  }
2525
- setEnvFile(envFile) {
2526
- this.state = { ...this.state, envFile };
2527
- this.emitter.emit("update", this.getEnv());
2708
+ }
2709
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
2710
+ const reducerKeys = Object.keys(reducers);
2711
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
2712
+ if (reducerKeys.length === 0) {
2713
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
2714
+ }
2715
+ if (!isPlainObject(inputState)) {
2716
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
2717
+ }
2718
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
2719
+ unexpectedKeys.forEach((key) => {
2720
+ unexpectedKeyCache[key] = true;
2721
+ });
2722
+ if (action && action.type === actionTypes_default.REPLACE)
2723
+ return;
2724
+ if (unexpectedKeys.length > 0) {
2725
+ return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
2528
2726
  }
2529
- };
2530
- var env = null;
2531
- function initEnv({
2532
- localStorageUtils: localStorageUtil = localStorageUtils(),
2533
- sessionStorageUtils: sessionStorageUtil = sessionStorageUtils()
2534
- }) {
2535
- if (!env) {
2536
- env = new EnvStore(localStorageUtil, sessionStorageUtil);
2537
- }
2538
- return env;
2539
2727
  }
2540
- function getEnv() {
2541
- if (!env) {
2542
- env = initEnv({});
2728
+ function assertReducerShape(reducers) {
2729
+ Object.keys(reducers).forEach((key) => {
2730
+ const reducer = reducers[key];
2731
+ const initialState10 = reducer(void 0, {
2732
+ type: actionTypes_default.INIT
2733
+ });
2734
+ if (typeof initialState10 === "undefined") {
2735
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
2736
+ }
2737
+ if (typeof reducer(void 0, {
2738
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
2739
+ }) === "undefined") {
2740
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
2741
+ }
2742
+ });
2743
+ }
2744
+ function combineReducers(reducers) {
2745
+ const reducerKeys = Object.keys(reducers);
2746
+ const finalReducers = {};
2747
+ for (let i = 0; i < reducerKeys.length; i++) {
2748
+ const key = reducerKeys[i];
2749
+ if (process.env.NODE_ENV !== "production") {
2750
+ if (typeof reducers[key] === "undefined") {
2751
+ warning(`No reducer provided for key "${key}"`);
2752
+ }
2753
+ }
2754
+ if (typeof reducers[key] === "function") {
2755
+ finalReducers[key] = reducers[key];
2756
+ }
2757
+ }
2758
+ const finalReducerKeys = Object.keys(finalReducers);
2759
+ let unexpectedKeyCache;
2760
+ if (process.env.NODE_ENV !== "production") {
2761
+ unexpectedKeyCache = {};
2543
2762
  }
2544
- return env?.getEnv();
2763
+ let shapeAssertionError;
2764
+ try {
2765
+ assertReducerShape(finalReducers);
2766
+ } catch (e) {
2767
+ shapeAssertionError = e;
2768
+ }
2769
+ return function combination(state = {}, action) {
2770
+ if (shapeAssertionError) {
2771
+ throw shapeAssertionError;
2772
+ }
2773
+ if (process.env.NODE_ENV !== "production") {
2774
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
2775
+ if (warningMessage) {
2776
+ warning(warningMessage);
2777
+ }
2778
+ }
2779
+ let hasChanged = false;
2780
+ const nextState = {};
2781
+ for (let i = 0; i < finalReducerKeys.length; i++) {
2782
+ const key = finalReducerKeys[i];
2783
+ const reducer = finalReducers[key];
2784
+ const previousStateForKey = state[key];
2785
+ const nextStateForKey = reducer(previousStateForKey, action);
2786
+ if (typeof nextStateForKey === "undefined") {
2787
+ const actionType = action && action.type;
2788
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
2789
+ }
2790
+ nextState[key] = nextStateForKey;
2791
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
2792
+ }
2793
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
2794
+ return hasChanged ? nextState : state;
2795
+ };
2796
+ }
2797
+
2798
+ // src/store/store.ts
2799
+ var rootReducer = combineReducers({
2800
+ env: env_slice_default,
2801
+ header: header_slice_default,
2802
+ navbar: navbar_slice_default,
2803
+ list: list_slice_default,
2804
+ search: search_slice_default,
2805
+ form: form_slice_default,
2806
+ breadcrumbs: breadcrums_slice_default,
2807
+ login: login_slice_default,
2808
+ excel: excel_slice_default,
2809
+ profile: profile_slice_default
2810
+ });
2811
+ var envStore = (0, import_toolkit11.configureStore)({
2812
+ reducer: rootReducer,
2813
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
2814
+ serializableCheck: false
2815
+ })
2816
+ });
2817
+
2818
+ // src/provider/redux-provider.tsx
2819
+ var import_jsx_runtime2 = require("react/jsx-runtime");
2820
+
2821
+ // src/provider/main-provider.tsx
2822
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2823
+
2824
+ // src/provider/version-gate-provider.tsx
2825
+ var import_react2 = require("react");
2826
+ var import_react_query2 = require("@tanstack/react-query");
2827
+ var import_jsx_runtime4 = require("react/jsx-runtime");
2828
+
2829
+ // src/provider/env-provider.tsx
2830
+ var import_react3 = require("react");
2831
+
2832
+ // src/configs/axios-client.ts
2833
+ var import_axios = __toESM(require("axios"));
2834
+
2835
+ // src/provider/env-provider.tsx
2836
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2837
+ var EnvContext = (0, import_react3.createContext)(null);
2838
+ function useEnv() {
2839
+ const context = (0, import_react3.useContext)(EnvContext);
2840
+ if (!context) {
2841
+ throw new Error("useEnv must be used within an EnvProvider");
2842
+ }
2843
+ return context;
2545
2844
  }
2546
2845
 
2846
+ // src/provider/service-provider.tsx
2847
+ var import_react4 = require("react");
2848
+
2849
+ // src/hooks/auth/use-forgot-password.ts
2850
+ var import_react_query3 = require("@tanstack/react-query");
2851
+
2852
+ // src/hooks/auth/use-forgotpassword-sso.ts
2853
+ var import_react_query4 = require("@tanstack/react-query");
2854
+
2855
+ // src/hooks/auth/use-get-provider.ts
2856
+ var import_react_query5 = require("@tanstack/react-query");
2857
+
2858
+ // src/hooks/auth/use-isvalid-token.ts
2859
+ var import_react_query6 = require("@tanstack/react-query");
2860
+
2861
+ // src/hooks/auth/use-login-credential.tsx
2862
+ var import_react_query7 = require("@tanstack/react-query");
2863
+
2864
+ // src/hooks/auth/use-login-socical.ts
2865
+ var import_react_query8 = require("@tanstack/react-query");
2866
+
2867
+ // src/hooks/auth/use-reset-password.ts
2868
+ var import_react_query9 = require("@tanstack/react-query");
2869
+
2870
+ // src/hooks/auth/use-reset-password-sso.ts
2871
+ var import_react_query10 = require("@tanstack/react-query");
2872
+
2873
+ // src/hooks/auth/use-update-password.ts
2874
+ var import_react_query11 = require("@tanstack/react-query");
2875
+
2876
+ // src/hooks/auth/use-logout.ts
2877
+ var import_react_query12 = require("@tanstack/react-query");
2878
+
2879
+ // src/hooks/auth/use-get-access-by-code.ts
2880
+ var import_react_query13 = require("@tanstack/react-query");
2881
+
2882
+ // src/hooks/auth/use-validate-action-token.ts
2883
+ var import_react_query14 = require("@tanstack/react-query");
2884
+
2885
+ // src/hooks/company/use-get-company-info.ts
2886
+ var import_react_query15 = require("@tanstack/react-query");
2887
+
2888
+ // src/hooks/company/use-get-current-company.ts
2889
+ var import_react_query16 = require("@tanstack/react-query");
2890
+
2891
+ // src/hooks/company/use-get-list-company.ts
2892
+ var import_react_query17 = require("@tanstack/react-query");
2893
+
2894
+ // src/hooks/excel/use-export-excel.ts
2895
+ var import_react_query18 = require("@tanstack/react-query");
2896
+
2897
+ // src/hooks/excel/use-get-field-export.ts
2898
+ var import_react_query19 = require("@tanstack/react-query");
2899
+
2900
+ // src/hooks/excel/use-get-file-excel.ts
2901
+ var import_react_query20 = require("@tanstack/react-query");
2902
+
2903
+ // src/hooks/excel/use-parse-preview.ts
2904
+ var import_react_query21 = require("@tanstack/react-query");
2905
+
2906
+ // src/hooks/excel/use-upload-file.ts
2907
+ var import_react_query22 = require("@tanstack/react-query");
2908
+
2909
+ // src/hooks/excel/use-upload-id-file.ts
2910
+ var import_react_query23 = require("@tanstack/react-query");
2911
+
2912
+ // src/hooks/excel/uss-execute-import.ts
2913
+ var import_react_query24 = require("@tanstack/react-query");
2914
+
2915
+ // src/hooks/form/use-change-status.ts
2916
+ var import_react_query25 = require("@tanstack/react-query");
2917
+
2918
+ // src/hooks/form/use-delete-comment.ts
2919
+ var import_react_query26 = require("@tanstack/react-query");
2920
+
2921
+ // src/hooks/form/use-get-comment.ts
2922
+ var import_react_query27 = require("@tanstack/react-query");
2923
+
2924
+ // src/hooks/form/use-get-form-view.ts
2925
+ var import_react_query28 = require("@tanstack/react-query");
2926
+
2927
+ // src/hooks/form/use-get-image.ts
2928
+ var import_react_query29 = require("@tanstack/react-query");
2929
+
2930
+ // src/hooks/form/use-send-comment.ts
2931
+ var import_react_query30 = require("@tanstack/react-query");
2932
+
2933
+ // src/hooks/form/use-upload-image.ts
2934
+ var import_react_query31 = require("@tanstack/react-query");
2935
+
2936
+ // src/hooks/model/use-delete.ts
2937
+ var import_react_query32 = require("@tanstack/react-query");
2938
+
2939
+ // src/hooks/model/use-get-all.ts
2940
+ var import_react_query33 = require("@tanstack/react-query");
2941
+
2942
+ // src/hooks/model/use-get-conversion-rate.ts
2943
+ var import_react_query34 = require("@tanstack/react-query");
2944
+
2945
+ // src/hooks/model/use-get-currency.ts
2946
+ var import_react_query35 = require("@tanstack/react-query");
2947
+
2948
+ // src/hooks/model/use-get-detail.ts
2949
+ var import_react_query36 = require("@tanstack/react-query");
2950
+
2951
+ // src/hooks/model/use-get-field-onchange.ts
2952
+ var import_react_query37 = require("@tanstack/react-query");
2953
+
2954
+ // src/hooks/model/use-get-list-my-bank-account.ts
2955
+ var import_react_query38 = require("@tanstack/react-query");
2956
+
2957
+ // src/hooks/model/use-onchange-form.ts
2958
+ var import_react_query39 = require("@tanstack/react-query");
2959
+
2960
+ // src/hooks/model/use-save.ts
2961
+ var import_react_query40 = require("@tanstack/react-query");
2962
+
2963
+ // src/hooks/user/use-get-profile.ts
2964
+ var import_react_query41 = require("@tanstack/react-query");
2965
+
2966
+ // src/hooks/user/use-get-user.ts
2967
+ var import_react_query42 = require("@tanstack/react-query");
2968
+
2969
+ // src/hooks/user/use-switch-locale.ts
2970
+ var import_react_query43 = require("@tanstack/react-query");
2971
+
2972
+ // src/hooks/view/use-button.ts
2973
+ var import_react_query44 = require("@tanstack/react-query");
2974
+
2975
+ // src/hooks/view/use-duplicate-record.ts
2976
+ var import_react_query45 = require("@tanstack/react-query");
2977
+
2978
+ // src/hooks/view/use-get-action-detail.ts
2979
+ var import_react_query46 = require("@tanstack/react-query");
2980
+
2981
+ // src/hooks/view/use-get-calendar.ts
2982
+ var import_react_query47 = require("@tanstack/react-query");
2983
+
2984
+ // src/hooks/view/use-get-groups.ts
2985
+ var import_react_query48 = require("@tanstack/react-query");
2986
+
2987
+ // src/hooks/view/use-get-list-data.ts
2988
+ var import_react_query49 = require("@tanstack/react-query");
2989
+
2990
+ // src/hooks/view/use-get-menu.ts
2991
+ var import_react_query50 = require("@tanstack/react-query");
2992
+
2993
+ // src/hooks/view/use-get-print-report.ts
2994
+ var import_react_query51 = require("@tanstack/react-query");
2995
+
2996
+ // src/hooks/view/use-get-progress-bar.ts
2997
+ var import_react_query52 = require("@tanstack/react-query");
2998
+
2999
+ // src/hooks/view/use-get-selection.ts
3000
+ var import_react_query53 = require("@tanstack/react-query");
3001
+
3002
+ // src/hooks/view/use-get-view.ts
3003
+ var import_react_query54 = require("@tanstack/react-query");
3004
+
3005
+ // src/hooks/view/use-load-action.ts
3006
+ var import_react_query55 = require("@tanstack/react-query");
3007
+
3008
+ // src/hooks/view/use-load-message.ts
3009
+ var import_react_query56 = require("@tanstack/react-query");
3010
+
3011
+ // src/hooks/view/use-print.ts
3012
+ var import_react_query57 = require("@tanstack/react-query");
3013
+
3014
+ // src/hooks/view/use-remove-row.ts
3015
+ var import_react_query58 = require("@tanstack/react-query");
3016
+
3017
+ // src/hooks/view/use-resequence.ts
3018
+ var import_react_query59 = require("@tanstack/react-query");
3019
+
3020
+ // src/hooks/view/use-run-action.ts
3021
+ var import_react_query60 = require("@tanstack/react-query");
3022
+
3023
+ // src/hooks/view/use-signin-sso.ts
3024
+ var import_react_query61 = require("@tanstack/react-query");
3025
+
3026
+ // src/hooks/view/use-verify-2FA.ts
3027
+ var import_react_query62 = require("@tanstack/react-query");
3028
+
3029
+ // src/hooks/view/uset-get-2FA-method.ts
3030
+ var import_react_query63 = require("@tanstack/react-query");
3031
+
3032
+ // src/hooks/view/use-grant-access.ts
3033
+ var import_react_query64 = require("@tanstack/react-query");
3034
+
3035
+ // src/hooks/view/use-remove-totp-setup.ts
3036
+ var import_react_query65 = require("@tanstack/react-query");
3037
+
3038
+ // src/hooks/view/use-request-setup-totp.ts
3039
+ var import_react_query66 = require("@tanstack/react-query");
3040
+
3041
+ // src/hooks/view/use-settings-web-read-2fa.ts
3042
+ var import_react_query67 = require("@tanstack/react-query");
3043
+
3044
+ // src/hooks/view/use-verify-totp.ts
3045
+ var import_react_query68 = require("@tanstack/react-query");
3046
+
3047
+ // src/provider/service-provider.tsx
3048
+ var import_jsx_runtime6 = require("react/jsx-runtime");
3049
+ var ServiceContext = (0, import_react4.createContext)(null);
3050
+
2547
3051
  // src/services/action-service/index.ts
2548
- var ActionService = {
2549
- // Load Action
2550
- async loadAction({
2551
- idAction,
2552
- context
2553
- }) {
2554
- const env2 = getEnv();
2555
- const jsonData = {
2556
- action_id: idAction,
2557
- with_context: {
2558
- ...context
2559
- }
2560
- };
2561
- return env2.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
2562
- headers: {
2563
- "Content-Type": "application/json"
3052
+ function useActionService() {
3053
+ const { env } = useEnv();
3054
+ const loadAction = (0, import_react5.useCallback)(
3055
+ async ({
3056
+ idAction,
3057
+ context
3058
+ }) => {
3059
+ const jsonData = {
3060
+ action_id: idAction,
3061
+ with_context: { ...context }
3062
+ };
3063
+ return env.requests.post("/load_action" /* LOAD_ACTION */, jsonData, {
3064
+ headers: { "Content-Type": "application/json" }
3065
+ });
3066
+ },
3067
+ [env]
3068
+ );
3069
+ const callButton = (0, import_react5.useCallback)(
3070
+ async ({
3071
+ model,
3072
+ ids = [],
3073
+ context,
3074
+ method
3075
+ }) => {
3076
+ try {
3077
+ const jsonData = {
3078
+ model,
3079
+ method,
3080
+ ids,
3081
+ with_context: context
3082
+ };
3083
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3084
+ headers: { "Content-Type": "application/json" }
3085
+ });
3086
+ } catch (error) {
3087
+ console.error("Error when calling button action:", error);
3088
+ throw error;
2564
3089
  }
2565
- });
2566
- },
2567
- // Call Button
2568
- async callButton({
2569
- model,
2570
- ids = [],
2571
- context,
2572
- method
2573
- }) {
2574
- try {
2575
- const env2 = getEnv();
3090
+ },
3091
+ [env]
3092
+ );
3093
+ const removeRows = (0, import_react5.useCallback)(
3094
+ async ({
3095
+ model,
3096
+ ids,
3097
+ context
3098
+ }) => {
2576
3099
  const jsonData = {
2577
3100
  model,
2578
- method,
3101
+ method: "unlink",
2579
3102
  ids,
2580
3103
  with_context: context
2581
3104
  };
2582
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
2583
- headers: {
2584
- "Content-Type": "application/json"
2585
- }
3105
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3106
+ headers: { "Content-Type": "application/json" }
2586
3107
  });
2587
- } catch (error) {
2588
- console.error("Error when calling button action:", error);
2589
- throw error;
2590
- }
2591
- },
2592
- // remove Row
2593
- async removeRows({
2594
- model,
2595
- ids,
2596
- context
2597
- }) {
2598
- const env2 = getEnv();
2599
- const jsonData = {
2600
- model,
2601
- method: "unlink",
2602
- ids,
2603
- with_context: context
2604
- };
2605
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
2606
- headers: {
2607
- "Content-Type": "application/json"
2608
- }
2609
- });
2610
- },
2611
- // Duplicate Model
2612
- async duplicateRecord({
2613
- model,
2614
- id,
2615
- context
2616
- }) {
2617
- const env2 = getEnv();
2618
- const jsonData = {
3108
+ },
3109
+ [env]
3110
+ );
3111
+ const duplicateRecord = (0, import_react5.useCallback)(
3112
+ async ({
2619
3113
  model,
2620
- method: "copy",
2621
- ids: id,
2622
- with_context: context
2623
- };
2624
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
2625
- headers: {
2626
- "Content-Type": "application/json"
2627
- }
2628
- });
2629
- },
2630
- // Get Print Report
2631
- async getPrintReportName({ id }) {
2632
- const env2 = getEnv();
2633
- const jsonData = {
2634
- model: "ir.actions.report",
2635
- method: "web_read",
2636
3114
  id,
2637
- kwargs: {
2638
- specification: {
2639
- report_name: {}
3115
+ context
3116
+ }) => {
3117
+ const jsonData = {
3118
+ model,
3119
+ method: "copy",
3120
+ ids: id,
3121
+ with_context: context
3122
+ };
3123
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3124
+ headers: { "Content-Type": "application/json" }
3125
+ });
3126
+ },
3127
+ [env]
3128
+ );
3129
+ const getPrintReportName = (0, import_react5.useCallback)(
3130
+ async ({ id }) => {
3131
+ const jsonData = {
3132
+ model: "ir.actions.report",
3133
+ method: "web_read",
3134
+ id,
3135
+ kwargs: {
3136
+ specification: {
3137
+ report_name: {}
3138
+ }
2640
3139
  }
2641
- }
2642
- };
2643
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
2644
- headers: {
2645
- "Content-Type": "application/json"
2646
- }
2647
- });
2648
- },
2649
- //Save Print Invoice
2650
- async print({ id, report, db }) {
2651
- const env2 = getEnv();
2652
- const jsonData = {
2653
- report,
2654
- id,
2655
- type: "pdf",
2656
- file_response: true,
2657
- db
2658
- };
2659
- const queryString = toQueryString(jsonData);
2660
- const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
2661
- return env2.requests.get(urlWithParams, {
2662
- headers: {
2663
- "Content-Type": "application/json"
2664
- },
2665
- responseType: "arraybuffer"
2666
- });
2667
- },
2668
- //Run Action
2669
- async runAction({
2670
- idAction,
2671
- context
2672
- }) {
2673
- const env2 = getEnv();
2674
- const jsonData = {
2675
- action_id: idAction,
2676
- with_context: {
2677
- ...context
2678
- }
2679
- // context: {
2680
- // lang: 'en_US',
2681
- // tz: 'Asia/Saigon',
2682
- // uid: 2,
2683
- // allowed_company_ids: [1],
2684
- // active_id: Array.isArray(idDetail) ? idDetail[0] : idDetail,
2685
- // active_ids: Array.isArray(idDetail) ? [...idDetail] : idDetail,
2686
- // active_model: model,
2687
- // },
2688
- };
2689
- return env2.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
2690
- headers: {
2691
- "Content-Type": "application/json"
2692
- }
2693
- });
2694
- }
2695
- };
2696
- var action_service_default = ActionService;
3140
+ };
3141
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3142
+ headers: { "Content-Type": "application/json" }
3143
+ });
3144
+ },
3145
+ [env]
3146
+ );
3147
+ const print = (0, import_react5.useCallback)(
3148
+ async ({ id, report, db }) => {
3149
+ const jsonData = {
3150
+ report,
3151
+ id,
3152
+ type: "pdf",
3153
+ file_response: true,
3154
+ db
3155
+ };
3156
+ const queryString = toQueryString(jsonData);
3157
+ const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
3158
+ return env.requests.get(urlWithParams, {
3159
+ headers: { "Content-Type": "application/json" },
3160
+ responseType: "arraybuffer"
3161
+ });
3162
+ },
3163
+ [env]
3164
+ );
3165
+ const runAction = (0, import_react5.useCallback)(
3166
+ async ({
3167
+ idAction,
3168
+ context
3169
+ }) => {
3170
+ const jsonData = {
3171
+ action_id: idAction,
3172
+ with_context: { ...context }
3173
+ };
3174
+ return env.requests.post("/run_action" /* RUN_ACTION_PATH */, jsonData, {
3175
+ headers: { "Content-Type": "application/json" }
3176
+ });
3177
+ },
3178
+ [env]
3179
+ );
3180
+ return {
3181
+ loadAction,
3182
+ callButton,
3183
+ removeRows,
3184
+ duplicateRecord,
3185
+ getPrintReportName,
3186
+ print,
3187
+ runAction
3188
+ };
3189
+ }
2697
3190
 
2698
3191
  // src/services/auth-service/index.ts
2699
- var AuthService = {
2700
- async login(body) {
2701
- const env2 = getEnv();
2702
- const payload = Object.fromEntries(
2703
- Object.entries({
2704
- username: body.email,
2705
- password: body.password,
2706
- grant_type: env2?.config?.grantType || "",
2707
- client_id: env2?.config?.clientId || "",
2708
- client_secret: env2?.config?.clientSecret || ""
2709
- }).filter(([_, value]) => !!value)
2710
- );
2711
- const encodedData = new URLSearchParams(payload).toString();
2712
- return env2?.requests?.post(body.path, encodedData, {
2713
- headers: {
2714
- "Content-Type": "application/x-www-form-urlencoded"
2715
- }
2716
- });
2717
- },
2718
- async forgotPassword(email) {
2719
- const env2 = getEnv();
2720
- const bodyData = {
2721
- login: email,
2722
- url: `${window.location.origin}/reset-password`
2723
- };
2724
- return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
2725
- headers: {
2726
- "Content-Type": "application/json"
2727
- }
2728
- });
2729
- },
2730
- async forgotPasswordSSO({
2731
- email,
2732
- with_context,
2733
- method
2734
- }) {
2735
- const env2 = getEnv();
2736
- const body = {
2737
- method,
2738
- kwargs: {
2739
- vals: {
2740
- email
3192
+ var import_react6 = require("react");
3193
+ function useAuthService() {
3194
+ const { env } = useEnv();
3195
+ const login = (0, import_react6.useCallback)(
3196
+ async (body) => {
3197
+ const payload = Object.fromEntries(
3198
+ Object.entries({
3199
+ username: body.email,
3200
+ password: body.password,
3201
+ grant_type: env?.config?.grantType || "",
3202
+ client_id: env?.config?.clientId || "",
3203
+ client_secret: env?.config?.clientSecret || ""
3204
+ }).filter(([_, value]) => !!value)
3205
+ );
3206
+ const encodedData = new URLSearchParams(payload).toString();
3207
+ return env?.requests?.post(body.path, encodedData, {
3208
+ headers: {
3209
+ "Content-Type": "application/x-www-form-urlencoded"
2741
3210
  }
2742
- },
2743
- with_context
2744
- };
2745
- return env2?.requests?.post("/call" /* CALL_PATH */, body, {
2746
- headers: {
2747
- "Content-Type": "application/json"
2748
- }
2749
- });
2750
- },
2751
- async resetPassword(data, token) {
2752
- const env2 = getEnv();
2753
- const bodyData = {
2754
- token,
2755
- password: data.password,
2756
- new_password: data.confirmPassword
2757
- };
2758
- return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
2759
- headers: {
2760
- "Content-Type": "application/json"
2761
- }
2762
- });
2763
- },
2764
- async resetPasswordSSO({
2765
- method,
2766
- password,
2767
- with_context
2768
- }) {
2769
- const env2 = getEnv();
2770
- const bodyData = {
2771
- method,
2772
- kwargs: {
2773
- vals: {
2774
- password
3211
+ });
3212
+ },
3213
+ [env]
3214
+ );
3215
+ const forgotPassword = (0, import_react6.useCallback)(
3216
+ async (email) => {
3217
+ const bodyData = {
3218
+ login: email,
3219
+ url: `${window.location.origin}/reset-password`
3220
+ };
3221
+ return env?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3222
+ headers: {
3223
+ "Content-Type": "application/json"
2775
3224
  }
2776
- },
2777
- with_context
2778
- };
2779
- return env2?.requests?.post("/call" /* CALL_PATH */, bodyData, {
2780
- headers: {
2781
- "Content-Type": "application/json"
2782
- }
2783
- });
2784
- },
2785
- async updatePassword(data, token) {
2786
- const env2 = getEnv();
2787
- const bodyData = {
2788
- token,
2789
- old_password: data.oldPassword,
2790
- new_password: data.newPassword
2791
- };
2792
- return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
2793
- headers: {
2794
- "Content-Type": "application/json"
2795
- }
2796
- });
2797
- },
2798
- async isValidToken(token) {
2799
- const env2 = getEnv();
2800
- const bodyData = {
2801
- token
2802
- };
2803
- return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
2804
- headers: {
2805
- "Content-Type": "application/json"
2806
- }
2807
- });
2808
- },
2809
- async isValidActionToken(actionToken, path) {
2810
- const env2 = getEnv();
2811
- return env2?.requests?.post(
2812
- path,
2813
- {},
2814
- {
3225
+ });
3226
+ },
3227
+ [env]
3228
+ );
3229
+ const forgotPasswordSSO = (0, import_react6.useCallback)(
3230
+ async ({
3231
+ email,
3232
+ with_context,
3233
+ method
3234
+ }) => {
3235
+ const body = {
3236
+ method,
3237
+ kwargs: {
3238
+ vals: {
3239
+ email
3240
+ }
3241
+ },
3242
+ with_context
3243
+ };
3244
+ return env?.requests?.post("/call" /* CALL_PATH */, body, {
3245
+ headers: {
3246
+ "Content-Type": "application/json"
3247
+ }
3248
+ });
3249
+ },
3250
+ [env]
3251
+ );
3252
+ const resetPassword = (0, import_react6.useCallback)(
3253
+ async (data, token) => {
3254
+ const bodyData = {
3255
+ token,
3256
+ password: data.password,
3257
+ new_password: data.confirmPassword
3258
+ };
3259
+ return env?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
2815
3260
  headers: {
2816
3261
  "Content-Type": "application/json"
3262
+ }
3263
+ });
3264
+ },
3265
+ [env]
3266
+ );
3267
+ const resetPasswordSSO = (0, import_react6.useCallback)(
3268
+ async ({
3269
+ method,
3270
+ password,
3271
+ with_context
3272
+ }) => {
3273
+ const bodyData = {
3274
+ method,
3275
+ kwargs: {
3276
+ vals: {
3277
+ password
3278
+ }
2817
3279
  },
2818
- useActionToken: true,
2819
- actionToken
2820
- }
2821
- );
2822
- },
2823
- async loginSocial({
2824
- db,
2825
- state,
2826
- access_token
2827
- }) {
2828
- const env2 = getEnv();
2829
- return env2?.requests?.post(
2830
- "/token/generate" /* GENTOKEN_SOCIAL */,
2831
- { state, access_token },
2832
- {
3280
+ with_context
3281
+ };
3282
+ return env?.requests?.post("/call" /* CALL_PATH */, bodyData, {
2833
3283
  headers: {
2834
3284
  "Content-Type": "application/json"
2835
3285
  }
2836
- }
2837
- );
2838
- },
2839
- async getProviders(db) {
2840
- const env2 = getEnv();
2841
- return env2?.requests?.get("/oauth/providers", { params: { db } });
2842
- },
2843
- async getAccessByCode(code) {
2844
- const env2 = getEnv();
2845
- const data = new URLSearchParams();
2846
- data.append("code", code);
2847
- data.append("grant_type", "authorization_code");
2848
- data.append("client_id", env2?.config?.clientId || "");
2849
- data.append("redirect_uri", env2?.config?.redirectUri || "");
2850
- return env2?.requests?.post(
2851
- `${env2?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
2852
- data,
2853
- {
3286
+ });
3287
+ },
3288
+ [env]
3289
+ );
3290
+ const updatePassword = (0, import_react6.useCallback)(
3291
+ async (data, token) => {
3292
+ const bodyData = {
3293
+ token,
3294
+ old_password: data.oldPassword,
3295
+ new_password: data.newPassword
3296
+ };
3297
+ return env?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
2854
3298
  headers: {
2855
- "Content-Type": "application/x-www-form-urlencoded"
3299
+ "Content-Type": "application/json"
2856
3300
  }
2857
- }
2858
- );
2859
- },
2860
- async logout(data) {
2861
- const env2 = getEnv();
2862
- console.log(data);
2863
- return env2?.requests?.post(
2864
- "/logout" /* LOGOUT */,
2865
- {},
2866
- {
3301
+ });
3302
+ },
3303
+ [env]
3304
+ );
3305
+ const isValidToken = (0, import_react6.useCallback)(
3306
+ async (token) => {
3307
+ const bodyData = {
3308
+ token
3309
+ };
3310
+ return env?.requests?.post("/check_token" /* TOKEN */, bodyData, {
2867
3311
  headers: {
2868
3312
  "Content-Type": "application/json"
2869
- },
2870
- withCredentials: true,
2871
- useRefreshToken: true
2872
- }
2873
- );
2874
- }
2875
- };
2876
- var auth_service_default = AuthService;
3313
+ }
3314
+ });
3315
+ },
3316
+ [env]
3317
+ );
3318
+ const isValidActionToken = (0, import_react6.useCallback)(
3319
+ async (actionToken, path) => {
3320
+ return env?.requests?.post(
3321
+ path,
3322
+ {},
3323
+ {
3324
+ headers: {
3325
+ "Content-Type": "application/json"
3326
+ },
3327
+ useActionToken: true,
3328
+ actionToken
3329
+ }
3330
+ );
3331
+ },
3332
+ [env]
3333
+ );
3334
+ const loginSocial = (0, import_react6.useCallback)(
3335
+ async ({
3336
+ db,
3337
+ state,
3338
+ access_token
3339
+ }) => {
3340
+ return env?.requests?.post(
3341
+ "/token/generate" /* GENTOKEN_SOCIAL */,
3342
+ { state, access_token },
3343
+ {
3344
+ headers: {
3345
+ "Content-Type": "application/json"
3346
+ }
3347
+ }
3348
+ );
3349
+ },
3350
+ [env]
3351
+ );
3352
+ const getProviders = (0, import_react6.useCallback)(
3353
+ async (db) => {
3354
+ return env?.requests?.get("/oauth/providers", { params: { db } });
3355
+ },
3356
+ [env]
3357
+ );
3358
+ const getAccessByCode = (0, import_react6.useCallback)(
3359
+ async (code) => {
3360
+ const data = new URLSearchParams();
3361
+ data.append("code", code);
3362
+ data.append("grant_type", "authorization_code");
3363
+ data.append("client_id", env?.config?.clientId || "");
3364
+ data.append("redirect_uri", env?.config?.redirectUri || "");
3365
+ return env?.requests?.post(
3366
+ `${env?.baseUrl?.replace("/mms/", "/id/")}/${"/token" /* TOKEN_BY_CODE */}`,
3367
+ data,
3368
+ {
3369
+ headers: {
3370
+ "Content-Type": "application/x-www-form-urlencoded"
3371
+ }
3372
+ }
3373
+ );
3374
+ },
3375
+ [env]
3376
+ );
3377
+ const logout = (0, import_react6.useCallback)(
3378
+ async (data) => {
3379
+ console.log(data);
3380
+ return env?.requests?.post(
3381
+ "/logout" /* LOGOUT */,
3382
+ {},
3383
+ {
3384
+ headers: {
3385
+ "Content-Type": "application/json"
3386
+ },
3387
+ withCredentials: true,
3388
+ useRefreshToken: true
3389
+ }
3390
+ );
3391
+ },
3392
+ [env]
3393
+ );
3394
+ return {
3395
+ login,
3396
+ forgotPassword,
3397
+ forgotPasswordSSO,
3398
+ resetPassword,
3399
+ resetPasswordSSO,
3400
+ updatePassword,
3401
+ isValidToken,
3402
+ isValidActionToken,
3403
+ loginSocial,
3404
+ getProviders,
3405
+ getAccessByCode,
3406
+ logout
3407
+ };
3408
+ }
2877
3409
 
2878
3410
  // src/services/company-service/index.ts
2879
- var CompanyService = {
2880
- async getCurrentCompany() {
2881
- const env2 = getEnv();
2882
- return await env2.requests.get("/company" /* COMPANY_PATH */, {
3411
+ var import_react7 = require("react");
3412
+ function useCompanyService() {
3413
+ const { env } = useEnv();
3414
+ const getCurrentCompany = (0, import_react7.useCallback)(async () => {
3415
+ return await env.requests.get("/company" /* COMPANY_PATH */, {
2883
3416
  headers: {
2884
3417
  "Content-Type": "application/json"
2885
3418
  }
2886
3419
  });
2887
- },
2888
- async getInfoCompany(id) {
2889
- const env2 = getEnv();
2890
- const jsonData = {
2891
- ids: [id],
2892
- model: "res.company" /* COMPANY */,
2893
- method: "web_read" /* WEB_READ */,
2894
- kwargs: {
2895
- specification: {
2896
- primary_color: {},
2897
- secondary_color: {},
2898
- logo: {},
2899
- display_name: {},
2900
- secondary_logo: {}
3420
+ }, [env]);
3421
+ const getInfoCompany = (0, import_react7.useCallback)(
3422
+ async (id) => {
3423
+ const jsonData = {
3424
+ ids: [id],
3425
+ model: "res.company" /* COMPANY */,
3426
+ method: "web_read" /* WEB_READ */,
3427
+ kwargs: {
3428
+ specification: {
3429
+ primary_color: {},
3430
+ secondary_color: {},
3431
+ logo: {},
3432
+ display_name: {},
3433
+ secondary_logo: {}
3434
+ }
2901
3435
  }
2902
- }
2903
- };
2904
- return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
2905
- headers: {
2906
- "Content-Type": "application/json"
2907
- }
2908
- });
2909
- }
2910
- };
2911
- var company_service_default = CompanyService;
3436
+ };
3437
+ return await env.requests.post("/call" /* CALL_PATH */, jsonData, {
3438
+ headers: {
3439
+ "Content-Type": "application/json"
3440
+ }
3441
+ });
3442
+ },
3443
+ [env]
3444
+ );
3445
+ return {
3446
+ getCurrentCompany,
3447
+ getInfoCompany
3448
+ };
3449
+ }
2912
3450
 
2913
3451
  // src/services/excel-service/index.ts
2914
- var ExcelService = {
2915
- async uploadFile({ formData }) {
2916
- const env2 = getEnv();
2917
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
2918
- headers: {
2919
- "Content-Type": "multipart/form-data"
2920
- }
2921
- });
2922
- },
2923
- async uploadIdFile({ formData }) {
2924
- const env2 = getEnv();
2925
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
2926
- headers: {
2927
- "Content-Type": "multipart/form-data"
2928
- }
2929
- });
2930
- },
2931
- async parsePreview({
2932
- id,
2933
- selectedSheet,
2934
- isHeader,
2935
- context
2936
- }) {
2937
- const env2 = getEnv();
2938
- const jsonData = {
2939
- model: "base_import.import" /* BASE_IMPORT */,
2940
- method: "parse_preview",
2941
- ids: [id],
2942
- kwargs: {
2943
- options: {
2944
- import_skip_records: [],
2945
- import_set_empty_fields: [],
2946
- fallback_values: {},
2947
- name_create_enabled_fields: {},
2948
- encoding: "",
2949
- separator: "",
2950
- quoting: '"',
2951
- date_format: "",
2952
- datetime_format: "",
2953
- float_thousand_separator: ",",
2954
- float_decimal_separator: ".",
2955
- advanced: true,
2956
- has_headers: isHeader,
2957
- keep_matches: false,
2958
- limit: 2e3,
2959
- sheets: [],
2960
- sheet: selectedSheet,
2961
- skip: 0,
2962
- tracking_disable: true
3452
+ var import_react8 = require("react");
3453
+ function useExcelService() {
3454
+ const { env } = useEnv();
3455
+ const uploadFile = (0, import_react8.useCallback)(
3456
+ async ({ formData }) => {
3457
+ return env.requests.post("/upload/file" /* UPLOAD_FILE_PATH */, formData, {
3458
+ headers: {
3459
+ "Content-Type": "multipart/form-data"
2963
3460
  }
2964
- },
2965
- with_context: context
2966
- };
2967
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
2968
- headers: {
2969
- "Content-Type": "multipart/form-data"
2970
- }
2971
- });
2972
- },
2973
- async executeImport({
2974
- columns,
2975
- fields,
2976
- idFile,
2977
- options,
2978
- dryrun,
2979
- context
2980
- }) {
2981
- const env2 = getEnv();
2982
- const jsonData = {
2983
- model: "base_import.import" /* BASE_IMPORT */,
2984
- method: "execute_import",
2985
- ids: [idFile],
2986
- kwargs: {
2987
- fields,
2988
- columns,
2989
- options,
2990
- dryrun
2991
- },
2992
- with_context: context
2993
- };
2994
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
2995
- headers: {
2996
- "Content-Type": "multipart/form-data"
2997
- }
2998
- });
2999
- },
3000
- async getFileExcel({ model }) {
3001
- const env2 = getEnv();
3002
- const jsonData = {
3003
- model,
3004
- method: "get_import_templates" /* GET_IMPORT */,
3005
- args: []
3006
- };
3007
- return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3008
- },
3009
- async getFieldExport({
3010
- ids,
3011
- model,
3012
- isShow,
3013
- parentField,
3014
- fieldType,
3015
- parentName,
3016
- prefix,
3017
- name,
3018
- context,
3019
- importCompat
3020
- }) {
3021
- const env2 = getEnv();
3022
- const jsonData = {
3461
+ });
3462
+ },
3463
+ [env]
3464
+ );
3465
+ const uploadIdFile = (0, import_react8.useCallback)(
3466
+ async ({ formData }) => {
3467
+ return env.requests.post("/upload/file" /* UPLOAD_FILE_PATH */, formData, {
3468
+ headers: {
3469
+ "Content-Type": "multipart/form-data"
3470
+ }
3471
+ });
3472
+ },
3473
+ [env]
3474
+ );
3475
+ const parsePreview = (0, import_react8.useCallback)(
3476
+ async ({
3477
+ id,
3478
+ selectedSheet,
3479
+ isHeader,
3480
+ context
3481
+ }) => {
3482
+ const jsonData = {
3483
+ model: "base_import.import" /* BASE_IMPORT */,
3484
+ method: "parse_preview",
3485
+ ids: [id],
3486
+ kwargs: {
3487
+ options: {
3488
+ import_skip_records: [],
3489
+ import_set_empty_fields: [],
3490
+ fallback_values: {},
3491
+ name_create_enabled_fields: {},
3492
+ encoding: "",
3493
+ separator: "",
3494
+ quoting: '"',
3495
+ date_format: "",
3496
+ datetime_format: "",
3497
+ float_thousand_separator: ",",
3498
+ float_decimal_separator: ".",
3499
+ advanced: true,
3500
+ has_headers: isHeader,
3501
+ keep_matches: false,
3502
+ limit: 2e3,
3503
+ sheets: [],
3504
+ sheet: selectedSheet,
3505
+ skip: 0,
3506
+ tracking_disable: true
3507
+ }
3508
+ },
3509
+ with_context: context
3510
+ };
3511
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3512
+ headers: {
3513
+ "Content-Type": "multipart/form-data"
3514
+ }
3515
+ });
3516
+ },
3517
+ [env]
3518
+ );
3519
+ const executeImport = (0, import_react8.useCallback)(
3520
+ async ({
3521
+ columns,
3522
+ fields,
3523
+ idFile,
3524
+ options,
3525
+ dryrun,
3526
+ context
3527
+ }) => {
3528
+ const jsonData = {
3529
+ model: "base_import.import" /* BASE_IMPORT */,
3530
+ method: "execute_import",
3531
+ ids: [idFile],
3532
+ kwargs: {
3533
+ fields,
3534
+ columns,
3535
+ options,
3536
+ dryrun
3537
+ },
3538
+ with_context: context
3539
+ };
3540
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3541
+ headers: {
3542
+ "Content-Type": "multipart/form-data"
3543
+ }
3544
+ });
3545
+ },
3546
+ [env]
3547
+ );
3548
+ const getFileExcel = (0, import_react8.useCallback)(
3549
+ async ({ model }) => {
3550
+ const jsonData = {
3551
+ model,
3552
+ method: "get_import_templates" /* GET_IMPORT */,
3553
+ args: []
3554
+ };
3555
+ return env.requests.post("/call" /* CALL_PATH */, jsonData);
3556
+ },
3557
+ [env]
3558
+ );
3559
+ const getFieldExport = (0, import_react8.useCallback)(
3560
+ async ({
3561
+ ids,
3023
3562
  model,
3024
- import_compat: importCompat,
3025
- domain: [["id", "in", ids]],
3026
- with_context: context
3027
- };
3028
- if (isShow) {
3029
- jsonData.parent_field = parentField;
3030
- jsonData.parent_field_type = fieldType;
3031
- jsonData.parent_name = parentName;
3032
- jsonData.name = name;
3033
- jsonData.prefix = prefix;
3034
- jsonData.exclude = [null];
3035
- }
3036
- return env2.requests.post("/export/get_fields", jsonData);
3037
- },
3038
- async exportExcel({
3039
- model,
3040
- domain,
3041
- ids,
3042
- fields,
3043
- type,
3044
- importCompat,
3045
- context,
3046
- groupby
3047
- }) {
3048
- const env2 = getEnv();
3049
- const jsonData = {
3563
+ isShow,
3564
+ parentField,
3565
+ fieldType,
3566
+ parentName,
3567
+ prefix,
3568
+ name,
3569
+ context,
3570
+ importCompat
3571
+ }) => {
3572
+ const jsonData = {
3573
+ model,
3574
+ import_compat: importCompat,
3575
+ domain: [["id", "in", ids]],
3576
+ with_context: context
3577
+ };
3578
+ if (isShow) {
3579
+ jsonData.parent_field = parentField;
3580
+ jsonData.parent_field_type = fieldType;
3581
+ jsonData.parent_name = parentName;
3582
+ jsonData.name = name;
3583
+ jsonData.prefix = prefix;
3584
+ jsonData.exclude = [null];
3585
+ }
3586
+ return env.requests.post("/export/get_fields", jsonData);
3587
+ },
3588
+ [env]
3589
+ );
3590
+ const exportExcel = (0, import_react8.useCallback)(
3591
+ async ({
3050
3592
  model,
3051
3593
  domain,
3052
3594
  ids,
3053
- import_compat: importCompat,
3054
3595
  fields,
3055
- with_context: context,
3056
- groupby: groupby ?? []
3057
- };
3058
- return env2.requests.post_excel(`/export/${type}`, jsonData);
3059
- }
3060
- };
3061
- var excel_service_default = ExcelService;
3596
+ type,
3597
+ importCompat,
3598
+ context,
3599
+ groupby
3600
+ }) => {
3601
+ const jsonData = {
3602
+ model,
3603
+ domain,
3604
+ ids,
3605
+ import_compat: importCompat,
3606
+ fields,
3607
+ with_context: context,
3608
+ groupby: groupby ?? []
3609
+ };
3610
+ return env.requests.post_excel(`/export/${type}`, jsonData);
3611
+ },
3612
+ [env]
3613
+ );
3614
+ return {
3615
+ uploadFile,
3616
+ uploadIdFile,
3617
+ parsePreview,
3618
+ executeImport,
3619
+ getFileExcel,
3620
+ getFieldExport,
3621
+ exportExcel
3622
+ };
3623
+ }
3062
3624
 
3063
3625
  // src/services/form-service/index.ts
3064
- var FormService = {
3065
- async getComment({ data }) {
3066
- try {
3067
- const env2 = getEnv();
3626
+ var import_react9 = require("react");
3627
+ function useFormService() {
3628
+ const { env } = useEnv();
3629
+ const getComment = (0, import_react9.useCallback)(
3630
+ async ({ data }) => {
3068
3631
  const jsonData = {
3069
3632
  thread_id: data.thread_id,
3070
3633
  thread_model: data.thread_model,
@@ -3073,19 +3636,16 @@ var FormService = {
3073
3636
  lang: data.lang
3074
3637
  }
3075
3638
  };
3076
- return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3639
+ return env.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3077
3640
  headers: {
3078
3641
  "Content-Type": "application/json"
3079
3642
  }
3080
3643
  });
3081
- } catch (error) {
3082
- console.error("Error when sending message:", error);
3083
- throw error;
3084
- }
3085
- },
3086
- async sentComment({ data }) {
3087
- try {
3088
- const env2 = getEnv();
3644
+ },
3645
+ [env]
3646
+ );
3647
+ const sentComment = (0, import_react9.useCallback)(
3648
+ async ({ data }) => {
3089
3649
  const jsonData = {
3090
3650
  context: {
3091
3651
  tz: "Asia/Saigon",
@@ -3104,39 +3664,33 @@ var FormService = {
3104
3664
  thread_id: Number(data.thread_id),
3105
3665
  thread_model: data.thread_model
3106
3666
  };
3107
- return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3667
+ return env.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3108
3668
  headers: {
3109
3669
  "Content-Type": "application/json"
3110
3670
  }
3111
3671
  });
3112
- } catch (error) {
3113
- console.error("Error when sent message:", error);
3114
- throw error;
3115
- }
3116
- },
3117
- async deleteComment({ data }) {
3118
- try {
3119
- const env2 = getEnv();
3672
+ },
3673
+ [env]
3674
+ );
3675
+ const deleteComment = (0, import_react9.useCallback)(
3676
+ async ({ data }) => {
3120
3677
  const jsonData = {
3121
3678
  attachment_ids: [],
3122
3679
  attachment_tokens: [],
3123
3680
  body: "",
3124
3681
  message_id: data.message_id
3125
3682
  };
3126
- return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3683
+ return env.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3127
3684
  headers: {
3128
3685
  "Content-Type": "application/json"
3129
3686
  }
3130
3687
  });
3131
- } catch (error) {
3132
- console.error("Error when sent message:", error);
3133
- throw error;
3134
- }
3135
- },
3136
- async getImage({ data }) {
3137
- try {
3138
- const env2 = getEnv();
3139
- return env2.requests.get(
3688
+ },
3689
+ [env]
3690
+ );
3691
+ const getImage = (0, import_react9.useCallback)(
3692
+ async ({ data }) => {
3693
+ return env.requests.get(
3140
3694
  `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3141
3695
  {
3142
3696
  headers: {
@@ -3144,384 +3698,400 @@ var FormService = {
3144
3698
  }
3145
3699
  }
3146
3700
  );
3147
- } catch (error) {
3148
- console.error("Error when sent message:", error);
3149
- throw error;
3150
- }
3151
- },
3152
- async uploadImage({ data }) {
3153
- try {
3154
- const env2 = getEnv();
3155
- return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3701
+ },
3702
+ [env]
3703
+ );
3704
+ const uploadImage = (0, import_react9.useCallback)(
3705
+ async ({ data }) => {
3706
+ return env.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3156
3707
  headers: {
3157
3708
  "Content-Type": "multipart/form-data"
3158
3709
  }
3159
3710
  });
3160
- } catch (error) {
3161
- console.error("Error when sent message:", error);
3162
- throw error;
3163
- }
3164
- },
3165
- async getFormView({ data }) {
3166
- try {
3167
- const env2 = getEnv();
3711
+ },
3712
+ [env]
3713
+ );
3714
+ const getFormView = (0, import_react9.useCallback)(
3715
+ async ({ data }) => {
3168
3716
  const jsonData = {
3169
3717
  model: data.model,
3170
3718
  method: "get_formview_action",
3171
3719
  ids: data.id ? [data.id] : [],
3172
3720
  with_context: data.context
3173
3721
  };
3174
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3722
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3175
3723
  headers: {
3176
3724
  "Content-Type": "application/json"
3177
3725
  }
3178
3726
  });
3179
- } catch (error) {
3180
- console.error("Error when fetching form view:", error);
3181
- throw error;
3182
- }
3183
- },
3184
- async changeStatus({ data }) {
3185
- const env2 = getEnv();
3186
- const vals = {
3187
- [data.name]: data.stage_id
3188
- };
3189
- const jsonData = {
3190
- model: data.model,
3191
- method: "web_save",
3192
- with_context: {
3193
- lang: data.lang,
3194
- allowed_company_ids: [1],
3195
- uid: 2,
3196
- search_default_my_ticket: true,
3197
- search_default_is_open: true
3198
- },
3199
- ids: [data.id],
3200
- kwargs: {
3201
- vals,
3202
- specification: {}
3203
- }
3204
- };
3205
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3206
- headers: {
3207
- "Content-Type": "application/json"
3208
- }
3209
- });
3210
- }
3211
- };
3212
- var form_service_default = FormService;
3213
-
3214
- // src/services/kanban-service/index.ts
3215
- var KanbanServices = {
3216
- async getGroups({
3217
- model,
3218
- width_context
3219
- }) {
3220
- const env2 = getEnv();
3221
- const jsonDataView = {
3222
- model,
3223
- method: "web_read_group",
3224
- kwargs: {
3225
- domain: [["stage_id.fold", "=", false]],
3226
- fields: ["color:sum"],
3227
- groupby: ["stage_id"]
3228
- },
3229
- width_context
3230
- };
3231
- return env2.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3232
- headers: {
3233
- "Content-Type": "application/json"
3234
- }
3235
- });
3236
- },
3237
- async getProgressBar({
3238
- field,
3239
- color,
3240
- model,
3241
- width_context
3242
- }) {
3243
- const env2 = getEnv();
3244
- const jsonDataView = {
3245
- model,
3246
- method: "read_progress_bar",
3247
- kwargs: {
3248
- domain: [],
3249
- group_by: "stage_id",
3250
- progress_bar: {
3251
- colors: color,
3252
- field
3727
+ },
3728
+ [env]
3729
+ );
3730
+ const changeStatus = (0, import_react9.useCallback)(
3731
+ async ({ data }) => {
3732
+ const vals = {
3733
+ [data.name]: data.stage_id
3734
+ };
3735
+ const jsonData = {
3736
+ model: data.model,
3737
+ method: "web_save",
3738
+ with_context: {
3739
+ lang: data.lang,
3740
+ allowed_company_ids: [1],
3741
+ uid: 2,
3742
+ search_default_my_ticket: true,
3743
+ search_default_is_open: true
3744
+ },
3745
+ ids: [data.id],
3746
+ kwargs: {
3747
+ vals,
3748
+ specification: {}
3253
3749
  }
3254
- },
3255
- width_context
3256
- };
3257
- return env2.requests.post("/call" /* CALL_PATH */, jsonDataView, {
3258
- headers: {
3259
- "Content-Type": "application/json"
3260
- }
3261
- });
3262
- }
3263
- };
3264
- var kanban_service_default = KanbanServices;
3750
+ };
3751
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3752
+ headers: {
3753
+ "Content-Type": "application/json"
3754
+ }
3755
+ });
3756
+ },
3757
+ [env]
3758
+ );
3759
+ return {
3760
+ getComment,
3761
+ sentComment,
3762
+ deleteComment,
3763
+ getImage,
3764
+ uploadImage,
3765
+ getFormView,
3766
+ changeStatus
3767
+ };
3768
+ }
3265
3769
 
3266
- // src/services/model-service/index.ts
3267
- var OBJECT_POSITION = 2;
3268
- var ModelService = {
3269
- async getListMyBankAccount({
3270
- domain,
3271
- spectification,
3272
- model
3273
- }) {
3274
- const env2 = getEnv();
3275
- const jsonData = {
3276
- model,
3277
- method: "web_search_read",
3278
- kwargs: {
3279
- specification: spectification,
3280
- domain,
3281
- limit: 100,
3282
- offset: 0
3283
- }
3284
- };
3285
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3286
- headers: {
3287
- "Content-Type": "application/json"
3288
- }
3289
- });
3290
- },
3291
- async getCurrency() {
3292
- const env2 = getEnv();
3293
- const jsonData = {
3294
- model: "res.currency",
3295
- method: "web_search_read",
3296
- kwargs: {
3297
- specification: {
3298
- icon_url: {},
3299
- name: {}
3770
+ // src/services/kanban-service/index.ts
3771
+ var import_react10 = require("react");
3772
+ function useKanbanService() {
3773
+ const { env } = useEnv();
3774
+ const getGroups = (0, import_react10.useCallback)(
3775
+ async ({ model, width_context }) => {
3776
+ const jsonData = {
3777
+ model,
3778
+ method: "web_read_group",
3779
+ kwargs: {
3780
+ domain: [["stage_id.fold", "=", false]],
3781
+ fields: ["color:sum"],
3782
+ groupby: ["stage_id"]
3300
3783
  },
3301
- domain: [["active", "=", true]],
3302
- limit: 100,
3303
- offset: 0
3304
- }
3305
- };
3306
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3307
- headers: {
3308
- "Content-Type": "application/json"
3309
- }
3310
- });
3311
- },
3312
- async getConversionRate() {
3313
- const env2 = getEnv();
3314
- const jsonData = {
3315
- model: "res.currency",
3316
- method: "web_search_read",
3317
- kwargs: {
3318
- specification: {
3319
- name: {},
3320
- icon_url: {},
3321
- rate_ids: {
3322
- fields: {
3323
- company_rate: {},
3324
- sell: {}
3325
- }
3784
+ width_context
3785
+ };
3786
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3787
+ headers: {
3788
+ "Content-Type": "application/json"
3789
+ }
3790
+ });
3791
+ },
3792
+ [env]
3793
+ );
3794
+ const getProgressBar = (0, import_react10.useCallback)(
3795
+ async ({ field, color, model, width_context }) => {
3796
+ const jsonData = {
3797
+ model,
3798
+ method: "read_progress_bar",
3799
+ kwargs: {
3800
+ domain: [],
3801
+ group_by: "stage_id",
3802
+ progress_bar: {
3803
+ colors: color,
3804
+ field
3326
3805
  }
3327
3806
  },
3328
- domain: [["active", "=", true]],
3329
- limit: 100,
3330
- offset: 0
3331
- }
3332
- };
3333
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3334
- headers: {
3335
- "Content-Type": "application/json"
3336
- }
3337
- });
3338
- },
3339
- async getAll({ data }) {
3340
- const env2 = getEnv();
3341
- const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3342
- fields: data.fields,
3343
- groupby: data.groupby
3344
- } : {
3345
- count_limit: 10001,
3346
- order: data.sort,
3347
- specification: data.specification
3348
- };
3349
- const jsonData = {
3350
- model: String(data.model),
3351
- method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3352
- ids: data.ids,
3353
- with_context: data.context,
3354
- kwargs: {
3355
- domain: data.domain,
3356
- limit: data.limit,
3357
- offset: data.offset,
3358
- ...jsonReadGroup
3359
- }
3360
- };
3361
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3362
- headers: {
3363
- "Content-Type": "application/json"
3364
- }
3365
- });
3366
- },
3367
- async getListCalendar({ data }) {
3368
- const env2 = getEnv();
3369
- const jsonReadGroup = data.type == "calendar" ? data?.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3370
- fields: data.fields,
3371
- groupby: data.groupby
3372
- } : {
3373
- count_limit: 10001,
3374
- order: data.sort,
3375
- specification: data.specification
3376
- };
3377
- const jsonData = {
3378
- model: String(data.model),
3379
- method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3380
- ids: data.ids,
3381
- with_context: data.context,
3382
- kwargs: {
3383
- domain: data.domain,
3384
- limit: data.limit,
3385
- offset: data.offset,
3386
- fields: data.fields,
3387
- ...jsonReadGroup
3388
- }
3389
- };
3390
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3391
- headers: {
3392
- "Content-Type": "application/json"
3393
- }
3394
- });
3395
- },
3396
- async getList({
3397
- model,
3398
- ids = [],
3399
- specification = {},
3400
- domain = [],
3401
- offset,
3402
- order,
3403
- context = {},
3404
- limit = 10
3405
- }) {
3406
- const env2 = getEnv();
3407
- const jsonData = {
3408
- model,
3409
- method: "web_search_read" /* WEB_SEARCH_READ */,
3410
- ids,
3411
- with_context: context,
3412
- kwargs: {
3413
- specification,
3414
- domain,
3415
- limit,
3416
- offset,
3417
- order
3418
- }
3419
- };
3420
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3421
- headers: {
3422
- "Content-Type": "application/json"
3423
- }
3424
- });
3425
- },
3426
- async getDetail({
3427
- ids = [],
3428
- model,
3429
- specification,
3430
- context
3431
- }) {
3432
- const env2 = getEnv();
3807
+ width_context
3808
+ };
3809
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3810
+ headers: {
3811
+ "Content-Type": "application/json"
3812
+ }
3813
+ });
3814
+ },
3815
+ [env]
3816
+ );
3817
+ return {
3818
+ getGroups,
3819
+ getProgressBar
3820
+ };
3821
+ }
3822
+
3823
+ // src/services/model-service/index.ts
3824
+ var import_react11 = require("react");
3825
+ var OBJECT_POSITION = 2;
3826
+ function useModelService() {
3827
+ const { env } = useEnv();
3828
+ const getListMyBankAccount = (0, import_react11.useCallback)(
3829
+ async ({
3830
+ domain,
3831
+ spectification,
3832
+ model
3833
+ }) => {
3834
+ const jsonData = {
3835
+ model,
3836
+ method: "web_search_read",
3837
+ kwargs: {
3838
+ specification: spectification,
3839
+ domain,
3840
+ limit: 100,
3841
+ offset: 0
3842
+ }
3843
+ };
3844
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3845
+ headers: {
3846
+ "Content-Type": "application/json"
3847
+ }
3848
+ });
3849
+ },
3850
+ [env]
3851
+ );
3852
+ const getCurrency = (0, import_react11.useCallback)(async () => {
3433
3853
  const jsonData = {
3434
- model,
3435
- method: "web_read" /* WEB_READ */,
3436
- ids,
3437
- with_context: context,
3854
+ model: "res.currency",
3855
+ method: "web_search_read",
3438
3856
  kwargs: {
3439
- specification
3857
+ specification: {
3858
+ icon_url: {},
3859
+ name: {}
3860
+ },
3861
+ domain: [["active", "=", true]],
3862
+ limit: 100,
3863
+ offset: 0
3440
3864
  }
3441
3865
  };
3442
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3866
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3443
3867
  headers: {
3444
3868
  "Content-Type": "application/json"
3445
3869
  }
3446
3870
  });
3447
- },
3448
- async save({
3449
- model,
3450
- ids = [],
3451
- data = {},
3452
- specification = {},
3453
- context = {},
3454
- path
3455
- }) {
3456
- const env2 = getEnv();
3871
+ }, [env]);
3872
+ const getConversionRate = (0, import_react11.useCallback)(async () => {
3457
3873
  const jsonData = {
3458
- model,
3459
- method: "web_save" /* WEB_SAVE */,
3460
- with_context: context,
3461
- ids,
3874
+ model: "res.currency",
3875
+ method: "web_search_read",
3462
3876
  kwargs: {
3463
- vals: data,
3464
- specification
3877
+ specification: {
3878
+ name: {},
3879
+ icon_url: {},
3880
+ rate_ids: {
3881
+ fields: {
3882
+ company_rate: {},
3883
+ sell: {}
3884
+ }
3885
+ }
3886
+ },
3887
+ domain: [["active", "=", true]],
3888
+ limit: 100,
3889
+ offset: 0
3465
3890
  }
3466
3891
  };
3467
- return env2?.requests?.post(path ?? "/call" /* CALL_PATH */, jsonData, {
3892
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3468
3893
  headers: {
3469
3894
  "Content-Type": "application/json"
3470
3895
  }
3471
3896
  });
3472
- },
3473
- async delete({ ids = [], model }) {
3474
- const env2 = getEnv();
3475
- const jsonData = {
3897
+ }, [env]);
3898
+ const getAll = (0, import_react11.useCallback)(
3899
+ async ({ data }) => {
3900
+ const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3901
+ fields: data.fields,
3902
+ groupby: data.groupby
3903
+ } : {
3904
+ count_limit: 10001,
3905
+ order: data.sort,
3906
+ specification: data.specification
3907
+ };
3908
+ const jsonData = {
3909
+ model: String(data.model),
3910
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3911
+ ids: data.ids,
3912
+ with_context: data.context,
3913
+ kwargs: {
3914
+ domain: data.domain,
3915
+ limit: data.limit,
3916
+ offset: data.offset,
3917
+ ...jsonReadGroup
3918
+ }
3919
+ };
3920
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3921
+ headers: {
3922
+ "Content-Type": "application/json"
3923
+ }
3924
+ });
3925
+ },
3926
+ [env]
3927
+ );
3928
+ const getListCalendar = (0, import_react11.useCallback)(
3929
+ async ({ data }) => {
3930
+ const jsonReadGroup = data.type == "calendar" ? data?.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3931
+ fields: data.fields,
3932
+ groupby: data.groupby
3933
+ } : {
3934
+ count_limit: 10001,
3935
+ order: data.sort,
3936
+ specification: data.specification
3937
+ };
3938
+ const jsonData = {
3939
+ model: String(data.model),
3940
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3941
+ ids: data.ids,
3942
+ with_context: data.context,
3943
+ kwargs: {
3944
+ domain: data.domain,
3945
+ limit: data.limit,
3946
+ offset: data.offset,
3947
+ fields: data.fields,
3948
+ ...jsonReadGroup
3949
+ }
3950
+ };
3951
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3952
+ headers: {
3953
+ "Content-Type": "application/json"
3954
+ }
3955
+ });
3956
+ },
3957
+ [env]
3958
+ );
3959
+ const getList = (0, import_react11.useCallback)(
3960
+ async ({
3476
3961
  model,
3477
- method: "unlink" /* UNLINK */,
3478
- ids
3479
- };
3480
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3481
- headers: {
3482
- "Content-Type": "application/json"
3483
- }
3484
- });
3485
- },
3486
- async onChange({
3487
- ids = [],
3488
- model,
3489
- object,
3490
- specification,
3491
- context,
3492
- fieldChange
3493
- }) {
3494
- const env2 = getEnv();
3495
- const jsonData = {
3962
+ ids = [],
3963
+ specification = {},
3964
+ domain = [],
3965
+ offset,
3966
+ order,
3967
+ context = {},
3968
+ limit = 10
3969
+ }) => {
3970
+ const jsonData = {
3971
+ model,
3972
+ method: "web_search_read" /* WEB_SEARCH_READ */,
3973
+ ids,
3974
+ with_context: context,
3975
+ kwargs: {
3976
+ specification,
3977
+ domain,
3978
+ limit,
3979
+ offset,
3980
+ order
3981
+ }
3982
+ };
3983
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
3984
+ headers: {
3985
+ "Content-Type": "application/json"
3986
+ }
3987
+ });
3988
+ },
3989
+ [env]
3990
+ );
3991
+ const getDetail = (0, import_react11.useCallback)(
3992
+ async ({ ids = [], model, specification, context }) => {
3993
+ const jsonData = {
3994
+ model,
3995
+ method: "web_read" /* WEB_READ */,
3996
+ ids,
3997
+ with_context: context,
3998
+ kwargs: {
3999
+ specification
4000
+ }
4001
+ };
4002
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
4003
+ headers: {
4004
+ "Content-Type": "application/json"
4005
+ }
4006
+ });
4007
+ },
4008
+ [env]
4009
+ );
4010
+ const save = (0, import_react11.useCallback)(
4011
+ async ({
3496
4012
  model,
3497
- method: "onchange" /* ONCHANGE */,
3498
- ids,
3499
- with_context: context,
3500
- args: [
3501
- object ? object : {},
3502
- fieldChange ? fieldChange : [],
3503
- specification
3504
- ]
3505
- };
3506
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3507
- headers: {
3508
- "Content-Type": "application/json"
3509
- }
3510
- });
3511
- },
3512
- async getListFieldsOnchange({ model }) {
3513
- const env2 = getEnv();
3514
- const jsonData = {
4013
+ ids = [],
4014
+ data = {},
4015
+ specification = {},
4016
+ context = {},
4017
+ path
4018
+ }) => {
4019
+ const jsonData = {
4020
+ model,
4021
+ method: "web_save" /* WEB_SAVE */,
4022
+ with_context: context,
4023
+ ids,
4024
+ kwargs: {
4025
+ vals: data,
4026
+ specification
4027
+ }
4028
+ };
4029
+ return env.requests.post(path ?? "/call" /* CALL_PATH */, jsonData, {
4030
+ headers: {
4031
+ "Content-Type": "application/json"
4032
+ }
4033
+ });
4034
+ },
4035
+ [env]
4036
+ );
4037
+ const deleteApi = (0, import_react11.useCallback)(
4038
+ async ({ ids = [], model }) => {
4039
+ const jsonData = {
4040
+ model,
4041
+ method: "unlink" /* UNLINK */,
4042
+ ids
4043
+ };
4044
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
4045
+ headers: {
4046
+ "Content-Type": "application/json"
4047
+ }
4048
+ });
4049
+ },
4050
+ [env]
4051
+ );
4052
+ const onChange = (0, import_react11.useCallback)(
4053
+ async ({
4054
+ ids = [],
3515
4055
  model,
3516
- method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3517
- };
3518
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3519
- headers: {
3520
- "Content-Type": "application/json"
3521
- }
3522
- });
3523
- },
3524
- parseORMOdoo(data) {
4056
+ object,
4057
+ specification,
4058
+ context,
4059
+ fieldChange
4060
+ }) => {
4061
+ const jsonData = {
4062
+ model,
4063
+ method: "onchange" /* ONCHANGE */,
4064
+ ids,
4065
+ with_context: context,
4066
+ args: [
4067
+ object ? object : {},
4068
+ fieldChange ? fieldChange : [],
4069
+ specification
4070
+ ]
4071
+ };
4072
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
4073
+ headers: {
4074
+ "Content-Type": "application/json"
4075
+ }
4076
+ });
4077
+ },
4078
+ [env]
4079
+ );
4080
+ const getListFieldsOnchange = (0, import_react11.useCallback)(
4081
+ async ({ model }) => {
4082
+ const jsonData = {
4083
+ model,
4084
+ method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
4085
+ };
4086
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
4087
+ headers: {
4088
+ "Content-Type": "application/json"
4089
+ }
4090
+ });
4091
+ },
4092
+ [env]
4093
+ );
4094
+ const parseORMOdoo = (0, import_react11.useCallback)((data) => {
3525
4095
  for (const key in data) {
3526
4096
  if (key === "display_name") {
3527
4097
  delete data[key];
@@ -3533,365 +4103,368 @@ var ModelService = {
3533
4103
  }
3534
4104
  }
3535
4105
  return { ...data };
3536
- },
3537
- toDataJS(data, viewData, model) {
3538
- for (const key in data) {
3539
- if (data[key] === false) {
3540
- if (viewData && model) {
3541
- if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
4106
+ }, []);
4107
+ const toDataJS = (0, import_react11.useCallback)(
4108
+ (data, viewData, model) => {
4109
+ for (const key in data) {
4110
+ if (data[key] === false) {
4111
+ if (viewData && model) {
4112
+ if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
4113
+ data[key] = null;
4114
+ }
4115
+ } else {
3542
4116
  data[key] = null;
3543
4117
  }
3544
- } else {
3545
- data[key] = null;
3546
- }
3547
- } else if (data[key] === "/") {
3548
- data[key] = "Draft";
3549
- } else if (data[key] !== false) {
3550
- if (model !== void 0) {
3551
- if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
3552
- data[key] = (data[key] ??= [])?.map((item) => {
3553
- const relation = viewData?.models?.[model]?.[key]?.relation;
3554
- if (relation !== void 0) {
3555
- if (viewData?.models?.[relation]) {
3556
- if (item?.length >= 3) {
3557
- return ModelService.toDataJS(
3558
- item[OBJECT_POSITION],
3559
- viewData,
3560
- relation
3561
- );
3562
- } else {
3563
- return ModelService.toDataJS(item, viewData, relation);
3564
- }
3565
- } else {
3566
- if (item?.length >= 3) {
3567
- return item[OBJECT_POSITION];
4118
+ } else if (data[key] === "/") {
4119
+ data[key] = "Draft";
4120
+ } else if (data[key] !== false) {
4121
+ if (model !== void 0) {
4122
+ if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
4123
+ data[key] = (data[key] ??= [])?.map((item) => {
4124
+ const relation = viewData?.models?.[model]?.[key]?.relation;
4125
+ if (relation !== void 0) {
4126
+ if (viewData?.models?.[relation]) {
4127
+ if (item?.length >= 3) {
4128
+ return toDataJS(item[OBJECT_POSITION], viewData, relation);
4129
+ } else {
4130
+ return toDataJS(item, viewData, relation);
4131
+ }
3568
4132
  } else {
3569
- return item;
4133
+ if (item?.length >= 3) {
4134
+ return item[OBJECT_POSITION];
4135
+ } else {
4136
+ return item;
4137
+ }
3570
4138
  }
3571
4139
  }
3572
- }
3573
- });
4140
+ });
4141
+ }
3574
4142
  }
3575
4143
  }
3576
4144
  }
3577
- }
3578
- return { ...data };
3579
- }
3580
- };
3581
- var model_service_default = ModelService;
4145
+ return { ...data };
4146
+ },
4147
+ []
4148
+ );
4149
+ return {
4150
+ getListMyBankAccount,
4151
+ getCurrency,
4152
+ getConversionRate,
4153
+ getAll,
4154
+ getListCalendar,
4155
+ getList,
4156
+ getDetail,
4157
+ save,
4158
+ deleteApi,
4159
+ onChange,
4160
+ getListFieldsOnchange,
4161
+ parseORMOdoo,
4162
+ toDataJS
4163
+ };
4164
+ }
3582
4165
 
3583
4166
  // src/services/user-service/index.ts
3584
- var UserService = {
3585
- async getProfile(path) {
3586
- const env2 = getEnv();
3587
- return env2?.requests?.get(path ?? "/userinfo" /* PROFILE_PATH */, {
3588
- headers: {
3589
- "Content-Type": "application/x-www-form-urlencoded"
3590
- }
3591
- });
3592
- },
3593
- async getUser({ context, id }) {
3594
- const env2 = getEnv();
3595
- const jsonData = {
3596
- model: "res.users",
3597
- method: "web_read",
3598
- ids: [id],
3599
- with_context: context,
3600
- kwargs: {
3601
- specification: {
3602
- display_name: {},
3603
- image_1920: {},
3604
- name: {},
3605
- login: {},
3606
- email: {},
3607
- password: {},
3608
- visible_group_id: {
3609
- fields: {
3610
- id: {},
3611
- display_name: {}
3612
- }
3613
- },
3614
- company_id: {
3615
- fields: {
3616
- id: {},
3617
- display_name: {}
4167
+ var import_react12 = require("react");
4168
+ function useUserService() {
4169
+ const { env } = useEnv();
4170
+ const getProfile = (0, import_react12.useCallback)(
4171
+ async (path) => {
4172
+ return env?.requests?.get(path ?? "/userinfo" /* PROFILE_PATH */, {
4173
+ headers: {
4174
+ "Content-Type": "application/x-www-form-urlencoded"
4175
+ }
4176
+ });
4177
+ },
4178
+ [env]
4179
+ );
4180
+ const getUser = (0, import_react12.useCallback)(
4181
+ async ({ context, id }) => {
4182
+ const jsonData = {
4183
+ model: "res.users",
4184
+ method: "web_read",
4185
+ ids: [id],
4186
+ with_context: context,
4187
+ kwargs: {
4188
+ specification: {
4189
+ display_name: {},
4190
+ image_1920: {},
4191
+ name: {},
4192
+ login: {},
4193
+ email: {},
4194
+ password: {},
4195
+ visible_group_id: {
4196
+ fields: {
4197
+ id: {},
4198
+ display_name: {}
4199
+ }
4200
+ },
4201
+ company_id: {
4202
+ fields: {
4203
+ id: {},
4204
+ display_name: {}
4205
+ }
3618
4206
  }
3619
4207
  }
3620
4208
  }
3621
- }
3622
- };
3623
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3624
- headers: {
3625
- "Content-Type": "application/json"
3626
- }
3627
- });
3628
- },
3629
- switchUserLocale: async ({ id, values }) => {
3630
- const env2 = getEnv();
3631
- const jsonData = {
3632
- model: "res.users",
3633
- domain: [["id", "=", id]],
3634
- values
3635
- };
3636
- return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
3637
- headers: {
3638
- "Content-Type": "application/json"
3639
- }
3640
- });
3641
- }
3642
- };
3643
- var user_service_default = UserService;
4209
+ };
4210
+ return env.requests.post("/call" /* CALL_PATH */, jsonData, {
4211
+ headers: {
4212
+ "Content-Type": "application/json"
4213
+ }
4214
+ });
4215
+ },
4216
+ [env]
4217
+ );
4218
+ const switchUserLocale = (0, import_react12.useCallback)(
4219
+ async ({ id, values }) => {
4220
+ const jsonData = {
4221
+ model: "res.users",
4222
+ domain: [["id", "=", id]],
4223
+ values
4224
+ };
4225
+ return env?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4226
+ headers: {
4227
+ "Content-Type": "application/json"
4228
+ }
4229
+ });
4230
+ },
4231
+ [env]
4232
+ );
4233
+ return {
4234
+ getProfile,
4235
+ getUser,
4236
+ switchUserLocale
4237
+ };
4238
+ }
3644
4239
 
3645
4240
  // src/services/view-service/index.ts
3646
- var ViewService = {
3647
- async getView({
3648
- model,
3649
- views,
3650
- context = {},
3651
- options = {},
3652
- aid
3653
- }) {
3654
- const env2 = getEnv();
3655
- const defaultOptions = {
3656
- load_filters: true,
3657
- toolbar: true,
3658
- action_id: aid
3659
- };
3660
- const jsonDataView = {
4241
+ var import_react13 = require("react");
4242
+ function useViewService() {
4243
+ const { env } = useEnv();
4244
+ const getView = (0, import_react13.useCallback)(
4245
+ async ({
3661
4246
  model,
3662
- method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
3663
- kwargs: {
3664
- views,
3665
- options: { ...options, ...defaultOptions }
3666
- },
3667
- with_context: context
3668
- };
3669
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3670
- headers: {
3671
- "Content-Type": "application/json"
3672
- }
3673
- });
3674
- },
3675
- async getMenu(context) {
3676
- const env2 = getEnv();
3677
- const jsonData = {
3678
- model: "ir.ui.menu" /* MENU */,
3679
- method: "web_search_read" /* WEB_SEARCH_READ */,
3680
- ids: [],
3681
- with_context: context,
3682
- kwargs: {
3683
- specification: {
3684
- active: {},
3685
- name: {},
3686
- is_display: {},
3687
- sequence: {},
3688
- complete_name: {},
3689
- action: {
3690
- fields: {
3691
- display_name: {},
3692
- type: {},
3693
- binding_view_types: {}
3694
- // res_model: {},
3695
- }
3696
- },
3697
- url_icon: {},
3698
- web_icon: {},
3699
- web_icon_data: {},
3700
- groups_id: {
3701
- fields: {
3702
- full_name: {}
4247
+ views,
4248
+ context = {},
4249
+ options = {},
4250
+ aid
4251
+ }) => {
4252
+ const defaultOptions = {
4253
+ load_filters: true,
4254
+ toolbar: true,
4255
+ action_id: aid
4256
+ };
4257
+ const jsonDataView = {
4258
+ model,
4259
+ method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
4260
+ kwargs: {
4261
+ views,
4262
+ options: { ...options, ...defaultOptions }
4263
+ },
4264
+ with_context: context
4265
+ };
4266
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4267
+ headers: {
4268
+ "Content-Type": "application/json"
4269
+ }
4270
+ });
4271
+ },
4272
+ [env]
4273
+ );
4274
+ const getMenu = (0, import_react13.useCallback)(
4275
+ async (context) => {
4276
+ const jsonData = {
4277
+ model: "ir.ui.menu" /* MENU */,
4278
+ method: "web_search_read" /* WEB_SEARCH_READ */,
4279
+ ids: [],
4280
+ with_context: context,
4281
+ kwargs: {
4282
+ specification: {
4283
+ active: {},
4284
+ name: {},
4285
+ is_display: {},
4286
+ sequence: {},
4287
+ complete_name: {},
4288
+ action: {
4289
+ fields: {
4290
+ display_name: {},
4291
+ type: {},
4292
+ binding_view_types: {}
4293
+ }
3703
4294
  },
3704
- limit: 40,
3705
- order: ""
3706
- },
3707
- display_name: {},
3708
- child_id: {
3709
- fields: {
3710
- active: {},
3711
- name: {},
3712
- is_display: {},
3713
- sequence: {},
3714
- complete_name: {},
3715
- action: {
3716
- fields: {
3717
- display_name: {},
3718
- type: {},
3719
- binding_view_types: {}
3720
- // res_model: {},
3721
- }
4295
+ url_icon: {},
4296
+ web_icon: {},
4297
+ web_icon_data: {},
4298
+ groups_id: {
4299
+ fields: {
4300
+ full_name: {}
3722
4301
  },
3723
- url_icon: {},
3724
- web_icon: {},
3725
- web_icon_data: {},
3726
- groups_id: {
3727
- fields: {
3728
- full_name: {}
4302
+ limit: 40,
4303
+ order: ""
4304
+ },
4305
+ display_name: {},
4306
+ child_id: {
4307
+ fields: {
4308
+ active: {},
4309
+ name: {},
4310
+ is_display: {},
4311
+ sequence: {},
4312
+ complete_name: {},
4313
+ action: {
4314
+ fields: {
4315
+ display_name: {},
4316
+ type: {},
4317
+ binding_view_types: {}
4318
+ }
3729
4319
  },
3730
- limit: 40,
3731
- order: ""
3732
- },
3733
- display_name: {},
3734
- child_id: {
3735
- fields: {
3736
- active: {},
3737
- name: {},
3738
- is_display: {},
3739
- sequence: {},
3740
- complete_name: {},
3741
- action: {
3742
- fields: {
3743
- display_name: {},
3744
- type: {},
3745
- binding_view_types: {}
3746
- // res_model: {},
3747
- }
4320
+ url_icon: {},
4321
+ web_icon: {},
4322
+ web_icon_data: {},
4323
+ groups_id: {
4324
+ fields: {
4325
+ full_name: {}
3748
4326
  },
3749
- url_icon: {},
3750
- web_icon: {},
3751
- web_icon_data: {},
3752
- groups_id: {
3753
- fields: {
3754
- full_name: {}
4327
+ limit: 40,
4328
+ order: ""
4329
+ },
4330
+ display_name: {},
4331
+ child_id: {
4332
+ fields: {
4333
+ active: {},
4334
+ name: {},
4335
+ is_display: {},
4336
+ sequence: {},
4337
+ complete_name: {},
4338
+ action: {
4339
+ fields: {
4340
+ display_name: {},
4341
+ type: {},
4342
+ binding_view_types: {}
4343
+ }
3755
4344
  },
3756
- limit: 40,
3757
- order: ""
3758
- },
3759
- display_name: {},
3760
- child_id: {
3761
- fields: {
3762
- active: {},
3763
- name: {},
3764
- is_display: {},
3765
- sequence: {},
3766
- complete_name: {},
3767
- action: {
3768
- fields: {
3769
- display_name: {},
3770
- type: {},
3771
- binding_view_types: {}
3772
- // res_model: {},
3773
- }
3774
- },
3775
- url_icon: {},
3776
- web_icon: {},
3777
- web_icon_data: {},
3778
- groups_id: {
3779
- fields: {
3780
- full_name: {}
3781
- },
3782
- limit: 40,
3783
- order: ""
4345
+ url_icon: {},
4346
+ web_icon: {},
4347
+ web_icon_data: {},
4348
+ groups_id: {
4349
+ fields: {
4350
+ full_name: {}
3784
4351
  },
3785
- display_name: {},
3786
- child_id: {
3787
- fields: {},
3788
- limit: 40,
3789
- order: ""
3790
- }
4352
+ limit: 40,
4353
+ order: ""
3791
4354
  },
3792
- limit: 40,
3793
- order: ""
3794
- }
3795
- },
3796
- limit: 40,
3797
- order: ""
3798
- }
3799
- },
3800
- limit: 40,
3801
- order: ""
4355
+ display_name: {},
4356
+ child_id: {
4357
+ fields: {},
4358
+ limit: 40,
4359
+ order: ""
4360
+ }
4361
+ },
4362
+ limit: 40,
4363
+ order: ""
4364
+ }
4365
+ },
4366
+ limit: 40,
4367
+ order: ""
4368
+ }
4369
+ },
4370
+ domain: [
4371
+ "&",
4372
+ ["is_display", "=", true],
4373
+ "&",
4374
+ ["active", "=", true],
4375
+ ["parent_id", "=", false]
4376
+ ]
4377
+ }
4378
+ };
4379
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4380
+ headers: {
4381
+ "Content-Type": "application/json"
4382
+ }
4383
+ });
4384
+ },
4385
+ [env]
4386
+ );
4387
+ const getActionDetail = (0, import_react13.useCallback)(
4388
+ async (aid, context) => {
4389
+ const jsonData = {
4390
+ model: "ir.actions.act_window" /* WINDOW_ACTION */,
4391
+ method: "web_read" /* WEB_READ */,
4392
+ ids: [aid],
4393
+ with_context: context,
4394
+ kwargs: {
4395
+ specification: {
4396
+ id: {},
4397
+ name: {},
4398
+ res_model: {},
4399
+ views: {},
4400
+ view_mode: {},
4401
+ mobile_view_mode: {},
4402
+ domain: {},
4403
+ context: {},
4404
+ groups_id: {},
4405
+ search_view_id: {}
3802
4406
  }
3803
- },
3804
- domain: [
3805
- "&",
3806
- ["is_display", "=", true],
3807
- "&",
3808
- ["active", "=", true],
3809
- ["parent_id", "=", false]
3810
- ]
3811
- }
3812
- };
3813
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3814
- headers: {
3815
- "Content-Type": "application/json"
3816
- }
3817
- });
3818
- },
3819
- async getActionDetail(aid, context) {
3820
- const env2 = getEnv();
3821
- const jsonData = {
3822
- model: "ir.actions.act_window" /* WINDOW_ACTION */,
3823
- method: "web_read" /* WEB_READ */,
3824
- ids: [aid],
3825
- with_context: context,
3826
- kwargs: {
3827
- specification: {
3828
- id: {},
3829
- name: {},
3830
- res_model: {},
3831
- views: {},
3832
- view_mode: {},
3833
- mobile_view_mode: {},
3834
- domain: {},
3835
- context: {},
3836
- groups_id: {},
3837
- search_view_id: {}
3838
4407
  }
3839
- }
3840
- };
3841
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3842
- headers: {
3843
- "Content-Type": "application/json"
3844
- }
3845
- });
3846
- },
3847
- async getResequence({
3848
- model,
3849
- ids,
3850
- context,
3851
- offset
3852
- }) {
3853
- const env2 = getEnv();
3854
- const jsonData = {
4408
+ };
4409
+ return env?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4410
+ headers: {
4411
+ "Content-Type": "application/json"
4412
+ }
4413
+ });
4414
+ },
4415
+ [env]
4416
+ );
4417
+ const getResequence = (0, import_react13.useCallback)(
4418
+ async ({
3855
4419
  model,
3856
- with_context: context,
3857
4420
  ids,
3858
- field: "sequence",
3859
- ...offset > 0 ? { offset } : {}
3860
- };
3861
- return env2?.requests.post("/web/dataset/resequence", jsonData, {
3862
- headers: {
3863
- "Content-Type": "application/json"
3864
- }
3865
- });
3866
- },
3867
- async getSelectionItem({ data }) {
3868
- const env2 = getEnv();
3869
- const jsonData = {
3870
- model: data.model,
3871
- ids: [],
3872
- method: "get_data_select",
3873
- with_context: data.context,
3874
- kwargs: {
3875
- count_limit: 10001,
3876
- domain: data.domain ? data.domain : [],
3877
- offset: 0,
3878
- order: "",
3879
- specification: data?.specification ?? {
3880
- id: {},
3881
- name: {},
3882
- display_name: {}
4421
+ context,
4422
+ offset
4423
+ }) => {
4424
+ const jsonData = {
4425
+ model,
4426
+ with_context: context,
4427
+ ids,
4428
+ field: "sequence",
4429
+ ...offset > 0 ? { offset } : {}
4430
+ };
4431
+ return env?.requests.post("/web/dataset/resequence", jsonData, {
4432
+ headers: {
4433
+ "Content-Type": "application/json"
3883
4434
  }
3884
- }
3885
- };
3886
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3887
- headers: {
3888
- "Content-Type": "application/json"
3889
- }
3890
- });
3891
- },
3892
- async loadMessages() {
3893
- const env2 = getEnv();
3894
- return env2.requests.post(
4435
+ });
4436
+ },
4437
+ [env]
4438
+ );
4439
+ const getSelectionItem = (0, import_react13.useCallback)(
4440
+ async ({ data }) => {
4441
+ const jsonData = {
4442
+ model: data.model,
4443
+ ids: [],
4444
+ method: "get_data_select",
4445
+ with_context: data.context,
4446
+ kwargs: {
4447
+ count_limit: 10001,
4448
+ domain: data.domain ? data.domain : [],
4449
+ offset: 0,
4450
+ order: "",
4451
+ specification: data?.specification ?? {
4452
+ id: {},
4453
+ name: {},
4454
+ display_name: {}
4455
+ }
4456
+ }
4457
+ };
4458
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4459
+ headers: {
4460
+ "Content-Type": "application/json"
4461
+ }
4462
+ });
4463
+ },
4464
+ [env]
4465
+ );
4466
+ const loadMessages = (0, import_react13.useCallback)(async () => {
4467
+ return env.requests.post(
3895
4468
  "/load_message_failures" /* LOAD_MESSAGE */,
3896
4469
  {},
3897
4470
  {
@@ -3900,203 +4473,204 @@ var ViewService = {
3900
4473
  }
3901
4474
  }
3902
4475
  );
3903
- },
3904
- async getVersion() {
3905
- const env2 = getEnv();
3906
- console.log("env?.requests", env2, env2?.requests);
3907
- return env2?.requests?.get("", {
3908
- headers: {
3909
- "Content-Type": "application/json"
3910
- }
3911
- });
3912
- },
3913
- async get2FAMethods({
3914
- method,
3915
- with_context
3916
- }) {
3917
- const env2 = getEnv();
3918
- const jsonData = {
3919
- method,
3920
- with_context
3921
- };
3922
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4476
+ }, [env]);
4477
+ const getVersion = (0, import_react13.useCallback)(async () => {
4478
+ return env?.requests?.get("", {
3923
4479
  headers: {
3924
4480
  "Content-Type": "application/json"
3925
4481
  }
3926
4482
  });
3927
- },
3928
- async verify2FA({
3929
- method,
3930
- with_context,
3931
- code,
3932
- device,
3933
- location
3934
- }) {
3935
- const env2 = getEnv();
3936
- const jsonData = {
3937
- method,
3938
- kwargs: {
3939
- vals: {
3940
- code,
3941
- device,
3942
- location
3943
- }
3944
- },
3945
- with_context
3946
- };
3947
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3948
- headers: {
3949
- "Content-Type": "application/json"
3950
- },
3951
- withCredentials: true
3952
- });
3953
- },
3954
- async signInSSO({
3955
- redirect_uri,
3956
- state,
3957
- client_id,
3958
- response_type,
3959
- path
3960
- }) {
3961
- const env2 = getEnv();
3962
- const params = new URLSearchParams({
3963
- response_type,
3964
- client_id,
3965
- redirect_uri,
3966
- state
3967
- });
3968
- const url = `${path}?${params.toString()}`;
3969
- return env2?.requests.get(url, {
3970
- headers: {
3971
- "Content-Type": "application/json"
3972
- },
3973
- withCredentials: true
3974
- });
3975
- },
3976
- async grantAccess({
3977
- redirect_uri,
3978
- state,
3979
- client_id,
3980
- scopes
3981
- }) {
3982
- const env2 = getEnv();
3983
- const jsonData = {
4483
+ }, [env]);
4484
+ const grantAccess = (0, import_react13.useCallback)(
4485
+ async ({
3984
4486
  redirect_uri,
3985
4487
  state,
3986
4488
  client_id,
3987
4489
  scopes
3988
- };
3989
- return env2?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
3990
- headers: {
3991
- "Content-Type": "application/json"
3992
- },
3993
- withCredentials: true
3994
- });
3995
- },
3996
- async getFieldsViewSecurity({
3997
- method,
3998
- token,
3999
- views
4000
- }) {
4001
- const env2 = getEnv();
4002
- const jsonData = {
4003
- method,
4004
- kwargs: {
4005
- views
4006
- },
4007
- with_context: {
4008
- token
4009
- }
4010
- };
4011
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4012
- headers: {
4013
- "Content-Type": "application/json"
4014
- }
4015
- });
4016
- },
4017
- async settingsWebRead2fa({
4018
- method,
4019
- model,
4020
- kwargs,
4021
- token
4022
- }) {
4023
- const env2 = getEnv();
4024
- const jsonData = {
4490
+ }) => {
4491
+ const jsonData = {
4492
+ redirect_uri,
4493
+ state,
4494
+ client_id,
4495
+ scopes
4496
+ };
4497
+ return env?.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
4498
+ headers: {
4499
+ "Content-Type": "application/json"
4500
+ },
4501
+ withCredentials: true
4502
+ });
4503
+ },
4504
+ [env]
4505
+ );
4506
+ const removeTotpSetUp = (0, import_react13.useCallback)(
4507
+ async ({ method, token }) => {
4508
+ const jsonData = {
4509
+ method,
4510
+ with_context: {
4511
+ token
4512
+ }
4513
+ };
4514
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4515
+ headers: {
4516
+ "Content-Type": "application/json"
4517
+ }
4518
+ });
4519
+ },
4520
+ [env]
4521
+ );
4522
+ const requestSetupTotp = (0, import_react13.useCallback)(
4523
+ async ({ method, token }) => {
4524
+ const jsonData = {
4525
+ method,
4526
+ with_context: { token }
4527
+ };
4528
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4529
+ headers: {
4530
+ "Content-Type": "application/json"
4531
+ }
4532
+ });
4533
+ },
4534
+ [env]
4535
+ );
4536
+ const settingsWebRead2fa = (0, import_react13.useCallback)(
4537
+ async ({
4025
4538
  method,
4026
4539
  model,
4027
4540
  kwargs,
4028
- with_context: {
4029
- token
4030
- }
4031
- };
4032
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4033
- headers: {
4034
- "Content-Type": "application/json"
4035
- }
4036
- });
4037
- },
4038
- async requestSetupTotp({ method, token }) {
4039
- const env2 = getEnv();
4040
- const jsonData = {
4041
- method,
4042
- with_context: {
4043
- token
4044
- }
4045
- };
4046
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4047
- headers: {
4048
- "Content-Type": "application/json"
4049
- }
4050
- });
4051
- },
4052
- async verifyTotp({
4053
- method,
4054
- action_token,
4055
- code
4056
- }) {
4057
- const env2 = getEnv();
4058
- const jsonData = {
4541
+ token
4542
+ }) => {
4543
+ const jsonData = {
4544
+ method,
4545
+ model,
4546
+ kwargs,
4547
+ with_context: {
4548
+ token
4549
+ }
4550
+ };
4551
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4552
+ headers: {
4553
+ "Content-Type": "application/json"
4554
+ }
4555
+ });
4556
+ },
4557
+ [env]
4558
+ );
4559
+ const signInSSO = (0, import_react13.useCallback)(
4560
+ async ({
4561
+ redirect_uri,
4562
+ state,
4563
+ client_id,
4564
+ response_type
4565
+ }) => {
4566
+ const jsonData = {
4567
+ redirect_uri,
4568
+ state,
4569
+ client_id,
4570
+ response_type
4571
+ };
4572
+ return env?.requests.get("/signin-sso/oauth" /* SIGNIN_SSO */, jsonData, {
4573
+ headers: {
4574
+ credentials: "include"
4575
+ }
4576
+ });
4577
+ },
4578
+ [env]
4579
+ );
4580
+ const verify2FA = (0, import_react13.useCallback)(
4581
+ ({
4059
4582
  method,
4060
- kwargs: {
4061
- vals: {
4062
- code
4583
+ with_context,
4584
+ code,
4585
+ device,
4586
+ location
4587
+ }) => {
4588
+ const jsonData = {
4589
+ method,
4590
+ kwargs: {
4591
+ vals: {
4592
+ code,
4593
+ device,
4594
+ location
4595
+ }
4596
+ },
4597
+ with_context
4598
+ };
4599
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4600
+ headers: {
4601
+ "Content-Type": "application/json"
4602
+ },
4603
+ withCredentials: true
4604
+ });
4605
+ },
4606
+ [env]
4607
+ );
4608
+ const get2FAMethods = (0, import_react13.useCallback)(
4609
+ ({ method, with_context }) => {
4610
+ const jsonData = {
4611
+ method,
4612
+ with_context
4613
+ };
4614
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4615
+ headers: {
4616
+ "Content-Type": "application/json"
4063
4617
  }
4064
- },
4065
- with_context: {
4066
- action_token
4067
- }
4068
- };
4069
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4070
- headers: {
4071
- "Content-Type": "application/json"
4072
- }
4073
- });
4074
- },
4075
- async removeTotpSetUp({ method, token }) {
4076
- const env2 = getEnv();
4077
- const jsonData = {
4618
+ });
4619
+ },
4620
+ [env]
4621
+ );
4622
+ const verifyTotp = (0, import_react13.useCallback)(
4623
+ ({
4078
4624
  method,
4079
- with_context: {
4080
- token
4081
- }
4082
- };
4083
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4084
- headers: {
4085
- "Content-Type": "application/json"
4086
- }
4087
- });
4088
- }
4089
- };
4090
- var view_service_default = ViewService;
4625
+ action_token,
4626
+ code
4627
+ }) => {
4628
+ const jsonData = {
4629
+ method,
4630
+ kwargs: {
4631
+ vals: {
4632
+ code
4633
+ }
4634
+ },
4635
+ with_context: {
4636
+ action_token
4637
+ }
4638
+ };
4639
+ return env?.requests.post("/call" /* CALL_PATH */, jsonData, {
4640
+ headers: {
4641
+ "Content-Type": "application/json"
4642
+ }
4643
+ });
4644
+ },
4645
+ [env]
4646
+ );
4647
+ return {
4648
+ getView,
4649
+ getMenu,
4650
+ getActionDetail,
4651
+ getResequence,
4652
+ getSelectionItem,
4653
+ loadMessages,
4654
+ getVersion,
4655
+ grantAccess,
4656
+ removeTotpSetUp,
4657
+ requestSetupTotp,
4658
+ settingsWebRead2fa,
4659
+ signInSSO,
4660
+ verify2FA,
4661
+ get2FAMethods,
4662
+ verifyTotp
4663
+ };
4664
+ }
4091
4665
  // Annotate the CommonJS export names for ESM import in node:
4092
4666
  0 && (module.exports = {
4093
- ActionService,
4094
- AuthService,
4095
- CompanyService,
4096
- ExcelService,
4097
- FormService,
4098
- KanbanService,
4099
- ModelService,
4100
- UserService,
4101
- ViewService
4667
+ useActionService,
4668
+ useAuthService,
4669
+ useCompanyService,
4670
+ useExcelService,
4671
+ useFormService,
4672
+ useKanbanService,
4673
+ useModelService,
4674
+ useUserService,
4675
+ useViewService
4102
4676
  });