generated from theodorusclarence/ts-nextjs-tailwind-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4414f5
commit 5f3ec95
Showing
2 changed files
with
49 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,48 @@ | ||
'use client'; | ||
|
||
import { configureStore } from '@reduxjs/toolkit'; | ||
import { configureStore, combineReducers } from '@reduxjs/toolkit'; | ||
import { persistStore, persistReducer } from 'redux-persist'; | ||
import storage from 'redux-persist/lib/storage'; | ||
import loginReducer from './Features/login/loginSlice'; | ||
import addressReducer from './Features/address/addressSlice'; | ||
import searchReducer from './Features/search/searchSlice'; | ||
import kernalClientSliceReducer from './Features/kernalClient/kernalClientSlice'; | ||
|
||
// Define RootState type | ||
type RootState = { | ||
login: { | ||
value: boolean; | ||
}; | ||
address: { | ||
value: string; | ||
}; | ||
search: { | ||
value: boolean; | ||
}; | ||
kernalClient: { | ||
value: {}; | ||
}; | ||
}; | ||
|
||
const persistConfig = { | ||
key: 'root', | ||
storage, | ||
}; | ||
|
||
// Combine reducers with RootState type | ||
const rootReducer = combineReducers<RootState>({ | ||
login: loginReducer, | ||
address: addressReducer, | ||
search: searchReducer, | ||
kernalClient: kernalClientSliceReducer, | ||
}); | ||
|
||
const persistedReducer = persistReducer(persistConfig, rootReducer); | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
login: loginReducer, | ||
address: addressReducer, | ||
search: searchReducer, | ||
kernalClient: kernalClientSliceReducer, | ||
}, | ||
reducer: persistedReducer, | ||
}); | ||
|
||
export type RootState = ReturnType<typeof store.getState>; | ||
export const persistor = persistStore(store); | ||
|
||
export type AppDispatch = typeof store.dispatch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters