@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.js
CHANGED
|
@@ -11484,15 +11484,53 @@ const GetSettingGroup = (callback) => {
|
|
|
11484
11484
|
catch (err) {
|
|
11485
11485
|
console.log('Invalid JSON:', err);
|
|
11486
11486
|
}
|
|
11487
|
-
callback({
|
|
11487
|
+
callback({ status: true, data: JSON.parse(text) });
|
|
11488
11488
|
}
|
|
11489
11489
|
else {
|
|
11490
|
-
callback({
|
|
11490
|
+
callback({ status: false, data: text });
|
|
11491
11491
|
}
|
|
11492
11492
|
})
|
|
11493
11493
|
.catch(error => {
|
|
11494
11494
|
console.log('Fetch error:', error);
|
|
11495
|
-
callback({
|
|
11495
|
+
callback({ status: false, data: error });
|
|
11496
|
+
});
|
|
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 });
|
|
11496
11534
|
});
|
|
11497
11535
|
};
|
|
11498
11536
|
|
|
@@ -11524,13 +11562,23 @@ 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(() => {
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11569
|
+
if (isOpen) {
|
|
11570
|
+
GetSettingGroup((data) => {
|
|
11571
|
+
if (data.status) {
|
|
11572
|
+
setDataSettingGroup(data.data);
|
|
11573
|
+
setTimeout(() => {
|
|
11574
|
+
switchSettingTab(data.data[0]);
|
|
11575
|
+
}, 500);
|
|
11576
|
+
}
|
|
11577
|
+
else {
|
|
11578
|
+
setDataSettingGroup([]);
|
|
11579
|
+
}
|
|
11580
|
+
});
|
|
11581
|
+
}
|
|
11534
11582
|
}, [isOpen]);
|
|
11535
11583
|
//Sự kiện chọn nhóm cài đặt
|
|
11536
11584
|
const switchSettingTab = (data) => {
|
|
@@ -11538,7 +11586,14 @@ const SettingApp = (props) => {
|
|
|
11538
11586
|
...item,
|
|
11539
11587
|
active: item.id === data.id
|
|
11540
11588
|
}));
|
|
11541
|
-
|
|
11589
|
+
GetSettingConfigByGroup({ GroupId: data.id }, (rs) => {
|
|
11590
|
+
if (rs.status) {
|
|
11591
|
+
setSettingData(rs.data);
|
|
11592
|
+
}
|
|
11593
|
+
else {
|
|
11594
|
+
setSettingData([]);
|
|
11595
|
+
}
|
|
11596
|
+
});
|
|
11542
11597
|
setDataSettingGroup(updated);
|
|
11543
11598
|
};
|
|
11544
11599
|
//Hàm sử dụng tạo theo loại giá trị
|
|
@@ -11552,6 +11607,7 @@ const SettingApp = (props) => {
|
|
|
11552
11607
|
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));
|
|
11553
11608
|
case "combobox":
|
|
11554
11609
|
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));
|
|
11610
|
+
case "slider":
|
|
11555
11611
|
case "text":
|
|
11556
11612
|
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));
|
|
11557
11613
|
case "password":
|