@esvndev/es-react-config-setting 1.0.44 → 1.0.46

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,43 @@ const GetSettingGroup = (callback) => {
11495
11495
  callback({ status: false, data: error });
11496
11496
  });
11497
11497
  };
11498
+ const GetSettingConfig = (callback) => {
11499
+ const _url = `${BASE_URL}/api/config/get-setting-config`;
11500
+ const options = {
11501
+ method: 'GET',
11502
+ headers: {
11503
+ 'Content-Type': 'application/json',
11504
+ Authorization: `Bearer ${getToken()}`,
11505
+ },
11506
+ };
11507
+ fetch(_url, options)
11508
+ .then(response => {
11509
+ if (!response.ok) {
11510
+ console.log(`HTTP error! Status: ${response.status}`);
11511
+ return null;
11512
+ }
11513
+ return response.text(); // hoặc .json() nếu muốn object
11514
+ })
11515
+ .then(text => {
11516
+ if (text) {
11517
+ try {
11518
+ JSON.parse(text); // Kiểm tra nếu là JSON hợp lệ
11519
+ console.log('Response JSON string:', text);
11520
+ }
11521
+ catch (err) {
11522
+ console.log('Invalid JSON:', err);
11523
+ }
11524
+ callback({ status: true, data: JSON.parse(text) });
11525
+ }
11526
+ else {
11527
+ callback({ status: false, data: text });
11528
+ }
11529
+ })
11530
+ .catch(error => {
11531
+ console.log('Fetch error:', error);
11532
+ callback({ status: false, data: error });
11533
+ });
11534
+ };
11498
11535
  const GetSettingConfigByGroup = (obj, callback) => {
11499
11536
  const _url = `${BASE_URL}/api/config/get-setting-config-by-group`;
11500
11537
  const options = {
@@ -11557,6 +11594,11 @@ const SettingApp = (props) => {
11557
11594
  //Sự kiện sau khi đã đóng cài đặt
11558
11595
  const handleFormClosed = () => {
11559
11596
  };
11597
+ //Sự kiện giá trị thay đổi
11598
+ const _eventChange = () => {
11599
+ if (eventChange)
11600
+ eventChange([{ key: "x", value: "x", state: "update" }]);
11601
+ };
11560
11602
  const DynamicIcon = ({ name, className }) => {
11561
11603
  const LucideIcon = Icon[name];
11562
11604
  return LucideIcon ? jsxRuntime.jsx(LucideIcon, { className: className }) : null;
@@ -11606,36 +11648,36 @@ const SettingApp = (props) => {
11606
11648
  switch (data.type) {
11607
11649
  case "switch":
11608
11650
  case "checkbox":
11609
- return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "checkbox", className: "" }) }, data.id));
11651
+ return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "checkbox", className: "", onChange: _eventChange }) }, data.id));
11610
11652
  case "radio":
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));
11653
+ 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, onChange: _eventChange }), opt.name] }, index))) }, data.id));
11612
11654
  case "combobox":
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));
11655
+ 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, onChange: _eventChange, 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
11656
  case "slider":
11615
11657
  case "text":
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));
11658
+ return (jsxRuntime.jsx("div", { className: "text-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "text", className: "input-custom", placeholder: data.name, onChange: _eventChange }) }, data.id));
11617
11659
  case "password":
11618
- return (jsxRuntime.jsx("div", { className: "text-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "password", className: "input-custom", placeholder: data.name }) }, data.id));
11660
+ return (jsxRuntime.jsx("div", { className: "text-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "password", className: "input-custom", placeholder: data.name, onChange: _eventChange }) }, data.id));
11619
11661
  case "number":
11620
- return (jsxRuntime.jsx("div", { className: "number-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "number", className: "t-right input-custom", placeholder: data.name }) }, data.id));
11662
+ return (jsxRuntime.jsx("div", { className: "number-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "number", className: "t-right input-custom", placeholder: data.name, onChange: _eventChange }) }, data.id));
11621
11663
  case "date":
11622
- return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "date", className: "t-right input-custom" }) }, data.id));
11664
+ return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "date", className: "t-right input-custom", onChange: _eventChange }) }, data.id));
11623
11665
  case "time":
11624
- return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "time", className: "t-right input-custom" }) }, data.id));
11666
+ return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "time", className: "t-right input-custom", onChange: _eventChange }) }, data.id));
11625
11667
  case "datetime":
11626
- return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "datetime", className: "t-right input-custom" }) }, data.id));
11668
+ return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "datetime", className: "t-right input-custom", onChange: _eventChange }) }, data.id));
11627
11669
  case "image":
11628
11670
  case "file":
11629
- return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom" }) }, data.id));
11671
+ return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: _eventChange }) }, data.id));
11630
11672
  case "color":
11631
- return (jsxRuntime.jsx("div", { className: "color-picker t-right", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "color", className: "form-color input-custom" }) }, data.id));
11673
+ return (jsxRuntime.jsx("div", { className: "color-picker t-right", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "color", className: "form-color input-custom", onChange: _eventChange }) }, data.id));
11632
11674
  default:
11633
- return (jsxRuntime.jsx("div", { className: (data.type ?? 'normal') + '-input', title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? '' }) }, data.id));
11675
+ return (jsxRuntime.jsx("div", { className: (data.type ?? 'normal') + '-input', title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? '', onChange: _eventChange }) }, data.id));
11634
11676
  }
11635
11677
  };
11636
11678
  //hàm tạo các thông số cấu hình và cài đặt
11637
11679
  const _renderView = () => {
11638
- return (settingData && settingData.data && settingData.data.length > 0 ? settingData.data.map((item, index) => {
11680
+ return (settingData && settingData.length > 0 ? settingData.map((item, index) => {
11639
11681
  return (jsxRuntime.jsxs("div", { className: "setting-section", children: [jsxRuntime.jsx("div", { className: "setting-section-label", children: jsxRuntime.jsx("div", { className: "", children: jsxRuntime.jsx("span", { children: item.name }) }) }), item.description ?
11640
11682
  jsxRuntime.jsx("div", { className: "setting-section-desc", children: jsxRuntime.jsx("div", { className: "", children: jsxRuntime.jsx("span", { children: item.description }) }) })
11641
11683
  : null, item.data ?
@@ -11654,6 +11696,17 @@ const SettingApp = (props) => {
11654
11696
  };
11655
11697
 
11656
11698
  const INIT_CONFIG_SETTING = () => {
11699
+ _LOAD_();
11700
+ GetSettingConfig((data) => {
11701
+ if (data.status) {
11702
+ localStorage.setItem("INIT_CONFIG_SETTING", JSON.parse(data.data));
11703
+ }
11704
+ _LOAD_();
11705
+ });
11706
+ };
11707
+ //Nạp dữ liệu biến vào
11708
+ const _LOAD_ = () => {
11709
+ localStorage.getItem("INIT_CONFIG_SETTING");
11657
11710
  };
11658
11711
 
11659
11712
  exports.INIT_CONFIG_SETTING = INIT_CONFIG_SETTING;