@esvndev/es-react-config-setting 1.0.55 → 1.0.57

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
@@ -18687,7 +18687,7 @@ const getToken = () => {
18687
18687
  };
18688
18688
  //#endregion
18689
18689
  const GetSettingGroup = (callback) => {
18690
- const _url = `${BASE_URL}/api/config/get-setting-group`;
18690
+ const _url = `${BASE_URL}/api/config/get-setting-config-group`;
18691
18691
  const options = {
18692
18692
  method: 'GET',
18693
18693
  headers: {
@@ -18848,31 +18848,17 @@ const SettingApp = (props) => {
18848
18848
  const handleFormClosed = () => {
18849
18849
  };
18850
18850
  //Sự kiện giá trị thay đổi
18851
- const _eventChange = (obj, e) => {
18852
- const value = e.target.type === "checkbox" ? e.target.checked : e.target.value;
18853
- setFormState(prev => ({
18854
- ...prev,
18855
- [obj.id]: value
18856
- }));
18857
- if (e.target) {
18858
- var _value = "";
18859
- if (obj.type === 'checkbox') {
18860
- _value = e.target.checked ? 'true' : 'false';
18861
- }
18862
- else {
18863
- _value = e.target.value;
18864
- }
18865
- UpdateSettingConfig({
18866
- Items: [{
18867
- Key: obj.key,
18868
- Value: _value
18869
- }]
18870
- }, null, (rs) => {
18871
- console.log(rs);
18872
- });
18873
- if (eventChange)
18874
- eventChange([{ key: obj.key, value: _value, state: "update" }]);
18875
- }
18851
+ const _eventChange = (obj) => {
18852
+ UpdateSettingConfig({
18853
+ Items: [{
18854
+ Key: obj.key,
18855
+ Value: obj.value
18856
+ }]
18857
+ }, null, (rs) => {
18858
+ console.log(rs);
18859
+ });
18860
+ if (eventChange)
18861
+ eventChange([{ key: obj.key, value: obj.value, state: "update" }]);
18876
18862
  };
18877
18863
  const DynamicIcon = ({ name, className }) => {
18878
18864
  const LucideIcon = Icon[name];
@@ -18928,6 +18914,36 @@ const SettingApp = (props) => {
18928
18914
  loadSettingConfigByGroup(data);
18929
18915
  setDataSettingGroup(updated);
18930
18916
  };
18917
+ //Khai báo sản biến cập nhật timer
18918
+ const saveSettings = React.useRef({
18919
+ hide_warning: null,
18920
+ hide_navbar: null,
18921
+ target_output_per_hour: null,
18922
+ working_hours_per_day: null,
18923
+ monthly_target_defects: null,
18924
+ allowed_defects_per_model_day: null
18925
+ }).current;
18926
+ //Cấu hình thông số delay tránh gửi liên tục
18927
+ const change_save = (obj, e) => {
18928
+ const _m = saveSettings;
18929
+ if (saveSettings && _m[obj.id] !== null) {
18930
+ clearTimeout(_m[obj.id]);
18931
+ }
18932
+ const value = e.target.type === "checkbox" ? e.target.checked : e.target.value;
18933
+ setFormState(prev => ({
18934
+ ...prev,
18935
+ [obj.id]: value
18936
+ }));
18937
+ const _data = {
18938
+ id: crypto.randomUUID(),
18939
+ obj: obj,
18940
+ key: obj.id,
18941
+ value: value,
18942
+ };
18943
+ _m[obj.id] = setTimeout(() => {
18944
+ _eventChange(_data);
18945
+ }, 1000);
18946
+ };
18931
18947
  //Hàm sử dụng tạo theo loại giá trị
18932
18948
  const _renderInput = (root, data) => {
18933
18949
  console.log(data);
@@ -18935,11 +18951,11 @@ const SettingApp = (props) => {
18935
18951
  switch (data.type) {
18936
18952
  case "switch":
18937
18953
  case "checkbox":
18938
- return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "checkbox", checked: !!value, onChange: (e) => _eventChange(data, e) }) }, data.id));
18954
+ return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "checkbox", checked: !!value, onChange: (e) => change_save(data, e) }) }, data.id));
18939
18955
  case "radio":
18940
- 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, checked: value === opt.value, onChange: (e) => _eventChange(data, e) }), opt.name] }, index))) }, data.id));
18956
+ 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, checked: value === opt.value, onChange: (e) => change_save(data, e) }), opt.name] }, index))) }, data.id));
18941
18957
  case "combobox":
18942
- return (jsxRuntime.jsx("div", { className: "combobox", title: data.description, children: jsxRuntime.jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, value: value, onChange: (e) => _eventChange(data, e), 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));
18958
+ return (jsxRuntime.jsx("div", { className: "combobox", title: data.description, children: jsxRuntime.jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, value: value, onChange: (e) => change_save(data, e), 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));
18943
18959
  case "slider":
18944
18960
  case "text":
18945
18961
  case "password":
@@ -18948,12 +18964,12 @@ const SettingApp = (props) => {
18948
18964
  case "time":
18949
18965
  case "datetime":
18950
18966
  case "color":
18951
- return (jsxRuntime.jsx("div", { className: `${data.type}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type, className: "input-custom", value: value, placeholder: data.name, onChange: (e) => _eventChange(data, e) }) }, data.id));
18967
+ return (jsxRuntime.jsx("div", { className: `${data.type}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type, className: "input-custom", value: value, placeholder: data.name, onChange: (e) => change_save(data, e) }) }, data.id));
18952
18968
  case "image":
18953
18969
  case "file":
18954
- return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => _eventChange(data, e) }) }, data.id));
18970
+ return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => change_save(data, e) }) }, data.id));
18955
18971
  default:
18956
- return (jsxRuntime.jsx("div", { className: `${data.type ?? 'normal'}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? "text", value: value, onChange: (e) => _eventChange(data, e) }) }, data.id));
18972
+ return (jsxRuntime.jsx("div", { className: `${data.type ?? 'normal'}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? "text", value: value, onChange: (e) => change_save(data, e) }) }, data.id));
18957
18973
  }
18958
18974
  };
18959
18975
  //hàm tạo các thông số cấu hình và cài đặt