@esvndev/es-react-config-setting 1.0.41 → 1.0.43
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 +55 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -2
- package/dist/index.mjs.map +1 -1
- package/dist/request/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11495,6 +11495,44 @@ const GetSettingGroup = (callback) => {
|
|
|
11495
11495
|
callback({ status: false, data: error });
|
|
11496
11496
|
});
|
|
11497
11497
|
};
|
|
11498
|
+
const GetSettingConfigByGroup = (obj, callback) => {
|
|
11499
|
+
const _url = `${BASE_URL}/api/config/get-setting-config-by-group`;
|
|
11500
|
+
const options = {
|
|
11501
|
+
method: 'POST',
|
|
11502
|
+
headers: {
|
|
11503
|
+
'Content-Type': 'application/json',
|
|
11504
|
+
Authorization: `Bearer ${getToken()}`,
|
|
11505
|
+
},
|
|
11506
|
+
body: JSON.stringify(obj)
|
|
11507
|
+
};
|
|
11508
|
+
fetch(_url, options)
|
|
11509
|
+
.then(response => {
|
|
11510
|
+
if (!response.ok) {
|
|
11511
|
+
console.log(`HTTP error! Status: ${response.status}`);
|
|
11512
|
+
return null;
|
|
11513
|
+
}
|
|
11514
|
+
return response.text(); // hoặc .json() nếu muốn object
|
|
11515
|
+
})
|
|
11516
|
+
.then(text => {
|
|
11517
|
+
if (text) {
|
|
11518
|
+
try {
|
|
11519
|
+
JSON.parse(text); // Kiểm tra nếu là JSON hợp lệ
|
|
11520
|
+
console.log('Response JSON string:', text);
|
|
11521
|
+
}
|
|
11522
|
+
catch (err) {
|
|
11523
|
+
console.log('Invalid JSON:', err);
|
|
11524
|
+
}
|
|
11525
|
+
callback({ status: true, data: JSON.parse(text) });
|
|
11526
|
+
}
|
|
11527
|
+
else {
|
|
11528
|
+
callback({ status: false, data: text });
|
|
11529
|
+
}
|
|
11530
|
+
})
|
|
11531
|
+
.catch(error => {
|
|
11532
|
+
console.log('Fetch error:', error);
|
|
11533
|
+
callback({ status: false, data: error });
|
|
11534
|
+
});
|
|
11535
|
+
};
|
|
11498
11536
|
|
|
11499
11537
|
const SettingApp = (props) => {
|
|
11500
11538
|
const { isOpen, eventChange, eventClose } = { ...props };
|
|
@@ -11524,7 +11562,7 @@ const SettingApp = (props) => {
|
|
|
11524
11562
|
return LucideIcon ? jsxRuntime.jsx(LucideIcon, { className: className }) : null;
|
|
11525
11563
|
};
|
|
11526
11564
|
//#endregion
|
|
11527
|
-
const [settingData, setSettingData] = React.useState(
|
|
11565
|
+
const [settingData, setSettingData] = React.useState({});
|
|
11528
11566
|
const [dataSettingGroup, setDataSettingGroup] = React.useState([]);
|
|
11529
11567
|
//Load data of group config and setting by group
|
|
11530
11568
|
React.useEffect(() => {
|
|
@@ -11532,6 +11570,9 @@ const SettingApp = (props) => {
|
|
|
11532
11570
|
GetSettingGroup((data) => {
|
|
11533
11571
|
if (data.status) {
|
|
11534
11572
|
setDataSettingGroup(data.data);
|
|
11573
|
+
setTimeout(() => {
|
|
11574
|
+
loadSettingConfigByGroup(data.data[0]);
|
|
11575
|
+
}, 500);
|
|
11535
11576
|
}
|
|
11536
11577
|
else {
|
|
11537
11578
|
setDataSettingGroup([]);
|
|
@@ -11539,13 +11580,24 @@ const SettingApp = (props) => {
|
|
|
11539
11580
|
});
|
|
11540
11581
|
}
|
|
11541
11582
|
}, [isOpen]);
|
|
11583
|
+
//Lấy danh sách cài đặt theo nhóm đã chọn
|
|
11584
|
+
const loadSettingConfigByGroup = (data) => {
|
|
11585
|
+
GetSettingConfigByGroup({ GroupId: data.id }, (rs) => {
|
|
11586
|
+
if (rs.status) {
|
|
11587
|
+
setSettingData(rs.data);
|
|
11588
|
+
}
|
|
11589
|
+
else {
|
|
11590
|
+
setSettingData([]);
|
|
11591
|
+
}
|
|
11592
|
+
});
|
|
11593
|
+
};
|
|
11542
11594
|
//Sự kiện chọn nhóm cài đặt
|
|
11543
11595
|
const switchSettingTab = (data) => {
|
|
11544
11596
|
const updated = dataSettingGroup.map((item) => ({
|
|
11545
11597
|
...item,
|
|
11546
11598
|
active: item.id === data.id
|
|
11547
11599
|
}));
|
|
11548
|
-
|
|
11600
|
+
loadSettingConfigByGroup(data);
|
|
11549
11601
|
setDataSettingGroup(updated);
|
|
11550
11602
|
};
|
|
11551
11603
|
//Hàm sử dụng tạo theo loại giá trị
|
|
@@ -11559,6 +11611,7 @@ const SettingApp = (props) => {
|
|
|
11559
11611
|
return (jsxRuntime.jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxRuntime.jsxs("label", { children: [jsxRuntime.jsx(Input$1, { type: "radio", name: data.name, value: opt.value }), opt.name] }, index))) }, data.id));
|
|
11560
11612
|
case "combobox":
|
|
11561
11613
|
return (jsxRuntime.jsx("div", { className: "combobox", title: data.description, children: jsxRuntime.jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, id: data.name, children: [jsxRuntime.jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsxRuntime.jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
|
|
11614
|
+
case "slider":
|
|
11562
11615
|
case "text":
|
|
11563
11616
|
return (jsxRuntime.jsx("div", { className: "text-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "text", className: "input-custom", placeholder: data.name }) }, data.id));
|
|
11564
11617
|
case "password":
|