@atomsolution/sdk-merchant 1.8.4 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/assets/locales/en/file.json.d.ts +2 -2
  2. package/dist/assets/locales/vi/file.json.d.ts +2 -2
  3. package/dist/batch-product-creation/components/merchant-batch-create-form/product-info-preview/index.d.ts +1 -1
  4. package/dist/batch-product-creation.cjs +42 -35
  5. package/dist/batch-product-creation.cjs.map +1 -1
  6. package/dist/batch-product-creation.esm.js +42 -35
  7. package/dist/batch-product-creation.esm.js.map +1 -1
  8. package/dist/batch-product-creation.js +42 -35
  9. package/dist/batch-product-creation.js.map +1 -1
  10. package/dist/components/common/dataTable/tableHeader.d.ts +1 -1
  11. package/dist/digistore.cjs +1 -1
  12. package/dist/digistore.esm.js +1 -1
  13. package/dist/digistore.js +1 -1
  14. package/dist/{dropdownMenuAbsolute-BvDBLhd-.js → dropdownMenuAbsolute-0z-SL48l.js} +4 -6
  15. package/dist/{dropdownMenuAbsolute-BvDBLhd-.js.map → dropdownMenuAbsolute-0z-SL48l.js.map} +1 -1
  16. package/dist/{dropdownMenuAbsolute-djdsnyTz.cjs → dropdownMenuAbsolute-t4SPWS3W.cjs} +4 -6
  17. package/dist/{dropdownMenuAbsolute-djdsnyTz.cjs.map → dropdownMenuAbsolute-t4SPWS3W.cjs.map} +1 -1
  18. package/dist/merchant-profile.cjs +2 -2
  19. package/dist/merchant-profile.esm.js +2 -2
  20. package/dist/merchant-profile.js +2 -2
  21. package/dist/shared.cjs +1 -1
  22. package/dist/shared.esm.js +1 -1
  23. package/dist/shared.js +1 -1
  24. package/dist/{use-external-config.store-CAZvrNUF.js → use-external-config.store-CaaNmLce.js} +2 -2
  25. package/dist/{use-external-config.store-CAZvrNUF.js.map → use-external-config.store-CaaNmLce.js.map} +1 -1
  26. package/dist/{use-external-config.store-D2beE35F.cjs → use-external-config.store-WVwivWvK.cjs} +2 -2
  27. package/dist/{use-external-config.store-D2beE35F.cjs.map → use-external-config.store-WVwivWvK.cjs.map} +1 -1
  28. package/dist/{use-translation-CD6xknr3.cjs → use-translation-Ba-GPTbc.cjs} +6 -6
  29. package/dist/{use-translation-CD6xknr3.cjs.map → use-translation-Ba-GPTbc.cjs.map} +1 -1
  30. package/dist/{use-translation-DFiePp2h.js → use-translation-Dpu_N-4j.js} +6 -6
  31. package/dist/{use-translation-DFiePp2h.js.map → use-translation-Dpu_N-4j.js.map} +1 -1
  32. package/package.json +1 -1
@@ -68,14 +68,14 @@ var __asyncGenerator = (__this, __arguments, generator) => {
68
68
  };
69
69
  var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
70
70
  import { j as jsxRuntimeExports } from "./jsx-runtime-ClP9nxnW.js";
71
- import { u as useTranslation, t as translate } from "./use-translation-DFiePp2h.js";
71
+ import { u as useTranslation, t as translate } from "./use-translation-Dpu_N-4j.js";
72
72
  import { ToastContainer } from "react-toastify";
73
73
  import { a as useUnsavedChangesStore, u as useWesapApiConfig } from "./use-wesap-api-config.store-CIaEkA7m.js";
74
74
  import * as React from "react";
75
75
  import React__default, { useState, useRef, useEffect, useMemo, forwardRef, useCallback } from "react";
76
76
  import create from "zustand";
77
- import { u as useExternalConfigStore } from "./use-external-config.store-CAZvrNUF.js";
78
- import { t as twMerge, B as Button, c as commonjsRequire, b as commonjsGlobal, g as getDefaultExportFromCjs, u as useMediaQuery, T as TableSkeleton, R as ReusableTable, a as DropdownMenuAbsolute } from "./dropdownMenuAbsolute-BvDBLhd-.js";
77
+ import { u as useExternalConfigStore } from "./use-external-config.store-CaaNmLce.js";
78
+ import { t as twMerge, B as Button, c as commonjsRequire, b as commonjsGlobal, g as getDefaultExportFromCjs, u as useMediaQuery, T as TableSkeleton, R as ReusableTable, a as DropdownMenuAbsolute } from "./dropdownMenuAbsolute-0z-SL48l.js";
79
79
  import * as ReactDOM from "react-dom";
80
80
  import ReactDOM__default from "react-dom";
81
81
  import { C as CustomToast } from "./index-ChOpfqCh.js";
@@ -57982,36 +57982,42 @@ const ProductPreviewTable = ({
57982
57982
  });
57983
57983
  }
