@atomsolution/sdk-merchant 1.7.0 → 1.7.2

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.
@@ -50,7 +50,7 @@ var __async = (__this, __arguments, generator) => {
50
50
  });
51
51
  };
52
52
  import { j as jsxRuntimeExports } from "./jsx-runtime-ClP9nxnW.js";
53
- import { useState, useCallback, useEffect, useRef, memo, useMemo } from "react";
53
+ import { useState, useCallback, useEffect, useMemo, useRef, memo } from "react";
54
54
  import { c as commonjsRequire, g as getDefaultExportFromCjs, B as Button, D as DropdownMenu, u as useMediaQuery, T as TableSkeleton, R as ReusableTable, a as DropdownMenuAbsolute } from "./dropdownMenuAbsolute-D9T3Cxw8.js";
55
55
  import { u as useTranslation } from "./use-translation-CpsANKUQ.js";
56
56
  import { u as usePortalApiConfig } from "./use-portal-api-config.store-C1UTTpK9.js";
@@ -1340,7 +1340,7 @@ const portalAxiosClient = axios.create({
1340
1340
  timeout: 1e4
1341
1341
  });
1342
1342
  portalAxiosClient.interceptors.request.use((config) => {
1343
- const baseURL = void 0;
1343
+ const baseURL = usePortalApiConfig.getState().baseURL;
1344
1344
  const accessToken = usePortalApiConfig.getState().accessToken;
1345
1345
  config.baseURL = baseURL;
1346
1346
  if (!config.headers.Authorization) {
@@ -1544,65 +1544,80 @@ const AddressFields$2 = ({
1544
1544
  errors,
1545
1545
  lang = "vi"
1546
1546
  }) => {
1547
+ var _a, _b, _c, _d;
1547
1548
  const { translate } = useTranslation("form", lang);
1548
- const { countries, newCities, newWards } = useAddress(
1549
+ const addressData = useAddress(
1549
1550
  formData.country,
1550
1551
  formData.city,
1551
1552
  formData.district
1552
1553
  );
1553
- const selects = [
1554
- {
1555
- label: "country",
1556
- name: "country",
1557
- value: formData.country,
1558
- options: countries.map((item) => {
1559
- var _a;
1560
- return {
1561
- value: (_a = item.id) != null ? _a : "",
1562
- label: item.name
1563
- };
1564
- })
1565
- },
1566
- {
1567
- label: "city",
1568
- name: "city",
1569
- value: formData.city,
1570
- options: newCities.map((item) => {
1571
- var _a;
1572
- return {
1573
- value: (_a = item.id) != null ? _a : "",
1574
- label: item.name
1575
- };
1576
- })
1554
+ const countries = (_a = addressData == null ? void 0 : addressData.countries) != null ? _a : [];
1555
+ const newCities = (_b = addressData == null ? void 0 : addressData.newCities) != null ? _b : [];
1556
+ const newWards = (_c = addressData == null ? void 0 : addressData.newWards) != null ? _c : [];
1557
+ const selects = useMemo(
1558
+ () => {
1559
+ var _a2, _b2, _c2;
1560
+ return [
1561
+ {
1562
+ name: "country",
1563
+ value: (_a2 = formData.country) != null ? _a2 : "",
1564
+ placeholder: translate("country"),
1565
+ options: countries.map((item) => {
1566
+ var _a3, _b3;
1567
+ return {
1568
+ value: (_a3 = item == null ? void 0 : item.id) != null ? _a3 : "",
1569
+ label: (_b3 = item == null ? void 0 : item.name) != null ? _b3 : ""
1570
+ };
1571
+ })
1572
+ },
1573
+ {
1574
+ name: "city",
1575
+ value: (_b2 = formData.city) != null ? _b2 : "",
1576
+ placeholder: translate("city"),
1577
+ options: newCities.map((item) => {
1578
+ var _a3, _b3;
1579
+ return {
1580
+ value: (_a3 = item == null ? void 0 : item.id) != null ? _a3 : "",
1581
+ label: (_b3 = item == null ? void 0 : item.name) != null ? _b3 : ""
1582
+ };
1583
+ })
1584
+ },
1585
+ {
1586
+ name: "ward",
1587
+ value: (_c2 = formData.ward) != null ? _c2 : "",
1588
+ placeholder: translate("ward"),
1589
+ options: newWards.map((item) => {
1590
+ var _a3, _b3;
1591
+ return {
1592
+ value: (_a3 = item == null ? void 0 : item.id) != null ? _a3 : "",
1593
+ label: (_b3 = item == null ? void 0 : item.name) != null ? _b3 : ""
1594
+ };
1595
+ })
1596
+ }
1597
+ ];
1577
1598
  },
1578
- {
1579
- label: "ward",
1580
- name: "ward",
1581
- value: formData.ward,
1582
- options: newWards.map((item) => {
1583
- var _a;
1584
- return {
1585
- value: (_a = item.id) != null ? _a : "",
1586
- label: item.name
1587
- };
1588
- })
1589
- }
1590
- ];
1599
+ [
1600
+ countries,
1601
+ newCities,
1602
+ newWards,
1603
+ translate,
1604
+ formData.country,
1605
+ formData.city,
1606
+ formData.ward
1607
+ ]
1608
+ );
1591
1609
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
1592
1610
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold font-inter leading-[18px] tracking-normal text-[#2C2C2C]", children: translate("address") }),
1593
1611
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-2", children: selects.map((select) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [
1594
1612
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
1595
1613
  "select",
1596
1614
  {
1597
- value: select.value,
1598
- onChange: (e) => onInputChange(
1599
- select.name,
1600
- e.target.value
1601
- ),
1615
+ value: select.value || "",
1616
+ onChange: (e) => onInputChange(select.name, e.target.value),
1602
1617
  className: `appearance-none w-full px-4 py-3 border ${(errors == null ? void 0 : errors[select.name]) ? "border-red-500" : "border-[#E4E7EC]"} rounded-[8px] focus:outline-none focus:ring-2 focus:ring-blue-500 text-[#6B7280] font-inter text-sm font-normal leading-[18px] tracking-normal hover:ring-2 hover:ring-blue-900`,
1603
1618
  children: [
1604
- /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: translate(select.label) }),
1605
- (select.options || []).map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: option.value, children: option.label }, option.value))
1619
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", disabled: true, hidden: true, children: select.placeholder }),
1620
+ select.options.map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: option.value, children: option.label }, option.value))
1606
1621
  ]
