@fctc/interface-logic 2.9.4 → 2.9.6

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.
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { L as LocalStorageUtilsType, S as SessionStorageUtilsType } from './session-storage-ARp_lhTD.mjs';
3
+ import { L as LocalStorageUtilsType, S as SessionStorageUtilsType } from './session-storage-DP3fkZ2Q.mjs';
4
4
  import { useForgotPassword, useForgotPasswordSSO, useGetProvider, useIsValidToken, useLoginCredential, useLoginSocial, useResetPassword, useResetPasswordSSO, useUpdatePassword, useLogout, useGetAccessByCode, useValidateActionToken, useGetCompanyInfo, useGetCurrentCompany, useGetListCompany, useExecuteImport, useExportExcel, useGetFieldExport, useGetFileExcel, useParsePreview, useUploadFileExcel, useUploadIdFile, useChangeStatus, useDeleteComment, useGetComment, useGetFormView, useGetImage, useSendComment, useUploadImage, useDelete, useGetAll, useGetConversionRate, useGetCurrency, useGetDetail, useGetFieldOnChange, useGetListMyBankAccount, useModel, useOdooDataTransform, useOnChangeForm, useSave, useGetProfile, useGetUser, useSwitchLocale, useButton, useDuplicateRecord, useGet2FAMethods, useGetActionDetail, useGetCalendar, useGetGroups, useGetListData, useGetMenu, useGetPrintReport, useGetProGressBar, useGetResequence, useGetSelection, useGetView, useLoadAction, useLoadMessage, usePrint, useRemoveRow, useRunAction, useSignInSSO, useVerify2FA, useGrantAccess, useRemoveTotpSetup, useRequestSetupTotp, useSettingsWebRead2fa, useVerifyTotp, useUploadFile, useCreateEntity, useGetASession, useCreateSession, useDeleteEntity, useGetList, useGetPos, useHandleClosingSession, useManageSession, useUpdateClosedSession, useUpdateEntity, useLoadDataPosSession, useManageOnChange, useGenSerialNumber, useGetOrderLine, useGetProductImage, useAddEntity, useCheckPayment } from './hooks.mjs';
5
5
  import '@tanstack/react-query';
6
6
  import './view-type-xxw9OeSR.mjs';
@@ -44,6 +44,7 @@ interface EnvConfig {
44
44
  localStorageUtils?: LocalStorageUtilsType;
45
45
  sessionStorageUtils?: SessionStorageUtilsType;
46
46
  envFile?: any;
47
+ xNode?: string;
47
48
  }
