mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-09-07 13:05:46 +00:00
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { configureStore } from '@reduxjs/toolkit';
|
|
import { baseApi } from '@ema-platform/api';
|
|
import { authReducer } from '../features/auth/store/auth.slice';
|
|
import { signupReducer } from '../features/auth/store/signup.slice';
|
|
import { licensesReducer } from '../features/licenses/store/licenses.slice';
|
|
import { authStorage } from '../features/auth/utils/auth-storage';
|
|
|
|
const preloadedAuth = (() => {
|
|
const token = authStorage.getToken();
|
|
const user = authStorage.getUser();
|
|
if (token && user) {
|
|
return { token, user, isAuthenticated: true };
|
|
}
|
|
return undefined;
|
|
})();
|
|
|
|
export const store = configureStore({
|
|
reducer: {
|
|
auth: authReducer,
|
|
signup: signupReducer,
|
|
licenses: licensesReducer,
|
|
[baseApi.reducerPath]: baseApi.reducer,
|
|
},
|
|
preloadedState: preloadedAuth ? { auth: preloadedAuth } : undefined,
|
|
middleware: (getDefaultMiddleware) =>
|
|
getDefaultMiddleware().concat(baseApi.middleware),
|
|
});
|
|
|
|
export type RootState = ReturnType<typeof store.getState>;
|
|
export type AppDispatch = typeof store.dispatch;
|