Merge pull request #71 from yougotwill/feat/no-ref/debug_menu_user_access
Debug Menu updatespull/3281/head
commit
8da778668c
@ -0,0 +1,25 @@
|
|||||||
|
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
export interface DebugState {
|
||||||
|
debugMode: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initialDebugState = {
|
||||||
|
debugMode: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const debugSlice = createSlice({
|
||||||
|
name: 'debug',
|
||||||
|
initialState: initialDebugState,
|
||||||
|
reducers: {
|
||||||
|
setDebugMode: (state, action: PayloadAction<boolean>) => {
|
||||||
|
(window as Window).sessionFeatureFlags.debug.debugLogging = action.payload;
|
||||||
|
state.debugMode = action.payload;
|
||||||
|
return state;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { actions, reducer } = debugSlice;
|
||||||
|
export const { setDebugMode } = actions;
|
||||||
|
export const debugReducer = reducer;
|
@ -0,0 +1,10 @@
|
|||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import type { StateType } from '../reducer';
|
||||||
|
|
||||||
|
const getDebugMode = (state: StateType): boolean => {
|
||||||
|
return window.sessionFeatureFlags?.debug?.debugLogging || state?.debug?.debugMode || false;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useDebugMode = (): boolean => {
|
||||||
|
return useSelector(getDebugMode);
|
||||||
|
};
|
Loading…
Reference in New Issue