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