@esvndev/es-react-config-setting 1.0.49 → 1.0.51
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 +54 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -14
- package/dist/index.mjs.map +1 -1
- package/dist/request/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -18771,6 +18771,31 @@ const GetSettingConfigByGroup = (obj, callback) => {
|
|
|
18771
18771
|
callback({ status: false, data: error });
|
|
18772
18772
|
});
|
|
18773
18773
|
};
|
|
18774
|
+
//Update setting data
|
|
18775
|
+
const UpdateSettingConfig = (obj, file, callback) => {
|
|
18776
|
+
const _url = `${BASE_URL}/api/config/update-setting-config`;
|
|
18777
|
+
const formData = new FormData();
|
|
18778
|
+
// Gửi từng item theo dạng Items[0].Key, Items[0].Value...
|
|
18779
|
+
obj.Items.forEach((item, index) => {
|
|
18780
|
+
formData.append(`Items[${index}].Key`, item.Key);
|
|
18781
|
+
formData.append(`Items[${index}].Value`, item.Value);
|
|
18782
|
+
formData.append(`Items[${index}].SortOrder`, item.SortOrder ?? 1);
|
|
18783
|
+
});
|
|
18784
|
+
if (file) {
|
|
18785
|
+
formData.append("file", file);
|
|
18786
|
+
}
|
|
18787
|
+
const options = {
|
|
18788
|
+
method: 'POST',
|
|
18789
|
+
headers: {
|
|
18790
|
+
Authorization: `Bearer ${getToken()}`
|
|
18791
|
+
},
|
|
18792
|
+
body: formData
|
|
18793
|
+
};
|
|
18794
|
+
fetch(_url, options)
|
|
18795
|
+
.then(res => res.json())
|
|
18796
|
+
.then(data => callback({ status: true, data }))
|
|
18797
|
+
.catch(error => callback({ status: false, data: error }));
|
|
18798
|
+
};
|
|
18774
18799
|
|
|
18775
18800
|
const SettingApp = (props) => {
|
|
18776
18801
|
const { isOpen, eventChange, eventClose } = { ...props };
|
|
@@ -18796,9 +18821,23 @@ const SettingApp = (props) => {
|
|
|
18796
18821
|
const handleFormClosed = () => {
|
|
18797
18822
|
};
|
|
18798
18823
|
//Sự kiện giá trị thay đổi
|
|
18799
|
-
const _eventChange = (data) => {
|
|
18824
|
+
const _eventChange = (key, data) => {
|
|
18800
18825
|
if (data.target) {
|
|
18801
|
-
|
|
18826
|
+
var _value = "";
|
|
18827
|
+
if (data.target.type === 'checkbox') {
|
|
18828
|
+
_value = data.target.checked ? 'true' : 'false';
|
|
18829
|
+
}
|
|
18830
|
+
else {
|
|
18831
|
+
_value = data.target.value;
|
|
18832
|
+
}
|
|
18833
|
+
UpdateSettingConfig({
|
|
18834
|
+
Items: [{
|
|
18835
|
+
Key: key,
|
|
18836
|
+
Value: _value
|
|
18837
|
+
}]
|
|
18838
|
+
}, null, (rs) => {
|
|
18839
|
+
console.log(rs);
|
|
18840
|
+
});
|
|
18802
18841
|
if (eventChange)
|
|
18803
18842
|
eventChange([{ key: "x", value: "x", state: "update" }]);
|
|
18804
18843
|
}
|
|
@@ -18848,34 +18887,35 @@ const SettingApp = (props) => {
|
|
|
18848
18887
|
};
|
|
18849
18888
|
//Hàm sử dụng tạo theo loại giá trị
|
|
18850
18889
|
const _renderInput = (root, data) => {
|
|
18890
|
+
console.log(data);
|
|
18851
18891
|
switch (data.type) {
|
|
18852
18892
|
case "switch":
|
|
18853
18893
|
case "checkbox":
|
|
18854
|
-
return (jsx("div", { className: "checkbox", title: data.description, children: jsx(Input$1, { type: "checkbox", className: "", onChange: _eventChange }) }, data.id));
|
|
18894
|
+
return (jsx("div", { className: "checkbox", title: data.description, children: jsx(Input$1, { type: "checkbox", className: "", onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18855
18895
|
case "radio":
|
|
18856
|
-
return (jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxs("label", { children: [jsx(Input$1, { type: "radio", name: data.name, value: opt.value, onChange: _eventChange }), opt.name] }, index))) }, data.id));
|
|
18896
|
+
return (jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxs("label", { children: [jsx(Input$1, { type: "radio", name: data.name, value: opt.value, onChange: (e) => _eventChange(data, e) }), opt.name] }, index))) }, data.id));
|
|
18857
18897
|
case "combobox":
|
|
18858
|
-
return (jsx("div", { className: "combobox", title: data.description, children: jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, id: data.name, onChange: _eventChange, children: [jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
|
|
18898
|
+
return (jsx("div", { className: "combobox", title: data.description, children: jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, id: data.name, onChange: (e) => _eventChange(data, e), children: [jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
|
|
18859
18899
|
case "slider":
|
|
18860
18900
|
case "text":
|
|
18861
|
-
return (jsx("div", { className: "text-input", title: data.description, children: jsx(Input$1, { type: "text", className: "input-custom", placeholder: data.name, onChange: _eventChange }) }, data.id));
|
|
18901
|
+
return (jsx("div", { className: "text-input", title: data.description, children: jsx(Input$1, { type: "text", className: "input-custom", placeholder: data.name, onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18862
18902
|
case "password":
|
|
18863
|
-
return (jsx("div", { className: "text-input", title: data.description, children: jsx(Input$1, { type: "password", className: "input-custom", placeholder: data.name, onChange: _eventChange }) }, data.id));
|
|
18903
|
+
return (jsx("div", { className: "text-input", title: data.description, children: jsx(Input$1, { type: "password", className: "input-custom", placeholder: data.name, onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18864
18904
|
case "number":
|
|
18865
|
-
return (jsx("div", { className: "number-input", title: data.description, children: jsx(Input$1, { type: "number", className: "t-right input-custom", placeholder: data.name, onChange: _eventChange }) }, data.id));
|
|
18905
|
+
return (jsx("div", { className: "number-input", title: data.description, children: jsx(Input$1, { type: "number", className: "t-right input-custom", placeholder: data.name, onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18866
18906
|
case "date":
|
|
18867
|
-
return (jsx("div", { className: "date-input", title: data.description, children: jsx(Input$1, { type: "date", className: "t-right input-custom", onChange: _eventChange }) }, data.id));
|
|
18907
|
+
return (jsx("div", { className: "date-input", title: data.description, children: jsx(Input$1, { type: "date", className: "t-right input-custom", onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18868
18908
|
case "time":
|
|
18869
|
-
return (jsx("div", { className: "date-input", title: data.description, children: jsx(Input$1, { type: "time", className: "t-right input-custom", onChange: _eventChange }) }, data.id));
|
|
18909
|
+
return (jsx("div", { className: "date-input", title: data.description, children: jsx(Input$1, { type: "time", className: "t-right input-custom", onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18870
18910
|
case "datetime":
|
|
18871
|
-
return (jsx("div", { className: "date-input", title: data.description, children: jsx(Input$1, { type: "datetime", className: "t-right input-custom", onChange: _eventChange }) }, data.id));
|
|
18911
|
+
return (jsx("div", { className: "date-input", title: data.description, children: jsx(Input$1, { type: "datetime", className: "t-right input-custom", onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18872
18912
|
case "image":
|
|
18873
18913
|
case "file":
|
|
18874
|
-
return (jsx("div", { className: "file-input", title: data.description, children: jsx(Input$1, { type: "file", className: "input-custom", onChange: _eventChange }) }, data.id));
|
|
18914
|
+
return (jsx("div", { className: "file-input", title: data.description, children: jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18875
18915
|
case "color":
|
|
18876
|
-
return (jsx("div", { className: "color-picker t-right", title: data.description, children: jsx(Input$1, { type: "color", className: "form-color input-custom", onChange: _eventChange }) }, data.id));
|
|
18916
|
+
return (jsx("div", { className: "color-picker t-right", title: data.description, children: jsx(Input$1, { type: "color", className: "form-color input-custom", onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18877
18917
|
default:
|
|
18878
|
-
return (jsx("div", { className: (data.type ?? 'normal') + '-input', title: data.description, children: jsx(Input$1, { type: data.type ?? '', onChange: _eventChange }) }, data.id));
|
|
18918
|
+
return (jsx("div", { className: (data.type ?? 'normal') + '-input', title: data.description, children: jsx(Input$1, { type: data.type ?? '', onChange: (e) => _eventChange(data, e) }) }, data.id));
|
|
18879
18919
|
}
|
|
18880
18920
|
};
|
|
18881
18921
|
//hàm tạo các thông số cấu hình và cài đặt
|