@atomsolution/sdk-merchant 1.6.11 → 1.6.12

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.
@@ -26812,16 +26812,8 @@ function MergeAndCheckData({ taxDeductionMethod }) {
26812
26812
  } = useUploadStore();
26813
26813
  const normalize = (str) => str.replace(/\r?\n|\r|\t/g, "").trim();
26814
26814
  let sheetHeaders = sheetData[0] || [];
26815
- sheetHeaders = sheetHeaders.map(
26816
- (h) => typeof h === "string" ? normalize(h) : h
26817
- );
26818
- const {
26819
- mappings,
26820
- setMappings,
26821
- defaultMappings,
26822
- setDefaultMappings,
26823
- resetMappings
26824
- } = useMappingStore();
26815
+ sheetHeaders = sheetHeaders.map((h) => typeof h === "string" ? normalize(h) : h);
26816
+ const { mappings, setMappings, defaultMappings, setDefaultMappings, resetMappings } = useMappingStore();
26825
26817
  const isMappableField = (field) => !EXCLUDED_SYSTEM_FIELDS.includes(field);
26826
26818
  useEffect(() => {
26827
26819
  if (sheetHeaders.length > 0 && Object.keys(defaultMappings).length === 0) {
@@ -26856,9 +26848,7 @@ function MergeAndCheckData({ taxDeductionMethod }) {
26856
26848
  if (taxNumber === 0) {
26857
26849
  priceBeforeTax = Math.round(priceAfterTaxNumber);
26858
26850
  } else {
26859
- priceBeforeTax = Math.round(
26860
- priceAfterTaxNumber / (1 + taxNumber / 100)
26861
- );
26851
+ priceBeforeTax = Math.round(priceAfterTaxNumber / (1 + taxNumber / 100));
26862
26852
  }
26863
26853
  }
26864
26854
  return {
@@ -26990,17 +26980,51 @@ function MergeAndCheckData({ taxDeductionMethod }) {
26990
26980
  ] })
26991
26981
  ] }),
26992
26982
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full px-4 py-4 max-h-[540px] overflow-auto rounded bg-[#F9FAFB]", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-xl p-4 bg-white", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "min-w-full text-xs border-separate border-spacing-0", children: [
26993
- /* @__PURE__ */ jsxRuntimeExports.jsxs("colgroup", { children: [
26994
- /* @__PURE__ */ jsxRuntimeExports.jsx("col", { className: "w-[12%]" }),
26995
- /* @__PURE__ */ jsxRuntimeExports.jsx("col", { className: "w-[25%]" }),
26996
- /* @__PURE__ */ jsxRuntimeExports.jsx("col", { className: "w-[20%]" }),
26997
- /* @__PURE__ */ jsxRuntimeExports.jsx("col", { className: "w-[14%]" }),
26998
- /* @__PURE__ */ jsxRuntimeExports.jsx("col", { className: "w-[10%]" })
26999
- ] }),
26983
+ /* @__PURE__ */ jsxRuntimeExports.jsx("colgroup", { children: (() => {
26984
+ const propMap = {
26985
+ 0: "code",
26986
+ 1: "name",
26987
+ 2: "priceBeforeTax",
26988
+ 3: "tax",
26989
+ 4: "priceAfterTax",
26990
+ 5: "unit",
26991
+ 6: "category"
26992
+ };
26993
+ const getCellString = (row, fieldIndex) => {
26994
+ const prop = propMap[fieldIndex];
26995
+ if (!prop) return "";
26996
+ const val = row[prop];
26997
+ if (fieldIndex === 2 || fieldIndex === 4) {
26998
+ return typeof val === "number" ? formatVND(val) : String(val != null ? val : "");
26999
+ }
27000
+ if (fieldIndex === 3) {
27001
+ return typeof val === "number" ? val + "%" : String(val != null ? val : "");
27002
+ }
27003
+ return String(val != null ? val : "");
27004
+ };
27005
+ const columnWeights = visibleSystemFields.map((field) => {
27006
+ const fieldIndex = systemFields.indexOf(field);
27007
+ let maxLen = field.length;
27008
+ filteredRows.forEach((row) => {
27009
+ const cellStr = getCellString(row, fieldIndex);
27010
+ if (cellStr.length > maxLen) {
27011
+ maxLen = cellStr.length;
27012
+ }
27013
+ });
27014
+ let weight = Math.sqrt(maxLen);
27015
+ if (fieldIndex === 0 || fieldIndex === 1) weight *= 1.2;
27016
+ return weight;
27017
+ });
27018
+ const totalWeight = columnWeights.reduce((a2, b) => a2 + b, 0);
27019
+ return visibleSystemFields.map((_, index) => {
27020
+ const width = `${columnWeights[index] / totalWeight * 100}%`;
27021
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("col", { style: { width } }, index);
27022
+ });
27023
+ })() }),
27000
27024
  /* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: visibleSystemFields.map((field) => /* @__PURE__ */ jsxRuntimeExports.jsx(
27001
27025
  "th",
27002
27026
  {
27003
- className: "px-2 py-3 text-left font-semibold text-[14px] text-[#475467] border-b",
27027
+ className: "px-2 py-3 text-left font-semibold text-[14px] text-[#475467] border-b whitespace-nowrap",
27004
27028
  children: field
27005
27029
  },
27006
27030
  field