@esvndev/es-react-config-setting 1.0.37 → 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 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) => ({