feat: have a user method to toggle the debug menu
new redux slice for debug statepull/3281/head
parent
17d2b10a09
commit
290cc5f8fe
@ -0,0 +1,24 @@
|
|||||||
|
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;
|
||||||
|
return { ...state, debugMode: action.payload };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useDebugMode = (): boolean => {
|
||||||
|
return useSelector(getDebugMode);
|
||||||
|
};
|
Loading…
Reference in New Issue