@esvndev/es-react-config-setting 1.0.40 → 1.0.42
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/index.js +64 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -8
- package/dist/index.mjs.map +1 -1
- package/dist/request/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11457,15 +11457,53 @@ const GetSettingGroup = (callback) => {
|
|
|
11457
11457
|
catch (err) {
|
|
11458
11458
|
console.log('Invalid JSON:', err);
|
|
11459
11459
|
}
|
|
11460
|
-
callback({
|
|
11460
|
+
callback({ status: true, data: JSON.parse(text) });
|
|
11461
11461
|
}
|
|
11462
11462
|
else {
|
|
11463
|
-
callback({
|
|
11463
|
+
callback({ status: false, data: text });
|
|
11464
11464
|
}
|
|
11465
11465
|
})
|
|
11466
11466
|
.catch(error => {
|
|
11467
11467
|
console.log('Fetch error:', error);
|
|
11468
|
-
callback({
|
|
11468
|
+
callback({ status: false, data: error });
|
|
11469
|
+
});
|
|
11470
|
+
};
|
|
11471
|
+
const GetSettingConfigByGroup = (obj, callback) => {
|
|
11472
|
+
const _url = `${BASE_URL}/api/config/get-setting-config-by-group`;
|
|
11473
|
+
const options = {
|
|
11474
|
+
method: 'POST',
|
|
11475
|
+
headers: {
|
|
11476
|
+
'Content-Type': 'application/json',
|
|
11477
|
+
Authorization: `Bearer ${getToken()}`,
|
|
11478
|
+
},
|
|
11479
|
+
body: JSON.stringify(obj)
|
|
11480
|
+
};
|
|
11481
|
+
fetch(_url, options)
|
|
11482
|
+
.then(response => {
|
|
11483
|
+
if (!response.ok) {
|
|
11484
|
+
console.log(`HTTP error! Status: ${response.status}`);
|
|
11485
|
+
return null;
|
|
11486
|
+
}
|
|
11487
|
+
return response.text(); // hoặc .json() nếu muốn object
|
|
11488
|
+
})
|
|
11489
|
+
.then(text => {
|
|
11490
|
+
if (text) {
|
|
11491
|
+
try {
|
|
11492
|
+
JSON.parse(text); // Kiểm tra nếu là JSON hợp lệ
|
|
11493
|
+
console.log('Response JSON string:', text);
|
|
11494
|
+
}
|
|
11495
|
+
catch (err) {
|
|
11496
|
+
console.log('Invalid JSON:', err);
|
|
11497
|
+
}
|
|
11498
|
+
callback({ status: true, data: JSON.parse(text) });
|
|
11499
|
+
}
|
|
11500
|
+
else {
|
|
11501
|
+
callback({ status: false, data: text });
|
|
11502
|
+
}
|
|
11503
|
+
})
|
|
11504
|
+
.catch(error => {
|
|
11505
|
+
console.log('Fetch error:', error);
|
|
11506
|
+
callback({ status: false, data: error });
|
|
11469
11507
|
});
|
|
11470
11508
|
};
|
|
11471
11509
|
|
|
@@ -11497,13 +11535,23 @@ const SettingApp = (props) => {
|
|
|
11497
11535
|
return LucideIcon ? jsx(LucideIcon, { className: className }) : null;
|
|
11498
11536
|
};
|
|
11499
11537
|
//#endregion
|
|
11500
|
-
const [settingData, setSettingData] = useState(
|
|
11538
|
+
const [settingData, setSettingData] = useState({});
|
|
11501
11539
|
const [dataSettingGroup, setDataSettingGroup] = useState([]);
|
|
11502
11540
|
//Load data of group config and setting by group
|
|
11503
11541
|
useEffect(() => {
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11542
|
+
if (isOpen) {
|
|
11543
|
+
GetSettingGroup((data) => {
|
|
11544
|
+
if (data.status) {
|
|
11545
|
+
setDataSettingGroup(data.data);
|
|
11546
|
+
setTimeout(() => {
|
|
11547
|
+
switchSettingTab(data.data[0]);
|
|
11548
|
+
}, 500);
|
|
11549
|
+
}
|
|
11550
|
+
else {
|
|
11551
|
+
setDataSettingGroup([]);
|
|
11552
|
+
}
|
|
11553
|
+
});
|
|
11554
|
+
}
|
|
11507
11555
|
}, [isOpen]);
|
|
11508
11556
|
//Sự kiện chọn nhóm cài đặt
|
|
11509
11557
|
const switchSettingTab = (data) => {
|
|
@@ -11511,7 +11559,14 @@ const SettingApp = (props) => {
|
|
|
11511
11559
|
...item,
|
|
11512
11560
|
active: item.id === data.id
|
|
11513
11561
|
}));
|
|
11514
|
-
|
|
11562
|
+
GetSettingConfigByGroup({ GroupId: data.id }, (rs) => {
|
|
11563
|
+
if (rs.status) {
|
|
11564
|
+
setSettingData(rs.data);
|
|
11565
|
+
}
|
|
11566
|
+
else {
|
|
11567
|
+
setSettingData([]);
|
|
11568
|
+
}
|
|
11569
|
+
});
|
|
11515
11570
|
setDataSettingGroup(updated);
|
|
11516
11571
|
};
|
|
11517
11572
|
//Hàm sử dụng tạo theo loại giá trị
|
|
@@ -11525,6 +11580,7 @@ const SettingApp = (props) => {
|
|
|
11525
11580
|
return (jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxs("label", { children: [jsx(Input$1, { type: "radio", name: data.name, value: opt.value }), opt.name] }, index))) }, data.id));
|
|
11526
11581
|
case "combobox":
|
|
11527
11582
|
return (jsx("div", { className: "combobox", title: data.description, children: jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, id: data.name, children: [jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
|
|
11583
|
+
case "slider":
|
|
11528
11584
|
case "text":
|
|
11529
11585
|
return (jsx("div", { className: "text-input", title: data.description, children: jsx(Input$1, { type: "text", className: "input-custom", placeholder: data.name }) }, data.id));
|
|
11530
11586
|
case "password":
|