@esvndev/es-react-config-setting 1.0.36 → 1.0.38
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 +63 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -3
- 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
|
@@ -11445,6 +11445,54 @@ var Input = /*#__PURE__*/function (_React$Component) {
|
|
|
11445
11445
|
Input.propTypes = propTypes;
|
|
11446
11446
|
var Input$1 = Input;
|
|
11447
11447
|
|
|
11448
|
+
const BASE_URL = process.env.REACT_APP_BASE_URL;
|
|
11449
|
+
//#region using for token
|
|
11450
|
+
const getToken = () => {
|
|
11451
|
+
let accessToken = localStorage.getItem('access_token');
|
|
11452
|
+
if (!accessToken) {
|
|
11453
|
+
const userData = localStorage.getItem('userData');
|
|
11454
|
+
if (userData && userData.length) {
|
|
11455
|
+
accessToken = JSON.parse(userData).id_token;
|
|
11456
|
+
}
|
|
11457
|
+
}
|
|
11458
|
+
return accessToken;
|
|
11459
|
+
};
|
|
11460
|
+
//#endregion
|
|
11461
|
+
const GetSettingGroup = (callback) => {
|
|
11462
|
+
const _url = `${BASE_URL}/api/config/get-setting-group`;
|
|
11463
|
+
const options = {
|
|
11464
|
+
method: 'GET',
|
|
11465
|
+
headers: {
|
|
11466
|
+
'Content-Type': 'application/json',
|
|
11467
|
+
Authorization: `Bearer ${getToken()}`,
|
|
11468
|
+
},
|
|
11469
|
+
};
|
|
11470
|
+
fetch(_url, options)
|
|
11471
|
+
.then(response => {
|
|
11472
|
+
if (!response.ok) {
|
|
11473
|
+
console.log(`HTTP error! Status: ${response.status}`);
|
|
11474
|
+
return null;
|
|
11475
|
+
}
|
|
11476
|
+
return response.text(); // hoặc .json() nếu muốn object
|
|
11477
|
+
})
|
|
11478
|
+
.then(text => {
|
|
11479
|
+
if (text) {
|
|
11480
|
+
try {
|
|
11481
|
+
JSON.parse(text); // Kiểm tra nếu là JSON hợp lệ
|
|
11482
|
+
console.log('Response JSON string:', text);
|
|
11483
|
+
}
|
|
11484
|
+
catch (err) {
|
|
11485
|
+
console.log('Invalid JSON:', err);
|
|
11486
|
+
}
|
|
11487
|
+
}
|
|
11488
|
+
callback({ state: true, data: text });
|
|
11489
|
+
})
|
|
11490
|
+
.catch(error => {
|
|
11491
|
+
console.log('Fetch error:', error);
|
|
11492
|
+
callback({ state: true, data: error });
|
|
11493
|
+
});
|
|
11494
|
+
};
|
|
11495
|
+
|
|
11448
11496
|
const SettingApp = (props) => {
|
|
11449
11497
|
const { isOpen, eventChange, eventClose } = { ...props };
|
|
11450
11498
|
useForm({
|
|
@@ -11582,6 +11630,12 @@ const SettingApp = (props) => {
|
|
|
11582
11630
|
name: t('Tiện ích'),
|
|
11583
11631
|
icon: "BookOpen"
|
|
11584
11632
|
}]);
|
|
11633
|
+
//Load data of group config and setting by group
|
|
11634
|
+
React.useEffect(() => {
|
|
11635
|
+
GetSettingGroup((data) => {
|
|
11636
|
+
console.log('rs', data);
|
|
11637
|
+
});
|
|
11638
|
+
}, []);
|
|
11585
11639
|
//Sự kiện chọn nhóm cài đặt
|
|
11586
11640
|
const switchSettingTab = (data) => {
|
|
11587
11641
|
const updated = dataSettingGroup.map((item) => ({
|
|
@@ -11595,6 +11649,7 @@ const SettingApp = (props) => {
|
|
|
11595
11649
|
const _renderInput = (root, data) => {
|
|
11596
11650
|
console.log((new Date()).getTime(), 111);
|
|
11597
11651
|
switch (data.type) {
|
|
11652
|
+
case "switch":
|
|
11598
11653
|
case "checkbox":
|
|
11599
11654
|
return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "checkbox", className: "" }) }, data.id));
|
|
11600
11655
|
case "radio":
|
|
@@ -11603,14 +11658,19 @@ const SettingApp = (props) => {
|
|
|
11603
11658
|
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));
|
|
11604
11659
|
case "text":
|
|
11605
11660
|
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));
|
|
11661
|
+
case "password":
|
|
11662
|
+
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));
|
|
11606
11663
|
case "number":
|
|
11607
11664
|
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));
|
|
11608
11665
|
case "date":
|
|
11609
|
-
return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "date", className: "input-custom" }) }, data.id));
|
|
11610
|
-
case "
|
|
11611
|
-
return (jsxRuntime.jsx("div", { className: "
|
|
11666
|
+
return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "date", className: "t-right input-custom" }) }, data.id));
|
|
11667
|
+
case "time":
|
|
11668
|
+
return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "time", className: "t-right input-custom" }) }, data.id));
|
|
11669
|
+
case "datetime":
|
|
11670
|
+
return (jsxRuntime.jsx("div", { className: "date-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "datetime", className: "t-right input-custom" }) }, data.id));
|
|
11612
11671
|
case "slider":
|
|
11613
11672
|
return (jsxRuntime.jsx("div", { className: "slider", title: data.description }, data.id));
|
|
11673
|
+
case "image":
|
|
11614
11674
|
case "file":
|
|
11615
11675
|
return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom" }) }, data.id));
|
|
11616
11676
|
case "color":
|