Added Redux Provider to app layout and simplified Redux store to work properly with Next.js SSR. **Changes:** - Added ReduxProvider wrapper to root layout (app/layout.tsx) - Fixed ReduxProvider TypeScript type (React.ReactNode) - Simplified store configuration by removing @redux-offline package - Removed packages incompatible with SSR: - @redux-offline/redux-offline - redux-persist - localforage - Re-added NetworkStatusIndicator to main page (now works with Redux) - Kept custom offline middleware and sync middleware for offline-first functionality **Why:** The @redux-offline package and localforage try to access browser APIs (IndexedDB, localStorage) during SSR, causing "No available storage method found" errors. Our custom offline middleware provides the same functionality without SSR issues. **Result:** Redux store now works correctly with: - Network status detection - Offline action queuing - Custom sync middleware - Activities and children slices with optimistic updates Next step: Can add redux-persist back with proper SSR guards if needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { configureStore, Middleware } from '@reduxjs/toolkit';
|
|
|
|
// Slices
|
|
import offlineReducer from './slices/offlineSlice';
|
|
import activitiesReducer from './slices/activitiesSlice';
|
|
import childrenReducer from './slices/childrenSlice';
|
|
import networkReducer from './slices/networkSlice';
|
|
|
|
// Middleware
|
|
import { offlineMiddleware } from './middleware/offlineMiddleware';
|
|
import { syncMiddleware } from './middleware/syncMiddleware';
|
|
|
|
export const store = configureStore({
|
|
reducer: {
|
|
offline: offlineReducer,
|
|
activities: activitiesReducer,
|
|
children: childrenReducer,
|
|
network: networkReducer,
|
|
},
|
|
middleware: (getDefaultMiddleware) =>
|
|
getDefaultMiddleware({
|
|
serializableCheck: {
|
|
// Ignore these action types for serialization check
|
|
ignoredActions: ['persist/PERSIST', 'persist/REHYDRATE'],
|
|
// Ignore these field paths in all actions
|
|
ignoredActionPaths: ['meta.arg', 'payload.timestamp'],
|
|
// Ignore these paths in the state
|
|
ignoredPaths: ['items.dates'],
|
|
},
|
|
}).concat(offlineMiddleware, syncMiddleware),
|
|
});
|
|
|
|
// Infer the `RootState` and `AppDispatch` types from the store itself
|
|
export type RootState = ReturnType<typeof store.getState>;
|
|
export type AppDispatch = typeof store.dispatch;
|
|
|
|
// Export store instance
|
|
export default store;
|