Skip to content

Commit

Permalink
redux toolkit added
Browse files Browse the repository at this point in the history
  • Loading branch information
shohan-pherones committed Apr 7, 2023
1 parent dd171d8 commit 70f09eb
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 6 deletions.
155 changes: 154 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
},
"dependencies": {
"@prisma/client": "^4.12.0",
"@reduxjs/toolkit": "^1.9.3",
"eslint": "8.37.0",
"eslint-config-next": "13.2.4",
"next": "13.2.4",
"prisma": "^4.12.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.8.0"
"react-icons": "^4.8.0",
"react-redux": "^8.0.5"
},
"devDependencies": {
"autoprefixer": "^10.4.14",
Expand Down
10 changes: 7 additions & 3 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Footer from "@/components/Footer";
import Navbar from "@/components/Navbar";
import Head from "next/head";
import "@/styles/globals.css";
import { Provider } from "react-redux";
import store from "@/store";

export default function App({ Component, pageProps }) {
return (
Expand All @@ -20,9 +22,11 @@ export default function App({ Component, pageProps }) {
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://www.euphoria.com/" />
</Head>
<Navbar />
<Component {...pageProps} />
<Footer />
<Provider store={store}>
<Navbar />
<Component {...pageProps} />
<Footer />
</Provider>
</>
);
}
5 changes: 4 additions & 1 deletion pages/products/[productId].js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ const ProductDetails = ({ product }) => {
>
Add to Cart
</Link>
<p className="text-gray-500 mt-5">{product.description}</p>
<div className="mt-5">
<p className="font-medium mb-3">Description:</p>
<p className="text-gray-500">{product.description}</p>
</div>
</div>
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { configureStore } from "@reduxjs/toolkit";
import { productSlice } from "./productSlice";

const store = configureStore({
reducer: {
products: productSlice.reducer,
},
});

export default store;
15 changes: 15 additions & 0 deletions store/productSlice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createSlice } from "@reduxjs/toolkit";

const initialState = {
products: localStorage.getItem("products")
? JSON.parse(localStorage.getItem("products"))
: [],
};

export const productSlice = createSlice({
name: "products",
initialState,
reducers: {},
});

export const {} = productSlice.actions;

0 comments on commit 70f09eb

Please sign in to comment.