48
49
  declare function EnvProvider({ children, localStorageUtils: localStorageUtil, sessionStorageUtils: sessionStorageUtil, }: {
49
50
  children: React.ReactNode;
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { L as LocalStorageUtilsType, S as SessionStorageUtilsType } from './session-storage-ARp_lhTD.js';
3
+ import { L as LocalStorageUtilsType, S as SessionStorageUtilsType } from './session-storage-DP3fkZ2Q.js';
4
4
  import { useForgotPassword, useForgotPasswordSSO, useGetProvider, useIsValidToken, useLoginCredential, useLoginSocial, useResetPassword, useResetPasswordSSO, useUpdatePassword, useLogout, useGetAccessByCode, useValidateActionToken, useGetCompanyInfo, useGetCurrentCompany, useGetListCompany, useExecuteImport, useExportExcel, useGetFieldExport, useGetFileExcel, useParsePreview, useUploadFileExcel, useUploadIdFile, useChangeStatus, useDeleteComment, useGetComment, useGetFormView, useGetImage, useSendComment, useUploadImage, useDelete, useGetAll, useGetConversionRate, useGetCurrency, useGetDetail, useGetFieldOnChange, useGetListMyBankAccount, useModel, useOdooDataTransform, useOnChangeForm, useSave, useGetProfile, useGetUser, useSwitchLocale, useButton, useDuplicateRecord, useGet2FAMethods, useGetActionDetail, useGetCalendar, useGetGroups, useGetListData, useGetMenu, useGetPrintReport, useGetProGressBar, useGetResequence, useGetSelection, useGetView, useLoadAction, useLoadMessage, usePrint, useRemoveRow, useRunAction, useSignInSSO, useVerify2FA, useGrantAccess, useRemoveTotpSetup, useRequestSetupTotp, useSettingsWebRead2fa, useVerifyTotp, useUploadFile, useCreateEntity, useGetASession, useCreateSession, useDeleteEntity, useGetList, useGetPos, useHandleClosingSession, useManageSession, useUpdateClosedSession, useUpdateEntity, useLoadDataPosSession, useManageOnChange, useGenSerialNumber, useGetOrderLine, useGetProductImage, useAddEntity, useCheckPayment } from './hooks.js';
5
5
  import '@tanstack/react-query';
6
6
  import './view-type-xxw9OeSR.js';
@@ -44,6 +44,7 @@ interface EnvConfig {
44
44
  localStorageUtils?: LocalStorageUtilsType;
45
45
  sessionStorageUtils?: SessionStorageUtilsType;
46
46
  envFile?: any;
47
+ xNode?: string;
47
48
  }
48
49
  declare function EnvProvider({ children, localStorageUtils: localStorageUtil, sessionStorageUtils: sessionStorageUtil, }: {
49
50
  children: React.ReactNode;
package/dist/provider.js CHANGED
@@ -5250,10 +5250,41 @@ var localStorageUtils = () => {
5250
5250
 
5251
5251
  // src/utils/storage/session-storage.ts
5252
5252
  var sessionStorageUtils = () => {
5253
- const getBrowserSession = async () => {
5254
- return sessionStorage.getItem("browserSession");
5253
+ const getMenuFocus = () => {
5254
+ const menuFocus = sessionStorage.getItem("menuFocus");
5255
+ return menuFocus ? JSON.parse(menuFocus) : {
5256
+ id: void 0,
5257
+ service: ""
5258
+ };
5259
+ };
5260
+ const setMenuFocus2 = (menuTree) => {
5261
+ sessionStorage.setItem("menuFocus", JSON.stringify({ ...menuTree }));
5262
+ };
5263
+ const getActionData = () => {
5264
+ const actionData = sessionStorage.getItem("actionData");
5265
+ return actionData ? JSON.parse(actionData) : {};
5266
+ };
5267
+ const setActionData = (actData) => {
5268
+ sessionStorage.setItem("actionData", JSON.stringify(actData));
5269
+ };
5270
+ const getViewData = () => {
5271
+ const viewData = sessionStorage.getItem("viewData");
5272
+ return viewData ? JSON.parse(viewData) : {};
5273
+ };
5274
+ const getBrowserSession = () => {
5275
+ const actionData = sessionStorage.getItem("browserSession");
5276
+ return actionData ? JSON.parse(actionData) : null;
5277
+ };
5278
+ const setViewData = (viewData) => {
5279
+ sessionStorage.setItem("viewData", JSON.stringify(viewData));
5255
5280
  };
5256
5281
  return {
5282
+ getMenuFocus,
5283
+ setMenuFocus: setMenuFocus2,
5284
+ setActionData,
5285
+ getActionData,
5286
+ getViewData,
5287
+ setViewData,
5257
5288
  getBrowserSession
5258
5289
  };
5259
5290
  };
@@ -5261,12 +5292,16 @@ var sessionStorageUtils = () => {
5261
5292
  // src/configs/axios-client.ts
5262
5293
  var axiosClient = {
5263
5294
  init(config) {
5295
+ console.log("config", config);
5264
5296
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
5265
5297
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
5266
5298
  const db = config?.db;
5267
5299
  const database = config?.config?.database;
5268
5300
  let isRefreshing = false;
5269
5301
  let failedQueue = [];
5302
+ const { env } = useEnv();
5303
+ const xNode = config?.xNode;
5304
+ const service = sessionStorageUtils().getMenuFocus().service || env?.default_service;
5270
5305
  const processQueue = (error, token = null) => {
5271
5306
  failedQueue?.forEach((prom) => {
5272
5307
  if (error) {
@@ -5421,46 +5456,48 @@ var axiosClient = {
5421
5456
  function formatUrl(url, db2) {
5422
5457
  return url + (db2 ? "?db=" + db2 : "");
5423
5458
  }
5424
- const getBaseUrl = (baseUrl, serviceName) => {
5425
- const service = serviceName || config?.default_service;
5459
+ const getBaseUrl = (baseUrl) => {
5426
5460
  return config?.default_service === "" ? `${baseUrl.replace(/\/$/, "")}/api/v2` : `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
5427
5461
  };
5462
+ const getHeaders = (header) => {
5463
+ const headers = {
5464
+ ...header,
5465
+ ...xNode ? { "X-Node": xNode } : {}
5466
+ };
5467
+ return headers;
5468
+ };
5428
5469
  const responseBody = (response) => response;
5429
5470
  const requests = {
5430
- get: (url, headers, serviceName) => instance.get(
5431
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5432
- headers
5471
+ get: (url, headers) => instance.get(
5472
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5473
+ getHeaders(headers)
5433
5474
  ).then(responseBody),
5434
- post: async (url, body, headers, serviceName) => instance.post(
5435
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5475
+ post: async (url, body, headers) => instance.post(
5476
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5436
5477
  body,
5437
- headers
5478
+ getHeaders(headers)
5438
5479
  ).then(responseBody),
5439
- post_excel: (url, body, headers, serviceName) => instance.post(
5440
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5441
- body,
5442
- {
5443
- responseType: "arraybuffer",
5444
- headers: {
5445
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
5446
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
5447
- ...headers
5448
- }
5480
+ post_excel: (url, body, headers) => instance.post(formatUrl(getBaseUrl(config?.baseUrl) + url, db), body, {
5481
+ responseType: "arraybuffer",
5482
+ headers: {
5483
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
5484
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
5485
+ ...headers
5449
5486
  }
5450
- ).then(responseBody),
5451
- put: (url, body, headers, serviceName) => instance.put(
5452
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5487
+ }).then(responseBody),
5488
+ put: (url, body, headers) => instance.put(
5489
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5453
5490
  body,
5454
- headers
5491
+ getHeaders(headers)
5455
5492
  ).then(responseBody),
5456
- patch: (url, body, headers, serviceName) => instance.patch(
5457
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5493
+ patch: (url, body, headers) => instance.patch(
5494
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5458
5495
  body,
5459
- headers
5496
+ getHeaders(headers)
5460
5497
  ).then(responseBody),
5461
- delete: (url, headers, serviceName) => instance.delete(
5462
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5463
- headers
5498
+ delete: (url, headers) => instance.delete(
5499
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5500
+ getHeaders(headers)
5464
5501
  ).then(responseBody)
5465
5502
  };
5466
5503
  return requests;
package/dist/provider.mjs CHANGED
@@ -5207,10 +5207,41 @@ var localStorageUtils = () => {
5207
5207
 
5208
5208
  // src/utils/storage/session-storage.ts
5209
5209
  var sessionStorageUtils = () => {
5210
- const getBrowserSession = async () => {
5211
- return sessionStorage.getItem("browserSession");
5210
+ const getMenuFocus = () => {
5211
+ const menuFocus = sessionStorage.getItem("menuFocus");
5212
+ return menuFocus ? JSON.parse(menuFocus) : {
5213
+ id: void 0,
5214
+ service: ""
5215
+ };
5216
+ };
5217
+ const setMenuFocus2 = (menuTree) => {
5218
+ sessionStorage.setItem("menuFocus", JSON.stringify({ ...menuTree }));
5219
+ };
5220
+ const getActionData = () => {
5221
+ const actionData = sessionStorage.getItem("actionData");
5222
+ return actionData ? JSON.parse(actionData) : {};
5223
+ };
5224
+ const setActionData = (actData) => {
5225
+ sessionStorage.setItem("actionData", JSON.stringify(actData));
5226
+ };
5227
+ const getViewData = () => {
5228
+ const viewData = sessionStorage.getItem("viewData");
5229
+ return viewData ? JSON.parse(viewData) : {};
5230
+ };
5231
+ const getBrowserSession = () => {
5232
+ const actionData = sessionStorage.getItem("browserSession");
5233
+ return actionData ? JSON.parse(actionData) : null;
5234
+ };
5235
+ const setViewData = (viewData) => {
5236
+ sessionStorage.setItem("viewData", JSON.stringify(viewData));
5212
5237
  };
5213
5238
  return {
5239
+ getMenuFocus,
5240
+ setMenuFocus: setMenuFocus2,
5241
+ setActionData,
5242
+ getActionData,
5243
+ getViewData,
5244
+ setViewData,
5214
5245
  getBrowserSession
5215
5246
  };
5216
5247
  };
@@ -5218,12 +5249,16 @@ var sessionStorageUtils = () => {
5218
5249
  // src/configs/axios-client.ts
5219
5250
  var axiosClient = {
5220
5251
  init(config) {
5252
+ console.log("config", config);
5221
5253
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
5222
5254
  const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
5223
5255
  const db = config?.db;
5224
5256
  const database = config?.config?.database;
5225
5257
  let isRefreshing = false;
5226
5258
  let failedQueue = [];
5259
+ const { env } = useEnv();
5260
+ const xNode = config?.xNode;
5261
+ const service = sessionStorageUtils().getMenuFocus().service || env?.default_service;
5227
5262
  const processQueue = (error, token = null) => {
5228
5263
  failedQueue?.forEach((prom) => {
5229
5264
  if (error) {
@@ -5378,46 +5413,48 @@ var axiosClient = {
5378
5413
  function formatUrl(url, db2) {
5379
5414
  return url + (db2 ? "?db=" + db2 : "");
5380
5415
  }
5381
- const getBaseUrl = (baseUrl, serviceName) => {
5382
- const service = serviceName || config?.default_service;
5416
+ const getBaseUrl = (baseUrl) => {
5383
5417
  return config?.default_service === "" ? `${baseUrl.replace(/\/$/, "")}/api/v2` : `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
5384
5418
  };
5419
+ const getHeaders = (header) => {
5420
+ const headers = {
5421
+ ...header,
5422
+ ...xNode ? { "X-Node": xNode } : {}
5423
+ };
5424
+ return headers;
5425
+ };
5385
5426
  const responseBody = (response) => response;
5386
5427
  const requests = {
5387
- get: (url, headers, serviceName) => instance.get(
5388
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5389
- headers
5428
+ get: (url, headers) => instance.get(
5429
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5430
+ getHeaders(headers)
5390
5431
  ).then(responseBody),
5391
- post: async (url, body, headers, serviceName) => instance.post(
5392
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5432
+ post: async (url, body, headers) => instance.post(
5433
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5393
5434
  body,
5394
- headers
5435
+ getHeaders(headers)
5395
5436
  ).then(responseBody),
5396
- post_excel: (url, body, headers, serviceName) => instance.post(
5397
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5398
- body,
5399
- {
5400
- responseType: "arraybuffer",
5401
- headers: {
5402
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
5403
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
5404
- ...headers
5405
- }
5437
+ post_excel: (url, body, headers) => instance.post(formatUrl(getBaseUrl(config?.baseUrl) + url, db), body, {
5438
+ responseType: "arraybuffer",
5439
+ headers: {
5440
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
5441
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
5442
+ ...headers
5406
5443
  }
5407
- ).then(responseBody),
5408
- put: (url, body, headers, serviceName) => instance.put(
5409
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5444
+ }).then(responseBody),
5445
+ put: (url, body, headers) => instance.put(
5446
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5410
5447
  body,
5411
- headers
5448
+ getHeaders(headers)
5412
5449
  ).then(responseBody),
5413
- patch: (url, body, headers, serviceName) => instance.patch(
5414
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5450
+ patch: (url, body, headers) => instance.patch(
5451
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5415
5452
  body,
5416
- headers
5453
+ getHeaders(headers)
5417
5454
  ).then(responseBody),
5418
- delete: (url, headers, serviceName) => instance.delete(
5419
- formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5420
- headers
5455
+ delete: (url, headers) => instance.delete(
5456
+ formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5457
+ getHeaders(headers)
5421
5458
  ).then(responseBody)
5422
5459
  };
5423
5460
  return requests;
@@ -8,8 +8,18 @@ declare const localStorageUtils: () => {
8
8
  type LocalStorageUtilsType = ReturnType<typeof localStorageUtils>;
9
9
 
10
10
  declare const sessionStorageUtils: () => {
11
- getBrowserSession: () => Promise<string | null>;
11
+ getMenuFocus: () => IMenu;
12
+ setMenuFocus: (menuTree: IMenu) => void;
13
+ setActionData: (actData: any) => void;
14
+ getActionData: () => any | null;
15
+ getViewData: () => any | null;
16
+ setViewData: (viewData: any) => void;
17
+ getBrowserSession: () => string | null;
12
18
  };
19
+ interface IMenu {
20
+ id: number | undefined;
21
+ service: string;
22
+ }
13
23
  type SessionStorageUtilsType = ReturnType<typeof sessionStorageUtils>;
14
24
 
15
25
  export type { LocalStorageUtilsType as L, SessionStorageUtilsType as S };
@@ -8,8 +8,18 @@ declare const localStorageUtils: () => {
8
8
  type LocalStorageUtilsType = ReturnType<typeof localStorageUtils>;
9
9
 
10
10
  declare const sessionStorageUtils: () => {
11
- getBrowserSession: () => Promise<string | null>;
11
+ getMenuFocus: () => IMenu;
12
+ setMenuFocus: (menuTree: IMenu) => void;
13
+ setActionData: (actData: any) => void;
14
+ getActionData: () => any | null;
15
+ getViewData: () => any | null;
16
+ setViewData: (viewData: any) => void;
17
+ getBrowserSession: () => string | null;
12
18
  };
19
+ interface IMenu {
20
+ id: number | undefined;
21
+ service: string;
22
+ }
13
23
  type SessionStorageUtilsType = ReturnType<typeof sessionStorageUtils>;
14
24
 
15
25
  export type { LocalStorageUtilsType as L, SessionStorageUtilsType as S };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/interface-logic",
3
- "version": "2.9.4",
3
+ "version": "2.9.6",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",