@atomsolution/sdk-merchant 1.6.13 → 1.7.0

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 (27) hide show
  1. package/dist/assets/locales/en/form.json.d.ts +1 -1
  2. package/dist/assets/locales/vi/form.json.d.ts +1 -1
  3. package/dist/batch-product-creation.cjs +2 -2
  4. package/dist/batch-product-creation.esm.js +2 -2
  5. package/dist/batch-product-creation.js +2 -2
  6. package/dist/digistore.cjs +1 -1
  7. package/dist/digistore.esm.js +1 -1
  8. package/dist/digistore.js +1 -1
  9. package/dist/{dropdownMenuAbsolute-BP6Ub_KP.js → dropdownMenuAbsolute-D9T3Cxw8.js} +2 -2
  10. package/dist/{dropdownMenuAbsolute-BP6Ub_KP.js.map → dropdownMenuAbsolute-D9T3Cxw8.js.map} +1 -1
  11. package/dist/{dropdownMenuAbsolute-CkZt6He5.cjs → dropdownMenuAbsolute-DQsYN_8b.cjs} +2 -2
  12. package/dist/{dropdownMenuAbsolute-CkZt6He5.cjs.map → dropdownMenuAbsolute-DQsYN_8b.cjs.map} +1 -1
  13. package/dist/merchant-profile/MerchantRegistrationForm/AddressFields.d.ts +1 -1
  14. package/dist/merchant-profile/MerchantRegistrationForm/MerchantRegistrationForm.d.ts +2 -2
  15. package/dist/merchant-profile/hooks/use-address.d.ts +2 -0
  16. package/dist/merchant-profile/services/addressService.d.ts +2 -0
  17. package/dist/merchant-profile.cjs +75 -42
  18. package/dist/merchant-profile.cjs.map +1 -1
  19. package/dist/merchant-profile.esm.js +75 -42
  20. package/dist/merchant-profile.esm.js.map +1 -1
  21. package/dist/merchant-profile.js +75 -42
  22. package/dist/merchant-profile.js.map +1 -1
  23. package/dist/{use-translation-C4KiJlNu.js → use-translation-CpsANKUQ.js} +3 -3
  24. package/dist/{use-translation-C4KiJlNu.js.map → use-translation-CpsANKUQ.js.map} +1 -1
  25. package/dist/{use-translation-DYlHWZXS.cjs → use-translation-D7LoHT4I.cjs} +3 -3
  26. package/dist/{use-translation-DYlHWZXS.cjs.map → use-translation-D7LoHT4I.cjs.map} +1 -1
  27. package/package.json +1 -1
@@ -51,8 +51,8 @@ var __async = (__this, __arguments, generator) => {
51
51
  };
52
52
  import { j as jsxRuntimeExports } from "./jsx-runtime-ClP9nxnW.js";
53
53
  import { useState, useCallback, useEffect, useRef, memo, useMemo } from "react";
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-BP6Ub_KP.js";
55
- import { u as useTranslation } from "./use-translation-C4KiJlNu.js";
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
+ import { u as useTranslation } from "./use-translation-CpsANKUQ.js";
56
56
  import { u as usePortalApiConfig } from "./use-portal-api-config.store-C1UTTpK9.js";
57
57
  import axios from "axios";
58
58
  var runtime = { exports: {} };
@@ -1340,7 +1340,7 @@ const portalAxiosClient = axios.create({
1340
1340
  timeout: 1e4
1341
1341
  });
