@esvndev/es-react-config-setting 1.0.41 → 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 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
+ switchSettingTab(data.data[0]);
11575
+ }, 500);
11535
11576
  }
11536
11577
  else {
11537
11578
  setDataSettingGroup([]);
@@ -11545,7 +11586,14 @@ const SettingApp = (props) => {
11545
11586
  ...item,
11546
11587
  active: item.id === data.id
11547
11588
  }));
11548
- setSettingData(data);
11589
+ GetSettingConfigByGroup({ GroupId: data.id }, (rs) => {
11590
+ if (rs.status) {
11591
+ setSettingData(rs.data);
11592
+ }
11593
+ else {
11594
+ setSettingData([]);
11595
+ }
11596
+ });
11549
11597
  setDataSettingGroup(updated);
11550
11598
  };
11551
11599
  //Hàm sử dụng tạo theo loại giá trị
@@ -11559,6 +11607,7 @@ const SettingApp = (props) => {
11559
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));
11560
11608
  case "combobox":
11561
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":
11562
11611
  case "text":
11563
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));
11564
11613
  case "password":