-
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.
Fixed the persistent issue and cart items for particular users
- Loading branch information
1 parent
b9f9d23
commit 01136b0
Showing
6 changed files
with
90 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,15 +1,21 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import App from './App' | ||
import './index.css' | ||
import { BrowserRouter } from "react-router-dom" | ||
import store from './redux/store' | ||
import { Provider } from 'react-redux' | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import App from "./App"; | ||
import "./index.css"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import store from "./redux/store"; | ||
import { Provider } from "react-redux"; | ||
import { PersistGate } from "redux-persist/integration/react"; | ||
import { persistStore } from "redux-persist"; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')).render( | ||
let persistor = persistStore(store); | ||
|
||
ReactDOM.createRoot(document.getElementById("root")).render( | ||
<Provider store={store}> | ||
<BrowserRouter> | ||
<App /> | ||
<PersistGate persistor={persistor}> | ||
<App /> | ||
</PersistGate> | ||
</BrowserRouter> | ||
</Provider>, | ||
) | ||
</Provider> | ||
); |
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,13 +1,37 @@ | ||
import { configureStore } from "@reduxjs/toolkit"; | ||
import { combineReducers, configureStore } from "@reduxjs/toolkit"; | ||
import cartReducer from "./Slices/cartSlice"; | ||
import authReducer from "./Slices/authSlice"; | ||
import wishlistReducer from "./Slices/wishlistSlice"; | ||
import storage from "redux-persist/lib/storage"; | ||
import { persistReducer } from "redux-persist"; | ||
|
||
const cartPersistConfig = { | ||
key: "cart", | ||
storage, | ||
}; | ||
|
||
const wishlistPersistConfig = { | ||
key: "wishlist", | ||
storage, | ||
}; | ||
|
||
const authReducerPersistConfig = { | ||
key: "auth", | ||
storage: storage, // Do not use storage for authReducer | ||
blacklist: ["user"], // Exclude 'user' field from being persisted | ||
}; | ||
|
||
const reducer = combineReducers({ | ||
cart: persistReducer(cartPersistConfig, cartReducer), | ||
auth: persistReducer(authReducerPersistConfig, authReducer), | ||
wishlist: persistReducer(wishlistPersistConfig, wishlistReducer), | ||
}); | ||
|
||
const persistendReducer = persistReducer( | ||
{ key: "root", version: 1, storage }, | ||
reducer | ||
); | ||
|
||
export default configureStore({ | ||
reducer: { | ||
cart: cartReducer, | ||
auth:authReducer, | ||
wishlist:wishlistReducer | ||
}, | ||
}) | ||
reducer: persistendReducer, | ||
}); |
01136b0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
e-commerce-website – ./
e-commerce-website-mohdfaisalbidda.vercel.app
e-commerce-website1-0.vercel.app
e-commerce-website-git-main-mohdfaisalbidda.vercel.app