@fctc/interface-logic 3.0.2 → 3.0.3

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/provider.js CHANGED
@@ -2892,74 +2892,6 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2892
2892
  return originalRequest.data;
2893
2893
  };
2894
2894
 
2895
- // src/utils/storage/local-storage.ts
2896
- var localStorageUtils = () => {
2897
- const setToken = async (access_token) => {
2898
- localStorage.setItem("accessToken", access_token);
2899
- };
2900
- const setRefreshToken = async (refresh_token) => {
2901
- localStorage.setItem("refreshToken", refresh_token);
2902
- };
2903
- const getAccessToken = async () => {
2904
- return localStorage.getItem("accessToken");
2905
- };
2906
- const getRefreshToken = async () => {
2907
- return localStorage.getItem("refreshToken");
2908
- };
2909
- const clearToken = async () => {
2910
- localStorage.removeItem("accessToken");
2911
- localStorage.removeItem("refreshToken");
2912
- };
2913
- return {
2914
- setToken,
2915
- setRefreshToken,
2916
- getAccessToken,
2917
- getRefreshToken,
2918
- clearToken
2919
- };
2920
- };
2921
-
2922
- // src/utils/storage/session-storage.ts
2923
- var sessionStorageUtils = /* @__PURE__ */ (() => {
2924
- const getMenuFocus = () => {
2925
- const menuFocus = sessionStorage.getItem("menuFocus");
2926
- return menuFocus ? JSON.parse(menuFocus) : {
2927
- id: void 0,
2928
- service: ""
2929
- };
2930
- };
2931
- const setMenuFocus2 = (menuTree) => {
2932
- sessionStorage.setItem("menuFocus", JSON.stringify({ ...menuTree }));
2933
- };
2934
- const getActionData = () => {
2935
- const actionData = sessionStorage.getItem("actionData");
2936
- return actionData ? JSON.parse(actionData) : {};
2937
- };
2938
- const setActionData = (actData) => {
2939
- sessionStorage.setItem("actionData", JSON.stringify(actData));
2940
- };
2941
- const getViewData = () => {
2942
- const viewData = sessionStorage.getItem("viewData");
2943
- return viewData ? JSON.parse(viewData) : {};
2944
- };
2945
- const getBrowserSession = () => {
2946
- const actionData = sessionStorage.getItem("browserSession");
2947
- return actionData ? JSON.parse(actionData) : null;
2948
- };
2949
- const setViewData = (viewData) => {
2950
- sessionStorage.setItem("viewData", JSON.stringify(viewData));
2951
- };
2952
- return {
2953
- getMenuFocus,
2954
- setMenuFocus: setMenuFocus2,
2955
- setActionData,
2956
- getActionData,
2957
- getViewData,
2958
- setViewData,
2959
- getBrowserSession
2960
- };
2961
- })();
2962
-
2963
2895
  // src/services/action-service/index.ts
2964
2896
  function useActionService() {
2965
2897
  const { env } = useEnv();
@@ -5212,6 +5144,61 @@ function useViewService() {
5212
5144
  },
5213
5145
  [env]
5214
5146
  );
5147
+ const getDataCloseSession = (0, import_react10.useCallback)(
5148
+ ({
5149
+ model,
5150
+ ids,
5151
+ xNode,
5152
+ service
5153
+ }) => {
5154
+ const jsonData = {
5155
+ model,
5156
+ ids,
5157
+ method: "get_closing_control_data" /* GET_CLOSING_CONTROL_DATA */
5158
+ };
5159
+ return env?.requests.post(
5160
+ "/call" /* CALL_PATH */,
5161
+ jsonData,
5162
+ {
5163
+ headers: {
5164
+ "Content-Type": "application/json",
5165
+ ...xNode ? { "X-Node": xNode } : {}
5166
+ }
5167
+ },
5168
+ service
5169
+ );
5170
+ },
5171
+ [env]
5172
+ );
5173
+ const getDetailEntity = (0, import_react10.useCallback)(
5174
+ ({
5175
+ model,
5176
+ ids,
5177
+ method,
5178
+ xNode,
5179
+ service,
5180
+ kwargs
5181
+ }) => {
5182
+ const jsonData = {
5183
+ model,
5184
+ ids,
5185
+ method,
5186
+ kwargs
5187
+ };
5188
+ return env?.requests.post(
5189
+ "/call" /* CALL_PATH */,
5190
+ jsonData,
5191
+ {
5192
+ headers: {
5193
+ "Content-Type": "application/json",
5194
+ ...xNode ? { "X-Node": xNode } : {}
5195
+ }
5196
+ },
5197
+ service
5198
+ );
5199
+ },
5200
+ [env]
5201
+ );
5215
5202
  return {
5216
5203
  getView,
5217
5204
  getMenu,
@@ -5243,7 +5230,9 @@ function useViewService() {
5243
5230
  getOrderLine,
5244
5231
  getProductImage,
5245
5232
  addEntity,
5246
- checkPayment
5233
+ checkPayment,
5234
+ getDataCloseSession,
5235
+ getDetailEntity
5247
5236
  };
5248
5237
  }
