This commit is contained in:
ajaythapliyal
2023-02-17 01:17:43 +05:30
parent 85b2f54829
commit 1b6a58520c
9 changed files with 301 additions and 6267 deletions

View File

@@ -1,48 +1,42 @@
import { configureStore, createSlice, PayloadAction } from '@reduxjs/toolkit';
interface State {
isApiKeyModalOpen: boolean;
apiKey: string;
isMenuOpen: boolean;
}
const initialState: State = {
isApiKeyModalOpen: false,
apiKey: '',
isMenuOpen: false,
};
export const slice = createSlice({
name: 'app',
initialState,
reducers: {
toggleApiKeyModal: (state) => {
state.isApiKeyModalOpen = !state.isApiKeyModalOpen;
console.log('showApiKeyModal', state.isApiKeyModalOpen);
},
setApiKey: (state, action: PayloadAction<string>) => {
state.apiKey = action.payload;
console.log('setApiKey', action.payload);
},
toggleIsMenuOpen: (state) => {
state.isMenuOpen = !state.isMenuOpen;
},
},
});
export const { toggleApiKeyModal, setApiKey, toggleIsMenuOpen } = slice.actions;
const store = configureStore({
reducer: {
app: slice.reducer,
},
});
type RootState = ReturnType<typeof store.getState>;
export const selectIsApiKeyModalOpen = (state: RootState) =>
state.app.isApiKeyModalOpen;
export const selectApiKey = (state: RootState) => state.app.apiKey;
export const selectIsMenuOpen = (state: RootState) => state.app.isMenuOpen;
export default store;
import { configureStore, createSlice, PayloadAction } from '@reduxjs/toolkit';
interface State {
isApiKeyModalOpen: boolean;
apiKey: string;
}
const initialState: State = {
isApiKeyModalOpen: false,
apiKey: '',
};
export const slice = createSlice({
name: 'app',
initialState,
reducers: {
toggleApiKeyModal: (state) => {
state.isApiKeyModalOpen = !state.isApiKeyModalOpen;
console.log('showApiKeyModal', state.isApiKeyModalOpen);
},
setApiKey: (state, action: PayloadAction<string>) => {
state.apiKey = action.payload;
console.log('setApiKey', action.payload);
},
},
});
export const { toggleApiKeyModal, setApiKey } = slice.actions;
const store = configureStore({
reducer: {
app: slice.reducer,
},
});
type RootState = ReturnType<typeof store.getState>;
export const selectIsApiKeyModalOpen = (state: RootState) =>
state.app.isApiKeyModalOpen;
export const selectApiKey = (state: RootState) => state.app.apiKey;
export default store;