@dashadmin/dash-admin-state 1.3.25 → 1.3.26

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.
Files changed (70) hide show
  1. package/dist/DefaultThemeSettings.js +34 -1
  2. package/dist/defaults/defaultAuth.js +9 -1
  3. package/dist/defaults/defaultCommon.js +44 -1
  4. package/dist/defaults/defaultFormState.js +5 -1
  5. package/dist/defaults/defaultPage.js +9 -1
  6. package/dist/defaults/defaultSettings.js +51 -1
  7. package/dist/hooks/DashAdminStateSelectors.js +149 -1
  8. package/dist/hooks/useLocalStorage.js +69 -1
  9. package/dist/index.js +41 -691
  10. package/dist/redux/ReduxStoreAccesor.js +19 -1
  11. package/dist/redux/actions/ActionTypes.js +84 -1
  12. package/dist/redux/actions/Auth.js +6 -1
  13. package/dist/redux/actions/Common.js +51 -1
  14. package/dist/redux/actions/ComponentData.js +33 -1
  15. package/dist/redux/actions/Menu.js +5 -1
  16. package/dist/redux/actions/Page.js +7 -1
  17. package/dist/redux/actions/Resources.js +21 -1
  18. package/dist/redux/actions/Setting.js +90 -1
  19. package/dist/redux/actions/index.js +6 -1
  20. package/dist/redux/reducers/Auth.js +55 -1
  21. package/dist/redux/reducers/Common.js +134 -1
  22. package/dist/redux/reducers/ComponentData.js +59 -1
  23. package/dist/redux/reducers/FormData.js +32 -1
  24. package/dist/redux/reducers/Menu.js +22 -1
  25. package/dist/redux/reducers/Page.js +30 -1
  26. package/dist/redux/reducers/Resources.js +19 -1
  27. package/dist/redux/reducers/Settings.js +79 -1
  28. package/dist/redux/reducers/index.js +25 -1
  29. package/dist/redux/sagas/index.js +9 -1
  30. package/dist/redux/store/index.js +35 -1
  31. package/package.json +75 -57
  32. package/src/DefaultThemeSettings.tsx +33 -0
  33. package/src/defaults/defaultAuth.tsx +8 -0
  34. package/src/defaults/defaultCommon.tsx +55 -0
  35. package/src/defaults/defaultFormState.tsx +4 -0
  36. package/src/defaults/defaultPage.tsx +9 -0
  37. package/src/defaults/defaultSettings.tsx +61 -0
  38. package/src/hooks/DashAdminStateSelectors.tsx +142 -0
  39. package/src/hooks/useLocalStorage.tsx +79 -0
  40. package/src/index.tsx +34 -0
  41. package/src/redux/ReduxStoreAccesor.tsx +18 -0
  42. package/src/redux/actions/ActionTypes.tsx +47 -0
  43. package/src/redux/actions/Auth.tsx +5 -0
  44. package/src/redux/actions/Common.tsx +51 -0
  45. package/src/redux/actions/ComponentData.tsx +78 -0
  46. package/src/redux/actions/Menu.tsx +4 -0
  47. package/src/redux/actions/Page.tsx +6 -0
  48. package/src/redux/actions/Resources.tsx +19 -0
  49. package/src/redux/actions/Setting.tsx +91 -0
  50. package/src/redux/actions/index.tsx +7 -0
  51. package/src/redux/interfaces/IAuthState.tsx +7 -0
  52. package/src/redux/interfaces/ICommonState.tsx +25 -0
  53. package/src/redux/interfaces/IComponentData.tsx +32 -0
  54. package/src/redux/interfaces/IDASHAppState.tsx +53 -0
  55. package/src/redux/interfaces/IDashResourceGroupsIcons.tsx +5 -0
  56. package/src/redux/interfaces/IFormDataState.tsx +6 -0
  57. package/src/redux/interfaces/IPage.tsx +27 -0
  58. package/src/redux/interfaces/IResources.tsx +0 -0
  59. package/src/redux/interfaces/ISettings.tsx +27 -0
  60. package/src/redux/reducers/Auth.tsx +38 -0
  61. package/src/redux/reducers/Common.tsx +144 -0
  62. package/src/redux/reducers/ComponentData.tsx +52 -0
  63. package/src/redux/reducers/FormData.tsx +21 -0
  64. package/src/redux/reducers/Menu.tsx +27 -0
  65. package/src/redux/reducers/Page.tsx +17 -0
  66. package/src/redux/reducers/Resources.tsx +19 -0
  67. package/src/redux/reducers/Settings.tsx +78 -0
  68. package/src/redux/reducers/index.tsx +25 -0
  69. package/src/redux/sagas/index.tsx +8 -0
  70. package/src/redux/store/index.tsx +33 -0
