aboutsummaryrefslogtreecommitdiff
path: root/jb-ui/src/store.ts
blob: baf13b75b17c5d3eb2295d2e906d06a71e75f5d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import appReducers from "@/models/appSlice";
import grlStatsReducers from "@/models/grlStatsSlice";
import grlEventsReducers from "@/models/grlEventsSlice";
import { authApi } from "@/models/authAPI";

import profilingQuestionsReducers from "@/models/profilingQuestionsSlice";
import type { Action, ThunkAction } from "@reduxjs/toolkit";
import { configureStore } from "@reduxjs/toolkit";

export const store = configureStore({
  reducer: {
    app: appReducers,
    // auth: authReducers,
    [authApi.reducerPath]: authApi.reducer,
    stats: grlStatsReducers,
    events: grlEventsReducers,
    profilingQuestions: profilingQuestionsReducers,
  },
  middleware: (getDefault) => getDefault().concat(authApi.middleware),
});

// Infer the type of `store`
export type AppStore = typeof store;
// Infer the `AppDispatch` type from the store itself
export type AppDispatch = typeof store.dispatch;
// Same for the `RootState` type

export type RootState = ReturnType<typeof store.getState>;

// Define a reusable type describing thunk functions
export type AppThunk<ThunkReturnType = void> = ThunkAction<
  ThunkReturnType,
  RootState,
  unknown,
  Action
>;