reducers.ts 871 B

12345678910111213141516171819202122232425262728293031
  1. import { createSlice, PayloadAction } from '@reduxjs/toolkit';
  2. import { AnalyticsTab, MetaAnalyticsState } from '../../types';
  3. const initialState: MetaAnalyticsState = {
  4. isDrawerOpen: false,
  5. drawerTab: AnalyticsTab.Stats,
  6. };
  7. const metaAnalyticsSlice = createSlice({
  8. name: 'metaAnalytics',
  9. initialState,
  10. reducers: {
  11. setDrawerOpen: (state: MetaAnalyticsState, action: PayloadAction<boolean>): MetaAnalyticsState => ({
  12. ...state,
  13. isDrawerOpen: action.payload,
  14. }),
  15. setDrawerTab: (state: MetaAnalyticsState, action: PayloadAction<AnalyticsTab>): MetaAnalyticsState => ({
  16. ...state,
  17. drawerTab: action.payload,
  18. }),
  19. },
  20. });
  21. export const { setDrawerOpen, setDrawerTab } = metaAnalyticsSlice.actions;
  22. export const metaAnalyticsReducers = metaAnalyticsSlice.reducer;
  23. export default {
  24. metaAnalytics: metaAnalyticsReducers,
  25. };