1607
1622
  }
1608
1623
  ),
@@ -1630,7 +1645,7 @@ const AddressFields$2 = ({
1630
1645
  "input",
1631
1646
  {
1632
1647
  type: "text",
1633
- value: formData.address,
1648
+ value: (_d = formData.address) != null ? _d : "",
1634
1649
  onChange: (e) => onInputChange("address", e.target.value),
1635
1650
  placeholder: translate("street"),
1636
1651
  className: `w-full px-3 py-3 border hover:ring-2 hover:ring-blue-900 ${(errors == null ? void 0 : errors.address) ? "border-red-500" : "border-[#E4E7EC]"} rounded-md text-[#6B7280] font-inter text-sm font-normal leading-[18px] tracking-normal`
@@ -1829,16 +1844,14 @@ const useMCCList = () => {
1829
1844
  }, []);
1830
1845
  return { industries, loading, error };
1831
1846
  };
1832
- const IndustrySelect = memo(({
1833
- value,
1834
- onChange,
1835
- lang = "vi"
1836
- }) => {
1837
- const { translate } = useTranslation("form", lang);
1838
- const { industries, loading, error } = useMCCList();
1839
- const isDisabled = loading || Boolean(error);
1840
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1841
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1847
+ const IndustrySelect = memo(
1848
+ ({ value, onChange, lang = "vi" }) => {
1849
+ const { translate } = useTranslation("form", lang);
1850
+ const { industries, loading, error } = useMCCList();
1851
+ const safeIndustries = useMemo(() => industries != null ? industries : [], [industries]);
1852
+ const isDisabled = Boolean(loading) || Boolean(error);
1853
+ const errorMessage = typeof error === "string" ? error : error && typeof error === "object" && "message" in error ? String(error.message) : error ? String(error) : "";
1854
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1842
1855
  /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-semibold text-[#2C2C2C] mb-2", children: [
1843
1856
  translate("industry"),
1844
1857
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500 ml-1", children: "*" })
@@ -1847,19 +1860,19 @@ const IndustrySelect = memo(({
1847
1860
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
1848
1861
  "select",
1849
1862
  {
1850
- value,
1863
+ value: value != null ? value : "",
1851
1864
  onChange: (e) => onChange(e.target.value),
1852
1865
  className: `
1853
- appearance-none w-full px-4 py-3 pr-10 border rounded-[8px]
1854
- focus:outline-none focus:ring-2 focus:ring-blue-500
1855
- text-[#6B7280] font-inter text-sm font-normal leading-[18px]
1856
- tracking-normal hover:ring-2 hover:ring-blue-900
1857
- ${isDisabled ? "bg-gray-100 cursor-not-allowed" : "bg-white"}
1858
- `,
1866
+ appearance-none w-full px-4 py-3 pr-10 border rounded-[8px]
1867
+ focus:outline-none focus:ring-2 focus:ring-blue-500
1868
+ text-[#6B7280] font-inter text-sm font-normal leading-[18px]
1869
+ tracking-normal hover:ring-2 hover:ring-blue-900
1870
+ ${isDisabled ? "bg-gray-100 cursor-not-allowed" : "bg-white"}
1871
+ `,
1859
1872
  disabled: isDisabled,
1860
1873
  children: [
1861
1874
  /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: translate("select_industry") }),
1862
- industries.map((industry) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: industry.code, children: industry.name }, industry.code))
1875
+ safeIndustries.map((industry) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: industry.code, children: industry.name }, industry.code))
1863
1876
  ]
1864
1877
  }
1865
1878
  ),
@@ -1881,12 +1894,12 @@ const IndustrySelect = memo(({
1881
1894
  )
1882
1895
  }
1883
1896
  ) })
1884
- ] })
1885
- ] }),
1886
- loading && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-blue-500 mt-2", children: translate("loading_industries") }),
1887
- error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-red-500 mt-2", children: error })
1888
- ] });
1889
- });
1897
+ ] }),
1898
+ loading && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-blue-500 mt-2", children: translate("loading_industries") }),
1899
+ Boolean(errorMessage) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-red-500 mt-2", children: errorMessage })
1900
+ ] });
1901
+ }
1902
+ );
1890
1903
  IndustrySelect.displayName = "IndustrySelect";
1891
1904
  const Input = ({
1892
1905
  label,