60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { configureStore, combineReducers } from '@reduxjs/toolkit';
|
|
import { persistReducer, persistStore } from 'redux-persist';
|
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
|
|
// Feature slices (to be added)
|
|
import uiSlice from '@/shared/store/uiSlice';
|
|
import authSlice from '@/modules/auth/store/authSlice';
|
|
import hrSlice from '@/modules/hr/zoho/store/hrSlice';
|
|
import zohoProjectsSlice from '@/modules/zohoProjects/store/zohoProjectsSlice';
|
|
import profileSlice from '@/modules/profile/store/profileSlice';
|
|
import integrationsSlice from '@/modules/integrations/store/integrationsSlice';
|
|
import crmSlice from '@/modules/crm/zoho/store/crmSlice';
|
|
import salesforceCrmSlice from '@/modules/crm/salesforce/store/salesforceCrmSlice';
|
|
import zohoBooksSlice from '@/modules/finance/zoho/store/zohoBooksSlice';
|
|
|
|
const rootReducer = combineReducers({
|
|
auth: authSlice.reducer,
|
|
zohoPeople: hrSlice.reducer,
|
|
zohoProjects: zohoProjectsSlice.reducer,
|
|
profile: profileSlice.reducer,
|
|
integrations: integrationsSlice.reducer,
|
|
crm: crmSlice,
|
|
salesforceCrm: salesforceCrmSlice,
|
|
zohoBooks: zohoBooksSlice,
|
|
ui: uiSlice.reducer,
|
|
});
|
|
|
|
const persistConfig = {
|
|
key: 'root',
|
|
storage: AsyncStorage,
|
|
whitelist: ['auth', 'zohoPeople', 'zohoProjects', 'profile', 'integrations', 'crm', 'salesforceCrm', 'zohoBooks'],
|
|
blacklist: ['ui'],
|
|
};
|
|
|
|
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
|
|
|
export const store = configureStore({
|
|
reducer: persistedReducer,
|
|
middleware: getDefaultMiddleware =>
|
|
getDefaultMiddleware({
|
|
serializableCheck: {
|
|
ignoredActions: [
|
|
'persist/FLUSH',
|
|
'persist/REHYDRATE',
|
|
'persist/PAUSE',
|
|
'persist/PERSIST',
|
|
'persist/PURGE',
|
|
'persist/REGISTER',
|
|
],
|
|
},
|
|
}),
|
|
});
|
|
|
|
export const persistor = persistStore(store);
|
|
|
|
export type RootState = ReturnType<typeof store.getState>;
|
|
export type AppDispatch = typeof store.dispatch;
|
|
|
|
|