@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.
- package/dist/assets/locales/en/form.json.d.ts +1 -1
- package/dist/assets/locales/vi/form.json.d.ts +1 -1
- package/dist/batch-product-creation.cjs +2 -2
- package/dist/batch-product-creation.esm.js +2 -2
- package/dist/batch-product-creation.js +2 -2
- package/dist/digistore.cjs +1 -1
- package/dist/digistore.esm.js +1 -1
- package/dist/digistore.js +1 -1
- package/dist/{dropdownMenuAbsolute-BP6Ub_KP.js → dropdownMenuAbsolute-D9T3Cxw8.js} +2 -2
- package/dist/{dropdownMenuAbsolute-BP6Ub_KP.js.map → dropdownMenuAbsolute-D9T3Cxw8.js.map} +1 -1
- package/dist/{dropdownMenuAbsolute-CkZt6He5.cjs → dropdownMenuAbsolute-DQsYN_8b.cjs} +2 -2
- package/dist/{dropdownMenuAbsolute-CkZt6He5.cjs.map → dropdownMenuAbsolute-DQsYN_8b.cjs.map} +1 -1
- package/dist/merchant-profile/MerchantRegistrationForm/AddressFields.d.ts +1 -1
- package/dist/merchant-profile/MerchantRegistrationForm/MerchantRegistrationForm.d.ts +2 -2
- package/dist/merchant-profile/hooks/use-address.d.ts +2 -0
- package/dist/merchant-profile/services/addressService.d.ts +2 -0
- package/dist/merchant-profile.cjs +75 -42
- package/dist/merchant-profile.cjs.map +1 -1
- package/dist/merchant-profile.esm.js +75 -42
- package/dist/merchant-profile.esm.js.map +1 -1
- package/dist/merchant-profile.js +75 -42
- package/dist/merchant-profile.js.map +1 -1
- package/dist/{use-translation-C4KiJlNu.js → use-translation-CpsANKUQ.js} +3 -3
- package/dist/{use-translation-C4KiJlNu.js.map → use-translation-CpsANKUQ.js.map} +1 -1
- package/dist/{use-translation-DYlHWZXS.cjs → use-translation-D7LoHT4I.cjs} +3 -3
- package/dist/{use-translation-DYlHWZXS.cjs.map → use-translation-D7LoHT4I.cjs.map} +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ interface AddressFieldsProps {
|
|
|
10
10
|
formData: MerchantFormData;
|
|
11
11
|
onInputChange: (field: keyof MerchantFormData, value: string) => void;
|
|
12
12
|
errors?: Partial<Record<keyof MerchantFormData, string>>;
|
|
13
|
-
lang?:
|
|
13
|
+
lang?: 'vi' | 'en';
|
|
14
14
|
}
|
|
15
15
|
export declare const AddressFields: React.FC<AddressFieldsProps>;
|
|
16
16
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { FormData } from '../types/formData';
|
|
3
3
|
interface SubmitPayload {
|
|
4
|
-
entity_type:
|
|
4
|
+
entity_type: 'PERSON' | 'BUSINESS_HOUSEHOLD' | 'ENTERPRISE';
|
|
5
5
|
tax_code: string;
|
|
6
6
|
full_name: string;
|
|
7
7
|
brand_name?: string;
|
|
@@ -31,7 +31,7 @@ interface MerchantRegistrationFormProps {
|
|
|
31
31
|
className?: string;
|
|
32
32
|
merchantId?: string;
|
|
33
33
|
isHeader?: boolean;
|
|
34
|
-
lang?:
|
|
34
|
+
lang?: 'vi' | 'en';
|
|
35
35
|
}
|
|
36
36
|
export declare const MerchantRegistrationForm: React.FC<MerchantRegistrationFormProps>;
|
|
37
37
|
export {};
|
|
@@ -7,4 +7,6 @@ export declare const getCountries: () => Promise<LocationOption[]>;
|
|
|
7
7
|
export declare const getCities: (countryCode: string) => Promise<LocationOption[]>;
|
|
8
8
|
export declare const getDistricts: (cityId: string) => Promise<LocationOption[]>;
|
|
9
9
|
export declare const getWards: (districtId: string) => Promise<LocationOption[]>;
|
|
10
|
+
export declare const getNewCities: () => Promise<LocationOption[]>;
|
|
11
|
+
export declare const getNewWards: (cityId: string) => Promise<LocationOption[]>;
|
|
10
12
|
export {};
|
|
@@ -53,8 +53,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
53
53
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
54
54
|
const jsxRuntime = require("./jsx-runtime-DV8UmLi4.cjs");
|
|
55
55
|
const React = require("react");
|
|
56
|
-
const dropdownMenuAbsolute = require("./dropdownMenuAbsolute-
|
|
57
|
-
const useTranslation = require("./use-translation-
|
|
56
|
+
const dropdownMenuAbsolute = require("./dropdownMenuAbsolute-DQsYN_8b.cjs");
|
|
57
|
+
const useTranslation = require("./use-translation-D7LoHT4I.cjs");
|
|
58
58
|
const usePortalApiConfig_store = require("./use-portal-api-config.store-C8a2gebE.cjs");
|
|
59
59
|
const axios = require("axios");
|
|
60
60
|
var runtime = { exports: {} };
|
|
@@ -1342,7 +1342,7 @@ const portalAxiosClient = axios.create({
|
|
|
1342
1342
|
timeout: 1e4
|
|
1343
1343
|
});
|
|
1344
1344
|
portalAxiosClient.interceptors.request.use((config) => {
|
|
1345
|
-
const baseURL =
|
|
1345
|
+
const baseURL = void 0;
|
|
1346
1346
|
const accessToken = usePortalApiConfig_store.usePortalApiConfig.getState().accessToken;
|
|
1347
1347
|
config.baseURL = baseURL;
|
|
1348
1348
|
if (!config.headers.Authorization) {
|
|
@@ -1377,27 +1377,38 @@ const getWards = (districtId) => __async(exports, null, function* () {
|
|
|
1377
1377
|
});
|
|
1378
1378
|
return data.data;
|
|
1379
1379
|
});
|
|
1380
|
+
const getNewCities = () => __async(exports, null, function* () {
|
|
1381
|
+
const { data } = yield portalAxiosClient.get("/address/new-city", {
|
|
1382
|
+
params: { page_size: -1 }
|
|
1383
|
+
});
|
|
1384
|
+
return data.data;
|
|
1385
|
+
});
|
|
1386
|
+
const getNewWards = (cityId) => __async(exports, null, function* () {
|
|
1387
|
+
const { data } = yield portalAxiosClient.get("/address/new-ward", {
|
|
1388
|
+
params: { city_id: cityId, page_size: -1 }
|
|
1389
|
+
});
|
|
1390
|
+
return data.data;
|
|
1391
|
+
});
|
|
1380
1392
|
const useAddress = (countryCode, cityCode, districtCode) => {
|
|
1381
1393
|
const [countries, setCountries] = React.useState([]);
|
|
1382
1394
|
const [cities, setCities] = React.useState([]);
|
|
1383
1395
|
const [districts, setDistricts] = React.useState([]);
|
|
1384
1396
|
const [wards, setWards] = React.useState([]);
|
|
1397
|
+
const [newCities, setNewCities] = React.useState([]);
|
|
1398
|
+
const [newWards, setNewWards] = React.useState([]);
|
|
1385
1399
|
const resetCities = React.useCallback(() => setCities([]), []);
|
|
1386
1400
|
const resetDistricts = React.useCallback(() => setDistricts([]), []);
|
|
1387
1401
|
const resetWards = React.useCallback(() => setWards([]), []);
|
|
1402
|
+
const resetNewWards = React.useCallback(() => setNewWards([]), []);
|
|
1388
1403
|
React.useEffect(() => {
|
|
1389
1404
|
let active = true;
|
|
1390
1405
|
const fetchCountries = () => __async(exports, null, function* () {
|
|
1391
1406
|
try {
|
|
1392
1407
|
const data = yield getCountries();
|
|
1393
|
-
if (active)
|
|
1394
|
-
setCountries(data);
|
|
1395
|
-
}
|
|
1408
|
+
if (active) setCountries(data);
|
|
1396
1409
|
} catch (error) {
|
|
1397
1410
|
console.error("Failed to fetch countries:", error);
|
|
1398
|
-
if (active)
|
|
1399
|
-
setCountries([]);
|
|
1400
|
-
}
|
|
1411
|
+
if (active) setCountries([]);
|
|
1401
1412
|
}
|
|
1402
1413
|
});
|
|
1403
1414
|
if (countries.length === 0) {
|
|
@@ -1407,6 +1418,22 @@ const useAddress = (countryCode, cityCode, districtCode) => {
|
|
|
1407
1418
|
active = false;
|
|
1408
1419
|
};
|
|
1409
1420
|
}, []);
|
|
1421
|
+
React.useEffect(() => {
|
|
1422
|
+
let active = true;
|
|
1423
|
+
const fetchNewCities = () => __async(exports, null, function* () {
|
|
1424
|
+
try {
|
|
1425
|
+
const data = yield getNewCities();
|
|
1426
|
+
if (active) setNewCities(data);
|
|
1427
|
+
} catch (error) {
|
|
1428
|
+
console.error("Failed to fetch new cities:", error);
|
|
1429
|
+
if (active) setNewCities([]);
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
fetchNewCities();
|
|
1433
|
+
return () => {
|
|
1434
|
+
active = false;
|
|
1435
|
+
};
|
|
1436
|
+
}, []);
|
|
1410
1437
|
React.useEffect(() => {
|
|
1411
1438
|
let active = true;
|
|
1412
1439
|
const fetchCities = () => __async(exports, null, function* () {
|
|
@@ -1473,14 +1500,10 @@ const useAddress = (countryCode, cityCode, districtCode) => {
|
|
|
1473
1500
|
}
|
|
1474
1501
|
try {
|
|
1475
1502
|
const data = yield getWards(districtCode);
|
|
1476
|
-
if (active)
|
|
1477
|
-
setWards(data);
|
|
1478
|
-
}
|
|
1503
|
+
if (active) setWards(data);
|
|
1479
1504
|
} catch (error) {
|
|
1480
1505
|
console.error("Failed to fetch wards:", error);
|
|
1481
|
-
if (active)
|
|
1482
|
-
setWards([]);
|
|
1483
|
-
}
|
|
1506
|
+
if (active) setWards([]);
|
|
1484
1507
|
}
|
|
1485
1508
|
});
|
|
1486
1509
|
fetchWards();
|
|
@@ -1488,11 +1511,33 @@ const useAddress = (countryCode, cityCode, districtCode) => {
|
|
|
1488
1511
|
active = false;
|
|
1489
1512
|
};
|
|
1490
1513
|
}, [districtCode, resetWards]);
|
|
1514
|
+
React.useEffect(() => {
|
|
1515
|
+
let active = true;
|
|
1516
|
+
const fetchNewWards = () => __async(exports, null, function* () {
|
|
1517
|
+
if (!cityCode || cityCode.trim() === "") {
|
|
1518
|
+
resetNewWards();
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
try {
|
|
1522
|
+
const data = yield getNewWards(cityCode);
|
|
1523
|
+
if (active) setNewWards(data);
|
|
1524
|
+
} catch (error) {
|
|
1525
|
+
console.error("Failed to fetch new wards:", error);
|
|
1526
|
+
if (active) setNewWards([]);
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1529
|
+
fetchNewWards();
|
|
1530
|
+
return () => {
|
|
1531
|
+
active = false;
|
|
1532
|
+
};
|
|
1533
|
+
}, [cityCode, resetNewWards]);
|
|
1491
1534
|
return {
|
|
1492
1535
|
countries,
|
|
1493
1536
|
cities,
|
|
1494
1537
|
districts,
|
|
1495
|
-
wards
|
|
1538
|
+
wards,
|
|
1539
|
+
newCities,
|
|
1540
|
+
newWards
|
|
1496
1541
|
};
|
|
1497
1542
|
};
|
|
1498
1543
|
const AddressFields$2 = ({
|
|
@@ -1502,7 +1547,7 @@ const AddressFields$2 = ({
|
|
|
1502
1547
|
lang = "vi"
|
|
1503
1548
|
}) => {
|
|
1504
1549
|
const { translate } = useTranslation.useTranslation("form", lang);
|
|
1505
|
-
const { countries,
|
|
1550
|
+
const { countries, newCities, newWards } = useAddress(
|
|
1506
1551
|
formData.country,
|
|
1507
1552
|
formData.city,
|
|
1508
1553
|
formData.district
|
|
@@ -1524,19 +1569,7 @@ const AddressFields$2 = ({
|
|
|
1524
1569
|
label: "city",
|
|
1525
1570
|
name: "city",
|
|
1526
1571
|
value: formData.city,
|
|
1527
|
-
options:
|
|
1528
|
-
var _a;
|
|
1529
|
-
return {
|
|
1530
|
-
value: (_a = item.id) != null ? _a : "",
|
|
1531
|
-
label: item.name
|
|
1532
|
-
};
|
|
1533
|
-
})
|
|
1534
|
-
},
|
|
1535
|
-
{
|
|
1536
|
-
label: "district",
|
|
1537
|
-
name: "district",
|
|
1538
|
-
value: formData.district,
|
|
1539
|
-
options: districts.map((item) => {
|
|
1572
|
+
options: newCities.map((item) => {
|
|
1540
1573
|
var _a;
|
|
1541
1574
|
return {
|
|
1542
1575
|
value: (_a = item.id) != null ? _a : "",
|
|
@@ -1548,7 +1581,7 @@ const AddressFields$2 = ({
|
|
|
1548
1581
|
label: "ward",
|
|
1549
1582
|
name: "ward",
|
|
1550
1583
|
value: formData.ward,
|
|
1551
|
-
options:
|
|
1584
|
+
options: newWards.map((item) => {
|
|
1552
1585
|
var _a;
|
|
1553
1586
|
return {
|
|
1554
1587
|
value: (_a = item.id) != null ? _a : "",
|
|
@@ -1559,7 +1592,7 @@ const AddressFields$2 = ({
|
|
|
1559
1592
|
];
|
|
1560
1593
|
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
|
1561
1594
|
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold font-inter leading-[18px] tracking-normal text-[#2C2C2C]", children: translate("address") }),
|
|
1562
|
-
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "
|
|
1595
|
+
/* @__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: [
|
|
1563
1596
|
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
|
|
1564
1597
|
"select",
|
|
1565
1598
|
{
|
|
@@ -1602,7 +1635,7 @@ const AddressFields$2 = ({
|
|
|
1602
1635
|
value: formData.address,
|
|
1603
1636
|
onChange: (e) => onInputChange("address", e.target.value),
|
|
1604
1637
|
placeholder: translate("street"),
|
|
1605
|
-
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
|
|
1638
|
+
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`
|
|
1606
1639
|
}
|
|
1607
1640
|
),
|
|
1608
1641
|
(errors == null ? void 0 : errors.address) && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("p", { className: "text-red-500 text-xs mt-1", children: errors.address })
|
|
@@ -2472,17 +2505,18 @@ const MerchantRegistrationForm = ({
|
|
|
2472
2505
|
const [showSuccessModal, setShowSuccessModal] = React.useState(false);
|
|
2473
2506
|
const [showErrorModal, setShowErrorModal] = React.useState(false);
|
|
2474
2507
|
const [errorMessage, setErrorMessage] = React.useState("");
|
|
2475
|
-
const {
|
|
2476
|
-
|
|
2477
|
-
|
|
2508
|
+
const { submit: createMerchant2 } = useCreateMerchant();
|
|
2509
|
+
React.useEffect(() => {
|
|
2510
|
+
if (accessToken) {
|
|
2511
|
+
usePortalApiConfig_store.usePortalApiConfig.setState({ accessToken });
|
|
2512
|
+
}
|
|
2513
|
+
}, [accessToken]);
|
|
2478
2514
|
const generateRandomData = () => {
|
|
2479
2515
|
const characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
2480
2516
|
const referralCode = Array.from({ length: 8 }).map(
|
|
2481
2517
|
() => characters.charAt(Math.floor(Math.random() * characters.length))
|
|
2482
2518
|
).join("");
|
|
2483
|
-
return {
|
|
2484
|
-
referralCode: `${referralCode}`
|
|
2485
|
-
};
|
|
2519
|
+
return { referralCode };
|
|
2486
2520
|
};
|
|
2487
2521
|
React.useEffect(() => {
|
|
2488
2522
|
const randomData = generateRandomData();
|
|
@@ -2665,8 +2699,7 @@ const MerchantRegistrationForm = ({
|
|
|
2665
2699
|
}
|
|
2666
2700
|
} catch (err) {
|
|
2667
2701
|
console.error("Submit error details:", { error: err });
|
|
2668
|
-
|
|
2669
|
-
setErrorMessage(displayMessage);
|
|
2702
|
+
setErrorMessage(translate("submit_error"));
|
|
2670
2703
|
setShowErrorModal(true);
|
|
2671
2704
|
onError == null ? void 0 : onError(err);
|
|
2672
2705
|
}
|
|
@@ -2714,7 +2747,7 @@ const MerchantRegistrationForm = ({
|
|
|
2714
2747
|
"userType",
|
|
2715
2748
|
e.target.value
|
|
2716
2749
|
),
|
|
2717
|
-
className: "w-4 h-4 text-blue-600
|
|
2750
|
+
className: "w-4 h-4 text-blue-600"
|
|
2718
2751
|
}
|
|
2719
2752
|
),
|
|
2720
2753
|
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { className: "text-sm text-[#2C2C2C]", children: option.label })
|