1342
1342
  portalAxiosClient.interceptors.request.use((config) => {
1343
- const baseURL = usePortalApiConfig.getState().baseURL;
1343
+ const baseURL = void 0;
1344
1344
  const accessToken = usePortalApiConfig.getState().accessToken;
1345
1345
  config.baseURL = baseURL;
1346
1346
  if (!config.headers.Authorization) {
@@ -1375,27 +1375,38 @@ const getWards = (districtId) => __async(void 0, null, function* () {
1375
1375
  });
1376
1376
  return data.data;
1377
1377
  });
1378
+ const getNewCities = () => __async(void 0, null, function* () {
1379
+ const { data } = yield portalAxiosClient.get("/address/new-city", {
1380
+ params: { page_size: -1 }
1381
+ });
1382
+ return data.data;
1383
+ });
1384
+ const getNewWards = (cityId) => __async(void 0, null, function* () {
1385
+ const { data } = yield portalAxiosClient.get("/address/new-ward", {
1386
+ params: { city_id: cityId, page_size: -1 }
1387
+ });
1388
+ return data.data;
1389
+ });
1378
1390
  const useAddress = (countryCode, cityCode, districtCode) => {
1379
1391
  const [countries, setCountries] = useState([]);
1380
1392
  const [cities, setCities] = useState([]);
1381
1393
  const [districts, setDistricts] = useState([]);
1382
1394
  const [wards, setWards] = useState([]);
1395
+ const [newCities, setNewCities] = useState([]);
1396
+ const [newWards, setNewWards] = useState([]);
1383
1397
  const resetCities = useCallback(() => setCities([]), []);
1384
1398
  const resetDistricts = useCallback(() => setDistricts([]), []);
1385
1399
  const resetWards = useCallback(() => setWards([]), []);
1400
+ const resetNewWards = useCallback(() => setNewWards([]), []);
1386
1401
  useEffect(() => {
1387
1402
  let active = true;
1388
1403
  const fetchCountries = () => __async(void 0, null, function* () {
1389
1404
  try {
1390
1405
  const data = yield getCountries();
1391
- if (active) {
1392
- setCountries(data);
1393
- }
1406
+ if (active) setCountries(data);
1394
1407
  } catch (error) {
1395
1408
  console.error("Failed to fetch countries:", error);
1396
- if (active) {
1397
- setCountries([]);
1398
- }
1409
+ if (active) setCountries([]);
1399
1410
  }
1400
1411
  });
1401
1412
  if (countries.length === 0) {
@@ -1405,6 +1416,22 @@ const useAddress = (countryCode, cityCode, districtCode) => {
1405
1416
  active = false;
1406
1417
  };
1407
1418
  }, []);
1419
+ useEffect(() => {
1420
+ let active = true;
1421
+ const fetchNewCities = () => __async(void 0, null, function* () {
1422
+ try {
1423
+ const data = yield getNewCities();
1424
+ if (active) setNewCities(data);
1425
+ } catch (error) {
1426
+ console.error("Failed to fetch new cities:", error);
1427
+ if (active) setNewCities([]);
1428
+ }
1429
+ });
1430
+ fetchNewCities();
1431
+ return () => {
1432
+ active = false;
1433
+ };
1434
+ }, []);
1408
1435
  useEffect(() => {
1409
1436
  let active = true;
1410
1437
  const fetchCities = () => __async(void 0, null, function* () {
@@ -1471,14 +1498,10 @@ const useAddress = (countryCode, cityCode, districtCode) => {
1471
1498
  }
1472
1499
  try {
1473
1500
  const data = yield getWards(districtCode);
1474
- if (active) {
1475
- setWards(data);
1476
- }
1501
+ if (active) setWards(data);
1477
1502
  } catch (error) {
1478
1503
  console.error("Failed to fetch wards:", error);
1479
- if (active) {
1480
- setWards([]);
1481
- }
1504
+ if (active) setWards([]);
1482
1505
  }
1483
1506
  });
1484
1507
  fetchWards();
@@ -1486,11 +1509,33 @@ const useAddress = (countryCode, cityCode, districtCode) => {
1486
1509
  active = false;
1487
1510
  };
1488
1511
  }, [districtCode, resetWards]);
1512
+ useEffect(() => {
1513
+ let active = true;
1514
+ const fetchNewWards = () => __async(void 0, null, function* () {
1515
+ if (!cityCode || cityCode.trim() === "") {
1516
+ resetNewWards();
1517
+ return;
1518
+ }
1519
+ try {
1520
+ const data = yield getNewWards(cityCode);
1521
+ if (active) setNewWards(data);
1522
+ } catch (error) {
1523
+ console.error("Failed to fetch new wards:", error);
1524
+ if (active) setNewWards([]);
1525
+ }
1526
+ });
1527
+ fetchNewWards();
1528
+ return () => {
1529
+ active = false;
1530
+ };
1531
+ }, [cityCode, resetNewWards]);
1489
1532
  return {
1490
1533
  countries,
1491
1534
  cities,
1492
1535
  districts,
1493
- wards
1536
+ wards,
1537
+ newCities,
1538
+ newWards
1494
1539
  };
1495
1540
  };
1496
1541
  const AddressFields$2 = ({
@@ -1500,7 +1545,7 @@ const AddressFields$2 = ({
1500
1545
  lang = "vi"
1501
1546
  }) => {
1502
1547
  const { translate } = useTranslation("form", lang);
1503
- const { countries, cities, districts, wards } = useAddress(
1548
+ const { countries, newCities, newWards } = useAddress(
1504
1549
  formData.country,
1505
1550
  formData.city,
1506
1551
  formData.district
@@ -1522,19 +1567,7 @@ const AddressFields$2 = ({
1522
1567
  label: "city",
1523
1568
  name: "city",
1524
1569
  value: formData.city,
1525
- options: cities.map((item) => {
1526
- var _a;
1527
- return {
1528
- value: (_a = item.id) != null ? _a : "",
1529
- label: item.name
1530
- };
1531
- })
1532
- },
1533
- {
1534
- label: "district",
1535
- name: "district",
1536
- value: formData.district,
1537
- options: districts.map((item) => {
1570
+ options: newCities.map((item) => {
1538
1571
  var _a;
1539
1572
  return {
1540
1573
  value: (_a = item.id) != null ? _a : "",
@@ -1546,7 +1579,7 @@ const AddressFields$2 = ({
1546
1579
  label: "ward",
1547
1580
  name: "ward",
1548
1581
  value: formData.ward,
1549
- options: wards.map((item) => {
1582
+ options: newWards.map((item) => {
1550
1583
  var _a;
1551
1584
  return {
1552
1585
  value: (_a = item.id) != null ? _a : "",
@@ -1557,7 +1590,7 @@ const AddressFields$2 = ({
1557
1590
  ];
1558
1591
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
1559
1592
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold font-inter leading-[18px] tracking-normal text-[#2C2C2C]", children: translate("address") }),
1560
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 gap-2", children: selects.map((select) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [
1593
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-2", children: selects.map((select) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [
1561
1594
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
1562
1595
  "select",
1563
1596
  {
@@ -1600,7 +1633,7 @@ const AddressFields$2 = ({
1600
1633
  value: formData.address,
1601
1634
  onChange: (e) => onInputChange("address", e.target.value),
1602
1635
  placeholder: translate("street"),
1603
- 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 `
1636
+ 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`
1604
1637
  }
1605
1638
  ),
1606
1639
  (errors == null ? void 0 : errors.address) && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-red-500 text-xs mt-1", children: errors.address })
@@ -2470,17 +2503,18 @@ const MerchantRegistrationForm = ({
2470
2503
  const [showSuccessModal, setShowSuccessModal] = useState(false);
2471
2504
  const [showErrorModal, setShowErrorModal] = useState(false);
2472
2505
  const [errorMessage, setErrorMessage] = useState("");
2473
- const {
2474
- submit: createMerchant2
2475
- } = useCreateMerchant();
2506
+ const { submit: createMerchant2 } = useCreateMerchant();
2507
+ useEffect(() => {
2508
+ if (accessToken) {
2509
+ usePortalApiConfig.setState({ accessToken });
2510
+ }
2511
+ }, [accessToken]);
2476
2512
  const generateRandomData = () => {
2477
2513
  const characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
2478
2514
  const referralCode = Array.from({ length: 8 }).map(
2479
2515
  () => characters.charAt(Math.floor(Math.random() * characters.length))
2480
2516
  ).join("");
2481
- return {
2482
- referralCode: `${referralCode}`
2483
- };
2517
+ return { referralCode };
2484
2518
  };
2485
2519
  useEffect(() => {
2486
2520
  const randomData = generateRandomData();
@@ -2663,8 +2697,7 @@ const MerchantRegistrationForm = ({
2663
2697
  }
2664
2698
  } catch (err) {
2665
2699
  console.error("Submit error details:", { error: err });
2666
- let displayMessage = translate("submit_error");
2667
- setErrorMessage(displayMessage);
2700
+ setErrorMessage(translate("submit_error"));
2668
2701
  setShowErrorModal(true);
2669
2702
  onError == null ? void 0 : onError(err);
2670
2703
  }
@@ -2712,7 +2745,7 @@ const MerchantRegistrationForm = ({
2712
2745
  "userType",
2713
2746
  e.target.value
2714
2747
  ),
2715
- className: "w-4 h-4 text-blue-600 "
2748
+ className: "w-4 h-4 text-blue-600"
2716
2749
  }
2717
2750
  ),
2718
2751
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-[#2C2C2C]", children: option.label })