57984
57984
  useEffect(() => {
57985
- const handleResetValidateMessages = (productsTableData2) => {
57986
- const resetProducts = productsTableData2.map((product) => __spreadProps(__spreadValues({}, product), {
57987
- note: ""
57988
- }));
57989
- return resetProducts;
57990
- };
57991
- const validate = () => __async(void 0, null, function* () {
57992
- const resetErrorProducts = handleResetValidateMessages(productsTableData);
57993
- yield handleValidateProductsExist(resetErrorProducts);
57994
- const validated = resetErrorProducts.map((product) => {
57995
- let errors = "";
57996
- const schema = createProductPreviewSchema(translate2, taxDeductionMethod);
57997
- const result = schema.safeParse(product);
57998
- if (!result.success) {
57999
- const fields = /* @__PURE__ */ new Set();
58000
- const zErrors = result.error.issues.filter((error) => {
58001
- if (fields.has(error.path[0])) return false;
58002
- fields.add(error.path[0]);
58003
- return true;
58004
- }).map((error) => error.message).join("\n");
58005
- errors = errors + zErrors;
58006
- }
58007
- product.note = product.note + errors;
58008
- return product;
58009
- });
58010
- setValidatedProducts(validated);
57985
+ if (productsTableData.length === 0) {
58011
57986
  setLoading(false);
57987
+ return;
57988
+ }
57989
+ let isMounted = true;
57990
+ const validate = () => __async(void 0, null, function* () {
57991
+ setLoading(true);
57992
+ const productsToValidate = productsTableData.map((p) => __spreadProps(__spreadValues({}, p), { note: "" }));
57993
+ try {
57994
+ yield handleValidateProductsExist(productsToValidate);
57995
+ if (!isMounted) return;
57996
+ const finalValidated = productsToValidate.map((product) => {
57997
+ var _a;
57998
+ let errors = "";
57999
+ const schema = createProductPreviewSchema(translate2, taxDeductionMethod);
58000
+ const result = schema.safeParse(product);
58001
+ if (!result.success) {
58002
+ errors = ((_a = result.error.issues[0]) == null ? void 0 : _a.message) || "";
58003
+ }
58004
+ return __spreadProps(__spreadValues({}, product), { note: product.note + errors });
58005
+ });
58006
+ setValidatedProducts(finalValidated);
58007
+ } catch (err) {
58008
+ console.error(err);
58009
+ } finally {
58010
+ if (isMounted) setLoading(false);
58011
+ }
58012
58012
  });
58013
- validate();
58014
- }, [productsTableData]);
58013
+ const timeoutId = setTimeout(() => {
58014
+ validate();
58015
+ }, 500);
58016
+ return () => {
58017
+ isMounted = false;
58018
+ clearTimeout(timeoutId);
58019
+ };
58020
+ }, [productsTableData, taxDeductionMethod]);
58015
58021
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "overflow-x-auto", children: [
58016
58022
  loading ? /* @__PURE__ */ jsxRuntimeExports.jsx(TableSkeleton, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(
58017
58023
  ReusableTable,
@@ -58049,7 +58055,9 @@ const ProductInfoPreview = ({ taxDeductionMethod }) => {
58049
58055
  const [showCreateProductConfirmModal, setShowCreateProductConfirmModal] = useState(false);
58050
58056
  const [showCreateSuccessModal, setShowSuccessModal] = useState(false);
58051
58057
  const [checkedProducts, setCheckedProducts] = useState([]);
58052
- const [createdProductsResult, setCreatedProductsResult] = useState(null);
58058
+ const [createdProductsResult, setCreatedProductsResult] = useState(
58059
+ null
58060
+ );
58053
58061
  const { sheetMappingData, selectedSheet, uploadedFile, reset } = useUploadStore();
58054
58062
  const filterRow = sheetMappingData.filter((row) => {
58055
58063
  return row.code || row.name || row.priceAfterTax || row.unit || row.category;
@@ -58079,8 +58087,7 @@ const ProductInfoPreview = ({ taxDeductionMethod }) => {
58079
58087
  translate2("upload_information_description2"),
58080
58088
  " ",
58081
58089
  /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { className: "text-[#1E2A7B]", children: uploadedFile == null ? void 0 : uploadedFile.name }),
58082
- ",",
58083
- " ",
58090
+ ", ",
58084
58091
  translate2("sheet"),
58085
58092
  " ",
58086
58093
  /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { className: "text-[#1E2A7B]", children: selectedSheet })
@@ -58107,7 +58114,7 @@ const ProductInfoPreview = ({ taxDeductionMethod }) => {
58107
58114
  setCreatedProductsResult(data);
58108
58115
  setShowSuccessModal(true);
58109
58116
  },
58110
- numCheckedProducts: `${checkedProducts.length}/${sheetMappingData.length}`,
58117
+ numCheckedProducts: `${checkedProducts.length}/${filterRow.length}`,
58111
58118
  checkedProducts,
58112
58119
  taxDeductionMethod
58113
58120
  }