@@ -0,0 +1,79 @@
1
+ import { useCallback, useEffect, useState, useMemo } from 'react';
2
+ import { dashStorage } from 'dash-utils';
3
+ const isBrowser = typeof window !== 'undefined';
4
+
5
+ const isLocalstorageAvailable = () => {
6
+ if (!isBrowser) {
7
+ return false;
8
+ }
9
+ const test = `test-${Date.now()}`;
10
+ try {
11
+ dashStorage.setItem(test, test);
12
+ dashStorage.removeItem(test);
13
+ return true;
14
+ } catch (e) {
15
+ return false;
16
+ }
17
+ };
18
+
19
+ // React hook
20
+ const useLocalStorage = (key, initialValue = '') => {
21
+ const available = isLocalstorageAvailable();
22
+ const getValueFromLocalstorage = useCallback(() => {
23
+ try {
24
+ if (!available) {
25
+ return initialValue;
26
+ }
27
+ const item = dashStorage.getItem(key);
28
+ return item ? JSON.parse(item) : initialValue;
29
+ } catch (error) {
30
+ return initialValue;
31
+ }
32
+ }, [available, initialValue, key]);
33
+
34
+ const [storedValue, setStoredValue] = useState(getValueFromLocalstorage());
35
+
36
+ useEffect(() => {
37
+ const value = getValueFromLocalstorage();
38
+ setStoredValue(value);
39
+ }, [available, getValueFromLocalstorage]);
40
+
41
+ // Listen to localstorage change to apply it
42
+ const changeHandler = useCallback(
43
+ (e) => {
44
+ const { key: changeKey, newValue } = e;
45
+ if (key === changeKey) {
46
+ setStoredValue(JSON.parse(newValue));
47
+ }
48
+ },
49
+ [key],
50
+ );
51
+
52
+ // Listen changes
53
+ useEffect(() => {
54
+ if (available) {
55
+ window.addEventListener('storage', changeHandler);
56
+ return () => {
57
+ window.removeEventListener('storage', changeHandler);
58
+ };
59
+ }
60
+ }, [available]); // eslint-disable-line react-hooks/exhaustive-deps
61
+
62
+ // Build the output
63
+ return useMemo(() => {
64
+ const setValue = (value) => {
65
+ if (!available) {
66
+ return false;
67
+ }
68
+ const valueToStore =
69
+ value instanceof Function ? value(storedValue) : value;
70
+ if (valueToStore !== storedValue) {
71
+ setStoredValue(valueToStore);
72
+ window.dashStorage.setItem(key, JSON.stringify(valueToStore));
73
+ }
74
+ };
75
+ return [storedValue, setValue];
76
+ }, [storedValue, available, key]);
77
+ };
78
+
79
+ export default useLocalStorage;
package/src/index.tsx ADDED
@@ -0,0 +1,34 @@
1
+ export { default as DASHStoreConfig } from './redux/store/index';
2
+ export { createRootReducer as DASHCreateRootReducer } from './redux/reducers/index';
3
+
4
+ export { default as DASH_THEME_SETTINGS } from './DefaultThemeSettings';
5
+
6
+ export type { default as IAuthState } from './redux/interfaces/IAuthState';
7
+ export type { default as ICommonState } from './redux/interfaces/ICommonState';
8
+ export type { default as ISettingsState } from './redux/interfaces/ISettings';
9
+ export type { default as IPageState, IBreadcrumbItem } from './redux/interfaces/IPage';
10
+ export type { default as IDASHAppState } from './redux/interfaces/IDASHAppState';
11
+ export type { default as IComponentDataState } from './redux/interfaces/IComponentData'; // Add this line
12
+
13
+ export { default as defaultAuth } from './defaults/defaultAuth';
14
+ export { default as defaultCommon } from './defaults/defaultCommon';
15
+ export { default as defaultFormState } from './defaults/defaultFormState';
16
+ export { default as defaultPageSettings } from './defaults/defaultPage';
17
+ export { default as defaultSettings } from './defaults/defaultSettings';
18
+
19
+ // Export all optimized hooks
20
+ export {
21
+ useLayoutState,
22
+ useAuthState,
23
+ useSettingsState,
24
+ useCommonState,
25
+ usePageState,
26
+ useResourcesState,
27
+ useLogoSettings,
28
+ usePanelSettings,
29
+ useThemeState,
30
+ useNavigationState
31
+ } from './hooks/DashAdminStateSelectors';
32
+
33
+ export * as DASH_REDUX_ACTIONS from './redux/actions';
34
+ export * from './redux/ReduxStoreAccesor';
@@ -0,0 +1,18 @@
1
+ // Create this new file to access the Redux store
2
+ let store: any = null;
3
+
4
+ export const setReduxStore = (reduxStore: any) => {
5
+ store = reduxStore;
6
+ };
7
+
8
+ export const getReduxStore = () => {
9
+ if (!store) {
10
+ throw new Error('Redux store not initialized. Call setReduxStore first.');
11
+ }
12
+ return store;
13
+ };
14
+
15
+ export const dispatchToRedux = (action: any) => {
16
+ const reduxStore = getReduxStore();
17
+ return reduxStore.dispatch(action);
18
+ };
@@ -0,0 +1,47 @@
1
+ export const SET_FORM_DATA = 'SET_FORM_DATA';
2
+ export const CLEAR_FORM_DATA = 'CLEAR_FORM_DATA';
3
+
4
+ export const SET_RESOURCES = 'SET_RESOURCES';
5
+ export const APPEND_RESOURCES = 'APPEND_RESOURCES';
6
+ export const SET_HEADER_COMPONENTS = 'SET_HEADER_COMPONENTS';
7
+ export const SET_PANEL_SETTINGS = 'SET_PANEL_COMPONENTS';
8
+
9
+ export const TOGGLE_COLLAPSED_NAV = 'TOGGLE_COLLAPSE_MENU';
10
+ export const WINDOW_WIDTH = 'WINDOW-WIDTH';
11
+ export const UPDATE_THEME_SETTINGS = 'UPDATE_THEME_SETTINGS';
12
+ export const CONTENT_WIDTH = 'CONTENT-WIDTH';
13
+ export const CONTENT_HEIGHT = 'CONTENT-HEIGHT';
14
+ export const WINDOW_HEIGHT = 'WINDOW-HEIGHT';
15
+ export const SWITCH_LANGUAGE = 'SWITCH-LANGUAGE';
16
+ export const SWITCH_THEME_TYPE = 'SWITCH_THEME_TYPE';
17
+ export const UPDATE_PAGE = 'UPDATE_PAGE';
18
+
19
+ export const FETCH_START = 'fetch_start';
20
+ export const FETCH_SUCCESS = 'fetch_success';
21
+ export const FETCH_ERROR = 'fetch_error';
22
+ export const SHOW_MESSAGE = 'SHOW_MESSAGE';
23
+ export const HIDE_MESSAGE = 'HIDE_MESSAGE';
24
+ export const ON_SHOW_LOADER = 'ON_SHOW_LOADER';
25
+ export const ON_HIDE_LOADER = 'ON_HIDE_LOADER';
26
+
27
+ export const LOADING = 'LOADING';
28
+
29
+ export const SIGNUP_USER = 'SIGNUP_USER';
30
+ export const SIGNUP_USER_SUCCESS = 'SIGNUP_USER_SUCCESS';
31
+ export const SIGNIN_GOOGLE_USER = 'SIGNIN_GOOGLE_USER';
32
+ export const SIGNIN_GOOGLE_USER_SUCCESS = 'SIGNIN_GOOGLE_USER_SUCCESS';
33
+ export const SIGNIN_FACEBOOK_USER = 'SIGNIN_FACEBOOK_USER';
34
+ export const SIGNIN_FACEBOOK_USER_SUCCESS = 'SIGNIN_FACEBOOK_USER_SUCCESS';
35
+ export const SIGNIN_TWITTER_USER = 'SIGNIN_TWITTER_USER';
36
+ export const SIGNIN_TWITTER_USER_SUCCESS = 'SIGNIN_TWITTER_USER_SUCCESS';
37
+ export const SIGNIN_GITHUB_USER = 'SIGNIN_GITHUB_USER';
38
+ export const SIGNIN_GITHUB_USER_SUCCESS = 'signin_github_user_success';
39
+ export const SIGNIN_USER = 'SIGNIN_USER';
40
+ export const SIGNIN_USER_SUCCESS = 'SIGNIN_USER_SUCCESS';
41
+ export const SIGNOUT_USER = 'SIGNOUT_USER';
42
+ export const SIGNOUT_USER_SUCCESS = 'SIGNOUT_USER_SUCCESS';
43
+ export const INIT_URL = 'INIT_URL';
44
+
45
+ export const TOGGLE_NAV_EXPANDED = 'TOGGLE_NAV_EXPANDED';
46
+ export const SET_NAV_EXPANDED = 'SET_NAV_EXPANDED';
47
+ export const SET_NAV_SIZE = 'SET_NAV_SIZE';
@@ -0,0 +1,5 @@
1
+ import IAuthState from '../interfaces/IAuthState';
2
+
3
+ export function updateAuth(type:any,auth: Partial<IAuthState<any, any>>) {
4
+ return { type: type, payload: auth };
5
+ }
@@ -0,0 +1,51 @@
1
+ import { FC, JSX } from 'react';
2
+ import {
3
+ LOADING,
4
+ SET_HEADER_COMPONENTS,
5
+ SET_NAV_EXPANDED,
6
+ SET_NAV_SIZE,
7
+ SET_PANEL_SETTINGS,
8
+ } from './ActionTypes';
9
+
10
+ export function loading(loading: boolean) {
11
+ return { type: LOADING, loading };
12
+ }
13
+
14
+ export const setComponentState = (componentId: string, state: any) => {
15
+ return {
16
+ type: 'SET_COMPONENT_STATE',
17
+ componentId,
18
+ state,
19
+ };
20
+ };
21
+
22
+ export const unsetComponentState = (componentId: string) => ({
23
+ type: 'UNSET_COMPONENT_STATE',
24
+ componentId,
25
+ });
26
+
27
+ export const setHeaderComponent = (headerToolBar: FC, headerToolBarReplace?: boolean) => {
28
+ return {
29
+ type: SET_HEADER_COMPONENTS,
30
+ headerToolBar,
31
+ headerToolBarReplace: headerToolBarReplace ?? false,
32
+ };
33
+ };
34
+
35
+ export const setPanelSettings = (panelSettings: any) => {
36
+ return {
37
+ type: SET_PANEL_SETTINGS,
38
+ panelSettings,
39
+ };
40
+ };
41
+
42
+
43
+ export const setNavExpanded = (navExpanded: boolean) => ({
44
+ type: SET_NAV_EXPANDED,
45
+ payload: navExpanded,
46
+ });
47
+
48
+ export const setNavSize = (navSize: "large" | "small") => ({
49
+ type: SET_NAV_SIZE,
50
+ payload: navSize,
51
+ });
@@ -0,0 +1,78 @@
1
+ // ComponentData Actions
2
+ export const SET_COMPONENT_DATA = 'SET_COMPONENT_DATA';
3
+ export const CLEAR_COMPONENT_DATA = 'CLEAR_COMPONENT_DATA';
4
+ export const REMOVE_COMPONENT_DATA_KEY = 'REMOVE_COMPONENT_DATA_KEY';
5
+ export const MERGE_COMPONENT_DATA = 'MERGE_COMPONENT_DATA';
6
+
7
+ export interface ISetComponentDataAction {
8
+ type: typeof SET_COMPONENT_DATA;
9
+ payload: {
10
+ key: string;
11
+ data: any;
12
+ };
13
+ }
14
+
15
+ export interface IClearComponentDataAction {
16
+ type: typeof CLEAR_COMPONENT_DATA;
17
+ }
18
+
19
+ export interface IRemoveComponentDataKeyAction {
20
+ type: typeof REMOVE_COMPONENT_DATA_KEY;
21
+ payload: {
22
+ key: string;
23
+ };
24
+ }
25
+
26
+ export interface IMergeComponentDataAction {
27
+ type: typeof MERGE_COMPONENT_DATA;
28
+ payload: {
29
+ key: string;
30
+ data: any;
31
+ };
32
+ }
33
+
34
+ export type ComponentDataActionTypes =
35
+ | ISetComponentDataAction
36
+ | IClearComponentDataAction
37
+ | IRemoveComponentDataKeyAction
38
+ | IMergeComponentDataAction;
39
+
40
+ /**
41
+ * Set component data for a specific key
42
+ * @param key - The component key (e.g., 'tab.products.list')
43
+ * @param data - The data to store
44
+ */
45
+ export const setComponentData = (key: string, data: any) => ({
46
+ type: SET_COMPONENT_DATA,
47
+ payload: { key, data }
48
+ });
49
+
50
+ /**
51
+ * Merge data with existing component data for a specific key
52
+ * @param key - The component key
53
+ * @param data - The data to merge
54
+ */
55
+ export const mergeComponentData = (key: string, data: any): IMergeComponentDataAction => ({
56
+ type: MERGE_COMPONENT_DATA,
57
+ payload: { key, data }
58
+ });
59
+
60
+ /**
61
+ * Remove a specific component data key
62
+ * @param key - The component key to remove
63
+ */
64
+ export const removeComponentDataKey = (key: string): IRemoveComponentDataKeyAction => ({
65
+ type: REMOVE_COMPONENT_DATA_KEY,
66
+ payload: { key }
67
+ });
68
+
69
+ /**
70
+ * Clear all component data
71
+ */
72
+ export const clearComponentData = (): IClearComponentDataAction => ({
73
+ type: CLEAR_COMPONENT_DATA
74
+ });
75
+
76
+ // Convenience action creators for common patterns
77
+ export const setCustomData = setComponentData; // Alias for backward compatibility
78
+ export const clearCustomData = clearComponentData; // Alias for backward compatibility
@@ -0,0 +1,4 @@
1
+ // Add these imports at the top
2
+ import { setNavExpanded, toggleNavExpanded } from '../reducers/Menu';
3
+
4
+ export { setNavExpanded, toggleNavExpanded };
@@ -0,0 +1,6 @@
1
+ import IPage from '../interfaces/IPage';
2
+ import { ACTION_UPDATE_PAGE } from '../reducers/Page';
3
+
4
+ export function updatePage(page: IPage) {
5
+ return { type: ACTION_UPDATE_PAGE, payload: page };
6
+ }
@@ -0,0 +1,19 @@
1
+ import { SET_RESOURCES, APPEND_RESOURCES } from './ActionTypes';
2
+
3
+ export function setResources(resources) {
4
+ return (dispatch:any) => {
5
+ dispatch({
6
+ type: SET_RESOURCES,
7
+ payload: resources,
8
+ });
9
+ };
10
+ }
11
+
12
+ export function appendResources(resources) {
13
+ return (dispatch:any) => {
14
+ dispatch({
15
+ type: APPEND_RESOURCES,
16
+ payload: resources,
17
+ });
18
+ };
19
+ }
@@ -0,0 +1,91 @@
1
+ import DefaultThemeSettings from '../../DefaultThemeSettings';
2
+ import {
3
+ CONTENT_HEIGHT,
4
+ CONTENT_WIDTH,
5
+ UPDATE_THEME_SETTINGS,
6
+ SWITCH_LANGUAGE,
7
+ WINDOW_WIDTH,
8
+ } from './ActionTypes';
9
+
10
+ import { dashStorage } from 'dash-utils';
11
+
12
+ export function toggleThemeType(themeType) {
13
+ console.log("dash theme type", themeType)
14
+ //document.documentElement.setAttribute('data-theme', themeType)
15
+ dashStorage.setItem('theme', themeType)
16
+ //return { type: DefaultThemeSettings.THEME_TYPE, themeType };
17
+ return { type: DefaultThemeSettings.THEME_TYPE, themeType }
18
+ }
19
+
20
+ export function updateWindowWidth(width) {
21
+ return (dispatch) => {
22
+ dispatch({ type: WINDOW_WIDTH, width });
23
+ };
24
+ }
25
+
26
+ export function updateContentWidth(width) {
27
+ return (dispatch) => {
28
+ dispatch({ type: CONTENT_WIDTH, width });
29
+ };
30
+ }
31
+
32
+ export function updateContentHeight(height) {
33
+ return (dispatch) => {
34
+ dispatch({ type: CONTENT_HEIGHT, height });
35
+ };
36
+ }
37
+
38
+ export function setThemeType(themeType) {
39
+ return (dispatch) => {
40
+ dispatch({ type: DefaultThemeSettings.THEME_TYPE, themeType });
41
+ };
42
+ }
43
+
44
+ export function setThemeColor(themeColor) {
45
+ return (dispatch) => {
46
+ dispatch({ type: DefaultThemeSettings.THEME_COLOR, themeColor });
47
+ };
48
+ }
49
+
50
+ export function setDirectionRTL(rtlStatus) {
51
+ return (dispatch) => {
52
+ dispatch({ type: DefaultThemeSettings.UPDATE_RTL_STATUS, rtlStatus });
53
+ };
54
+ }
55
+
56
+ export function onNavStyleChange(navStyle) {
57
+ return (dispatch) => {
58
+ dispatch({ type: DefaultThemeSettings.NAV_STYLE, navStyle });
59
+ };
60
+ }
61
+
62
+ export function onLayoutTypeChange(layoutType) {
63
+ return (dispatch) => {
64
+ dispatch({ type: DefaultThemeSettings.LAYOUT_TYPE, layoutType });
65
+ };
66
+ }
67
+
68
+ export function switchLanguage(locale) {
69
+ return (dispatch) => {
70
+ dispatch({
71
+ type: SWITCH_LANGUAGE,
72
+ payload: locale,
73
+ });
74
+ };
75
+ }
76
+
77
+ export function setSidebarProps(width, expandedWidth) {
78
+ return (dispatch) => {
79
+ dispatch({
80
+ type: UPDATE_THEME_SETTINGS,
81
+ payload: { width: width, expandedWidth: expandedWidth },
82
+ });
83
+ };
84
+ }
85
+
86
+ export function updateThemeSettings(settings) {
87
+ return {
88
+ type: UPDATE_THEME_SETTINGS,
89
+ payload: settings,
90
+ };
91
+ }
@@ -0,0 +1,7 @@
1
+ export * from './Common';
2
+ export * from './Setting';
3
+ export * from './Auth';
4
+ export * from './Page';
5
+ export * from './Resources';
6
+ //export * from './Menu';
7
+ export * from './ComponentData';
@@ -0,0 +1,7 @@
1
+ export type IAuthState<U, A> = {
2
+ authenticated: boolean;
3
+ user: U;
4
+ auth: A;
5
+ };
6
+
7
+ export default IAuthState;
@@ -0,0 +1,25 @@
1
+ import { FC, JSX } from "react";
2
+
3
+ export interface IComponentState {
4
+ [x: string]: any;
5
+ }
6
+
7
+ export interface ICommonState {
8
+ appPath: string;
9
+ error: string;
10
+ loading: boolean;
11
+ message: any;
12
+ navExpanded: boolean;
13
+ navSize: "large" | "small";//string; //"large" | "small";
14
+ width: number | string | any;
15
+ height: number | string | any;
16
+ content_width?: number;
17
+ content_height?: number;
18
+ pathname: string;
19
+ componentsState?: {[x: string]: any}; // Changed from array to object
20
+ headerToolBar?: FC;
21
+ headerToolBarReplace?: boolean;
22
+ panelSettings?: {[x: string]: any};
23
+ }
24
+
25
+ export default ICommonState;
@@ -0,0 +1,32 @@
1
+ export default interface IComponentDataState {
2
+ [key: string]: any;
3
+ }
4
+
5
+ // Helper type for strongly typed component data access
6
+ export interface ITypedComponentData<T = any> {
7
+ data: T;
8
+ timestamp?: number;
9
+ version?: string;
10
+ }
11
+
12
+ /*
13
+ // Common component data patterns
14
+ export interface ITabProductsData {
15
+ products: any[];
16
+ filters: Record<string, any>;
17
+ pagination: {
18
+ page: number;
19
+ perPage: number;
20
+ total: number;
21
+ };
22
+ lastFetch: number;
23
+ }
24
+
25
+ export interface ITabsListData {
26
+ tabs: any[];
27
+ selectedTabs: string[];
28
+ statusFilter: string;
29
+ sortOrder: 'asc' | 'desc';
30
+ viewMode: 'grid' | 'list';
31
+ }
32
+ */
@@ -0,0 +1,53 @@
1
+ import IAuthState from './IAuthState';
2
+ import ICommonState from './ICommonState';
3
+ import IPageState from './IPage';
4
+ import ISettingsState from './ISettings';
5
+ import IFormDataState from './IFormDataState';
6
+ import { IMenuState } from '../reducers/Menu';
7
+ import IComponentDataState from './IComponentData';
8
+ /**
9
+ * Represents the overall state of the DASH application.
10
+ *
11
+ * @template U - The type of the user object.
12
+ * @template A - The type of the authentication object.
13
+ * @template R - The type of the resource items.
14
+ */
15
+ export interface IDASHAppState<U, A, R> {
16
+ /**
17
+ * The state of the current page in the DASH application.
18
+ */
19
+ page: IPageState;
20
+ /**
21
+ * The state of the application settings for the DASH application.
22
+ */
23
+ settings: ISettingsState;
24
+ /**
25
+ * The state of the authentication for the DASH application.
26
+ */
27
+ auth: IAuthState<U, A>;
28
+ /**
29
+ * The common state of the DASH application.
30
+ */
31
+ common: ICommonState;
32
+ /**
33
+ * IDashAutoResourceConfig or IDashAutoResourceConfig extended class, The resources property of the IDASHAppState interface, which contains an array of resource items of type R.
34
+ */
35
+ resources: { items: R[] };
36
+ /**
37
+ * The state of the current dirty form in the DASH application.
38
+ */
39
+ formData: IFormDataState;
40
+
41
+ /**
42
+ * The menu state of the DASH application.
43
+ */
44
+ menu?: IMenuState;
45
+
46
+ /**
47
+ * Generic store for DASH component.
48
+ */
49
+ componentData: IComponentDataState;
50
+
51
+ }
52
+
53
+ export default IDASHAppState;
@@ -0,0 +1,5 @@
1
+ import { JSX } from "react";
2
+
3
+ export interface IDASHResourceGroupsIcons {
4
+ [x: string]: JSX.Element;
5
+ }
@@ -0,0 +1,6 @@
1
+
2
+ export interface IFormDataState {
3
+ [x:string]: string
4
+ }
5
+
6
+ export default IFormDataState;
@@ -0,0 +1,27 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ /**
4
+ * Represents a single breadcrumb item in the navigation trail
5
+ */
6
+ export interface IBreadcrumbItem {
7
+ /** Display label for the breadcrumb */
8
+ label: string;
9
+ /** Navigation path (URL) for the breadcrumb. If undefined, item is not clickable */
10
+ path?: string;
11
+ /** Optional icon to display before the label */
12
+ icon?: ReactNode;
13
+ /** Whether this is the current/active breadcrumb */
14
+ isActive?: boolean;
15
+ /** Optional custom data for the breadcrumb */
16
+ data?: Record<string, any>;
17
+ }
18
+
19
+ export interface IPageState {
20
+ title?: string;
21
+ icon?: React.ReactNode;
22
+ subTitle?: string;
23
+ /** Breadcrumb navigation trail */
24
+ breadcrumbs?: IBreadcrumbItem[];
25
+ }
26
+
27
+ export default IPageState;
File without changes
@@ -0,0 +1,27 @@
1
+ import { IDASHResourceGroupsIcons } from "./IDashResourceGroupsIcons";
2
+
3
+ export interface ILocale {
4
+ languageId: string;
5
+ locale: string;
6
+ name: string;
7
+ icon: string;
8
+ }
9
+ // import IDashAutoAdminResourceConfig from "@dash-auto-admin/interfaces/IDashAutoAdminResourceConfig";
10
+ export interface ISettingsState {
11
+ loading: boolean;
12
+ navStyle: any;
13
+ layoutType: string;
14
+ themeType: string | any;
15
+ themeColor: string;
16
+ layoutSettings?: {[x: string]: any};
17
+ groupIcons?: IDASHResourceGroupsIcons;
18
+ isDirectionRTL: boolean;
19
+ // resources: IDashAutoAdminResourceConfig[]
20
+ locale: string;
21
+ availableLocales: ILocale[];
22
+ translations: {[locale: string]: {[key: string]: string}};
23
+ //sidebarExpandedWidth?: number;
24
+ //sidebarCollapsedWidth?: number;
25
+ }
26
+
27
+ export default ISettingsState;
@@ -0,0 +1,38 @@
1
+ import IAuthState from "../interfaces/IAuthState";
2
+
3
+ export const ACTION_UPDATE_AUTH = 'ACTION_UPDATE_AUTH';
4
+ export const ACTION_UPDATE_AUTH_AUTH = 'ACTION_UPDATE_AUTH_AUTH';
5
+ export const ACTION_UPDATE_AUTH_USER = 'ACTION_UPDATE_AUTH_USER';
6
+ export const ACTION_UPDATE_AUTH_AUTHENTICATED = 'ACTION_UPDATE_AUTH_AUTHENTICATED';
7
+
8
+ const AuthReducer = (state: IAuthState<any, any> = {
9
+ authenticated: false,
10
+ user: undefined,
11
+ auth: undefined
12
+ }, action) => {
13
+ switch (action.type) {
14
+ case ACTION_UPDATE_AUTH:
15
+ return {
16
+ ...state,
17
+ ...action.payload,
18
+ };
19
+ case ACTION_UPDATE_AUTH_AUTH:
20
+ return {
21
+ ...state,
22
+ auth: action.payload.auth,
23
+ };
24
+ case ACTION_UPDATE_AUTH_USER:
25
+ return {
26
+ ...state,
27
+ user: action.payload.user,
28
+ };
29
+ case ACTION_UPDATE_AUTH_AUTHENTICATED:
30
+ return {
31
+ ...state,
32
+ authenticated: action.payload.authenticated,
33
+ };
34
+ default:
35
+ return state;
36
+ }
37
+ };
38
+ export default AuthReducer;