5249
5238
 
@@ -5288,15 +5277,53 @@ var import_react12 = require("react");
5288
5277
 
5289
5278
  // src/configs/axios-client.ts
5290
5279
  var import_axios = __toESM(require("axios"));
5280
+
5281
+ // src/utils/storage/local-storage.ts
5282
+ var localStorageUtils = () => {
5283
+ const setToken = async (access_token) => {
5284
+ localStorage.setItem("accessToken", access_token);
5285
+ };
5286
+ const setRefreshToken = async (refresh_token) => {
5287
+ localStorage.setItem("refreshToken", refresh_token);
5288
+ };
5289
+ const getAccessToken = async () => {
5290
+ return localStorage.getItem("accessToken");
5291
+ };
5292
+ const getRefreshToken = async () => {
5293
+ return localStorage.getItem("refreshToken");
5294
+ };
5295
+ const clearToken = async () => {
5296
+ localStorage.removeItem("accessToken");
5297
+ localStorage.removeItem("refreshToken");
5298
+ };
5299
+ return {
5300
+ setToken,
5301
+ setRefreshToken,
5302
+ getAccessToken,
5303
+ getRefreshToken,
5304
+ clearToken
5305
+ };
5306
+ };
5307
+
5308
+ // src/utils/storage/session-storage.ts
5309
+ var sessionStorageUtils = () => {
5310
+ const getBrowserSession = async () => {
5311
+ return sessionStorage.getItem("browserSession");
5312
+ };
5313
+ return {
5314
+ getBrowserSession
5315
+ };
5316
+ };
5317
+
5318
+ // src/configs/axios-client.ts
5291
5319
  var axiosClient = {
5292
5320
  init(config) {
5293
5321
  const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
5294
- const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils;
5322
+ const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
5295
5323
  const db = config?.db;
5296
5324
  const database = config?.config?.database;
5297
5325
  let isRefreshing = false;
5298
5326
  let failedQueue = [];
5299
- const xNode = config?.xNode;
5300
5327
  const processQueue = (error, token = null) => {
5301
5328
  failedQueue?.forEach((prom) => {
5302
5329
  if (error) {
@@ -5451,48 +5478,46 @@ var axiosClient = {
5451
5478
  function formatUrl(url, db2) {
5452
5479
  return url + (db2 ? "?db=" + db2 : "");
5453
5480
  }
5454
- const getBaseUrl = (baseUrl) => {
5455
- return config?.default_service === "" ? `${baseUrl.replace(/\/$/, "")}/api/v2` : `${baseUrl.replace(/\/$/, "")}/${sessionStorage2.getMenuFocus().service || config?.default_service}/api/v2`;
5456
- };
5457
- const getHeaders = (header) => {
5458
- const headers = {
5459
- ...header,
5460
- ...xNode ? { "X-Node": xNode } : {}
5461
- };
5462
- return headers;
5481
+ const getBaseUrl = (baseUrl, serviceName) => {
5482
+ const service = serviceName || config?.default_service;
5483
+ return config?.default_service === "" ? `${baseUrl.replace(/\/$/, "")}/api/v2` : `${baseUrl.replace(/\/$/, "")}/${service}/api/v2`;
5463
5484
  };
5464
5485
  const responseBody = (response) => response;
5465
5486
  const requests = {
5466
- get: (url, headers) => instance.get(
5467
- formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5468
- getHeaders(headers)
5487
+ get: (url, headers, serviceName) => instance.get(
5488
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5489
+ headers
5469
5490
  ).then(responseBody),
5470
- post: async (url, body, headers) => instance.post(
5471
- formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5491
+ post: async (url, body, headers, serviceName) => instance.post(
5492
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5472
5493
  body,
5473
- getHeaders(headers)
5494
+ headers
5474
5495
  ).then(responseBody),
5475
- post_excel: (url, body, headers) => instance.post(formatUrl(getBaseUrl(config?.baseUrl) + url, db), body, {
5476
- responseType: "arraybuffer",
5477
- headers: {
5478
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
5479
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
5480
- ...headers
5496
+ post_excel: (url, body, headers, serviceName) => instance.post(
5497
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5498
+ body,
5499
+ {
5500
+ responseType: "arraybuffer",
5501
+ headers: {
5502
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
5503
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
5504
+ ...headers
5505
+ }
5481
5506
  }
5482
- }).then(responseBody),
5483
- put: (url, body, headers) => instance.put(
5484
- formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5507
+ ).then(responseBody),
5508
+ put: (url, body, headers, serviceName) => instance.put(
5509
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5485
5510
  body,
5486
- getHeaders(headers)
5511
+ headers
5487
5512
  ).then(responseBody),
5488
- patch: (url, body, headers) => instance.patch(
5489
- formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5513
+ patch: (url, body, headers, serviceName) => instance.patch(
5514
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5490
5515
  body,
5491
- getHeaders(headers)
5516
+ headers
5492
5517
  ).then(responseBody),
5493
- delete: (url, headers) => instance.delete(
5494
- formatUrl(getBaseUrl(config?.baseUrl) + url, db),
5495
- getHeaders(headers)
5518
+ delete: (url, headers, serviceName) => instance.delete(
5519
+ formatUrl(getBaseUrl(config?.baseUrl, serviceName) + url, db),
5520
+ headers
5496
5521
  ).then(responseBody)
5497
5522
  };
5498
5523
  return requests;
@@ -5526,7 +5551,7 @@ var EnvContext = (0, import_react12.createContext)(null);
5526
5551
  function EnvProvider({
5527
5552
  children,
5528
5553
  localStorageUtils: localStorageUtil = localStorageUtils(),
5529
- sessionStorageUtils: sessionStorageUtil = sessionStorageUtils
5554
+ sessionStorageUtils: sessionStorageUtil = sessionStorageUtils()
5530
5555
  }) {
5531
5556
  const [env, setEnvState] = (0, import_react12.useState)({
5532
5557
  ...initialEnvState,
@@ -7402,6 +7427,54 @@ var useCheckPayment = () => {
7402
7427
  };
7403
7428
  var use_check_payment_default = useCheckPayment;
7404
7429
 
7430
+ // src/hooks/view/use-get-data-close-session.ts
7431
+ var import_react_query87 = require("@tanstack/react-query");
7432
+ var useGetDataCloseSession = () => {
7433
+ const { getDataCloseSession } = useViewService();
7434
+ return (0, import_react_query87.useMutation)({
7435
+ mutationFn: ({
7436
+ model,
7437
+ ids,
7438
+ xNode,
7439
+ service
7440
+ }) => {
7441
+ return getDataCloseSession({
7442
+ model,
7443
+ ids,
7444
+ xNode,
7445
+ service
7446
+ });
7447
+ }
7448
+ });
7449
+ };
7450
+ var use_get_data_close_session_default = useGetDataCloseSession;
7451
+
7452
+ // src/hooks/view/use-get-detail-entity.ts
7453
+ var import_react_query88 = require("@tanstack/react-query");
7454
+ var useGetDetailEntity = () => {
7455
+ const { getDetailEntity } = useViewService();
7456
+ return (0, import_react_query88.useMutation)({
7457
+ mutationFn: ({
7458
+ model,
7459
+ ids,
7460
+ method,
7461
+ xNode,
7462
+ service,
7463
+ kwargs
7464
+ }) => {
7465
+ return getDetailEntity({
7466
+ model,
7467
+ ids,
7468
+ method,
7469
+ xNode,
7470
+ service,
7471
+ kwargs
7472
+ });
7473
+ }
7474
+ });
7475
+ };
7476
+ var use_get_detail_entity_default = useGetDetailEntity;
7477
+
7405
7478
  // src/provider/service-provider.tsx
7406
7479
  var import_jsx_runtime6 = require("react/jsx-runtime");
7407
7480
  var ServiceContext = (0, import_react13.createContext)(null);
@@ -7494,7 +7567,9 @@ var ServiceProvider = ({
7494
7567
  useGetOrderLine: use_get_order_line_default,
7495
7568
  useGetProductImage: use_get_product_image_default,
7496
7569
  useAddEntity: use_add_entity_default,
7497
- useCheckPayment: use_check_payment_default
7570
+ useCheckPayment: use_check_payment_default,
7571
+ useGetDataCloseSession: use_get_data_close_session_default,
7572
+ useGetDetailEntity: use_get_detail_entity_default
7498
7573
  };
7499
7574
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ServiceContext.Provider, { value: services, children });
7500
7575
  };