@admin-layout/client 10.0.2-alpha.24 → 10.0.2-alpha.25

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useSettings.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,WAAW;;0BAuCD,GAAG;CA2CzB,CAAC"}
1
+ {"version":3,"file":"useSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useSettings.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,WAAW;;0BAqCD,GAAG;CAuCzB,CAAC"}
@@ -1,4 +1,4 @@
1
- import {useEffect,useCallback}from'react';import {useDispatch,useSelector}from'react-redux';import {CHANGE_SETTINGS_ACTION}from'../constants/constants.js';const updateColorWeak = (colorWeak) => {
1
+ import {useState,useEffect,useCallback}from'react';import'../config/env-config.js';import {defaultSettings}from'../config/defaultSettings.js';const updateColorWeak = (colorWeak) => {
2
2
  // @sri to avoid breaking during SSR, split into to checks
3
3
  if (typeof window !== 'undefined') {
4
4
  const root = document.getElementById('root');
@@ -8,20 +8,18 @@ import {useEffect,useCallback}from'react';import {useDispatch,useSelector}from'r
8
8
  }
9
9
  };
10
10
  const useSettings = () => {
11
- const dispatch = useDispatch();
12
- const settings = useSelector((state) => state.settings);
11
+ const [settings, setSettingsState] = useState(defaultSettings);
12
+ const [settingsSynced, setSettingsSynced] = useState(false);
13
13
  useEffect(() => {
14
- if (!settings || Object.keys(settings).length === 0) {
14
+ if (!settingsSynced) {
15
15
  void getSettings().then((settingsData) => {
16
16
  if (settingsData) {
17
- dispatch({
18
- type: CHANGE_SETTINGS_ACTION,
19
- payload: settingsData,
20
- });
17
+ setSettingsState(settingsData);
18
+ setSettingsSynced(true);
21
19
  }
22
20
  });
23
21
  }
24
- }, [dispatch, settings]);
22
+ }, []);
25
23
  const getSettings = useCallback(async () => {
26
24
  try {
27
25
  const response = await fetch('/resources/settings', {
@@ -61,20 +59,16 @@ const useSettings = () => {
61
59
  if (!response.ok) {
62
60
  throw new Error('Failed to update settings');
63
61
  }
64
- const updatedSettings = {
65
- ...settings,
62
+ setSettingsState((prevSettings) => ({
63
+ ...prevSettings,
66
64
  ...config,
67
- };
68
- dispatch({
69
- type: CHANGE_SETTINGS_ACTION,
70
- payload: updatedSettings,
71
- });
65
+ }));
72
66
  return await response.json();
73
67
  }
74
68
  catch (error) {
75
69
  console.error(error);
76
70
  return null;
77
71
  }
78
- }, [dispatch, settings]);
72
+ }, [setSettingsState, settings]);
79
73
  return { settings, setSettings };
80
74
  };export{useSettings};//# sourceMappingURL=useSettings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSettings.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"useSettings.js","sources":["../../src/hooks/useSettings.ts"],"sourcesContent":[null],"names":[],"mappings":"gLAkD0B,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@admin-layout/client",
3
- "version": "10.0.2-alpha.24",
3
+ "version": "10.0.2-alpha.25",
4
4
  "description": "Sample client for higher packages to depend on",
5
5
  "license": "ISC",
6
6
  "author": "CDMBase LLC",
@@ -39,5 +39,5 @@
39
39
  "typescript": {
40
40
  "definition": "lib/index.d.ts"
41
41
  },
42
- "gitHead": "63ef0bf22828aa8189acd9cb0ff87f50a89374d6"
42
+ "gitHead": "f4aca5e50d5b980c61bb42b8f40749c28eb47537"
43
43
  }