+
+
+
-
- {filteredData?.map((product: ProductType) => (
-
-
-
-

-
{product.title}
-
{product.rating}
- {/*
{product.description}
*/}
-
-
-
-
${product.price}
-
-
-
- ))}
-
)
}
+
+const MemoizedProductListingPage = memo(ProductListingPage)
+export default MemoizedProductListingPage
diff --git a/client/src/pages/product-listing/components/product-card/ProductCard.module.css b/client/src/pages/product-listing/components/product-card/ProductCard.module.css
new file mode 100644
index 0000000..e69de29
diff --git a/client/src/pages/product-listing/components/product-card/ProductCard.tsx b/client/src/pages/product-listing/components/product-card/ProductCard.tsx
new file mode 100644
index 0000000..a3b4621
--- /dev/null
+++ b/client/src/pages/product-listing/components/product-card/ProductCard.tsx
@@ -0,0 +1,42 @@
+import { ProductType } from '@/types'
+import Paper from '@mui/material/Paper'
+import { Link } from 'react-router-dom'
+
+type Props = {
+ product: ProductType
+}
+
+export default function ProductCard({ product }: Props) {
+ return (
+
+
+
+
+

+
{product.title}
+
{product.rating}
+
{product.description}
+
+
+
+
${product.price}
+
+
+
+
+ )
+}
diff --git a/client/src/pages/product-listing/components/products/Products.tsx b/client/src/pages/product-listing/components/products/Products.tsx
new file mode 100644
index 0000000..55a30a6
--- /dev/null
+++ b/client/src/pages/product-listing/components/products/Products.tsx
@@ -0,0 +1,16 @@
+import type { ProductType } from '@/types'
+import ProductCard from '../product-card/ProductCard'
+
+type Props = {
+ filteredData: ProductType[]
+}
+
+export default function Products({ filteredData }: Props) {
+ return (
+
+ {filteredData?.map((product) => (
+
+ ))}
+
+ )
+}
diff --git a/client/src/pages/signup/SignUpPage.tsx b/client/src/pages/signup/SignUpPage.tsx
index 308566d..c181d06 100644
--- a/client/src/pages/signup/SignUpPage.tsx
+++ b/client/src/pages/signup/SignUpPage.tsx
@@ -1,37 +1,14 @@
-import { Link } from 'react-router-dom'
-import styles from './SignUpPage.module.css'
+import Form from '@/components/form/Form'
export default function SignUpPage() {
return (
-
-
-
- Login
-
-
-
Get access to your Orders,
-
Wishlist and Recommendations
-
-
-
-
+ <>
+
+ >
)
}
diff --git a/client/src/state/services/productApi.ts b/client/src/state/services/productApi.ts
index 9dd032a..6d48680 100644
--- a/client/src/state/services/productApi.ts
+++ b/client/src/state/services/productApi.ts
@@ -1,6 +1,6 @@
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
import { ENV } from '@/conf'
-import { ProductType } from '@/types'
+import type { ProductType } from '@/types'
export const productApi = createApi({
reducerPath: 'api',
diff --git a/client/src/state/slices/cartSlice.ts b/client/src/state/slices/cartSlice.ts
index 4e5764b..7e4d705 100644
--- a/client/src/state/slices/cartSlice.ts
+++ b/client/src/state/slices/cartSlice.ts
@@ -1,5 +1,5 @@
-import { CartType } from '@/types'
-import { PayloadAction, createSlice, nanoid } from '@reduxjs/toolkit'
+import type { CartType } from '@/types'
+import { createSlice, nanoid } from '@reduxjs/toolkit'
const initialState = JSON.parse(localStorage.getItem('cart') || '[]')
@@ -29,7 +29,7 @@ const cartSlice = createSlice({
}
localStorage.setItem('cart', JSON.stringify(state))
},
- removeFromCart(state, action: PayloadAction
) {
+ removeFromCart(state, action) {
const newState = state.filter(
(item: CartType) => item.cartItemId !== action.payload
)
diff --git a/client/src/state/slices/filtersSlice.ts b/client/src/state/slices/filtersSlice.ts
deleted file mode 100644
index 7c4d7dd..0000000
--- a/client/src/state/slices/filtersSlice.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import { createSlice, PayloadAction } from '@reduxjs/toolkit'
-import { ProductType } from '@/types'
-
-type InitialStateType = {
- data: ProductType[]
- sort: string
- stateRating: string | null
- priceRange: number[]
- searchQuery: string
- category: string
-}
-
-export const initialState: InitialStateType = {
- data: [],
- sort: '',
- stateRating: null,
- priceRange: [10, 2000],
- searchQuery: '',
- category: '',
-}
-
-const filtersSlice = createSlice({
- name: 'filters',
- initialState,
- reducers: {
- sort(state, action: PayloadAction) {
- state.sort = action.payload
- },
- filterRating(state, action: PayloadAction) {
- state.stateRating = action.payload
- },
- priceRange(state, action) {
- state.priceRange = action.payload
- },
- filterSearch(state, action) {
- state.searchQuery = action.payload
- },
- categoryFilter(state, action) {
- state.category = action.payload
- },
- clearFilters() {
- return initialState
- },
- },
-})
-
-export const {
- filterRating,
- sort,
- priceRange,
- filterSearch,
- categoryFilter,
- clearFilters,
-} = filtersSlice.actions
-
-export default filtersSlice.reducer
diff --git a/client/src/state/slices/index.ts b/client/src/state/slices/index.ts
index eba2234..af9b954 100644
--- a/client/src/state/slices/index.ts
+++ b/client/src/state/slices/index.ts
@@ -1,4 +1,3 @@
import cartReducer from './cartSlice'
-import filtersReducer from './filtersSlice'
-export { cartReducer, filtersReducer }
+export { cartReducer }
diff --git a/client/src/state/store.ts b/client/src/state/store.ts
index 768e9a1..ec4841a 100644
--- a/client/src/state/store.ts
+++ b/client/src/state/store.ts
@@ -1,19 +1,22 @@
import { configureStore } from '@reduxjs/toolkit'
-import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
+import type { TypedUseSelectorHook } from 'react-redux'
+import { useDispatch, useSelector } from 'react-redux'
+import { setupListeners } from '@reduxjs/toolkit/query'
import { productApi } from './services'
-import { cartReducer, filtersReducer } from './slices'
+import { cartReducer } from './slices'
const store = configureStore({
reducer: {
cart: cartReducer,
- filter: filtersReducer,
[productApi.reducerPath]: productApi.reducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(productApi.middleware),
})
+setupListeners(store.dispatch)
+
// Types for store.
type RootState = ReturnType
type AppDispatch = typeof store.dispatch
diff --git a/client/src/types/index.ts b/client/src/types/index.ts
index bc7e7e2..c15ca15 100644
--- a/client/src/types/index.ts
+++ b/client/src/types/index.ts
@@ -11,17 +11,7 @@ export type ProductType = {
thumbnail: string
}
-export type CartType = {
- id: number
- title: string
- description: string
- price: number
- discountPercentage: number
- rating: number
- stock: number
- brand: string
- category: string
- thumbnail: string
+export type CartType = ProductType & {
quantity: number
cartItemId: string
}
diff --git a/client/src/utils/index.ts b/client/src/utils/index.ts
index 898d270..344e0c0 100644
--- a/client/src/utils/index.ts
+++ b/client/src/utils/index.ts
@@ -1,4 +1,4 @@
-import { CartType } from '../types'
+import type { CartType } from '@/types'
export const totalCartPrice = (cartData: CartType[]) => {
let cartPrice = 0
diff --git a/server/src/app.js b/server/src/app.js
index 1246e86..415fcaa 100644
--- a/server/src/app.js
+++ b/server/src/app.js
@@ -17,7 +17,7 @@ app.use(express.static('public'))
app.use(cookieParser())
// Routes
-import { Payment } from './Models/payment.model.js'
+import { Payment } from './models/payment.model.js'
import paymentRoute from './routes/payment.routes.js'
app.use('/api/v1', paymentRoute)
diff --git a/server/src/controllers/payment.controller.js b/server/src/controllers/payment.controller.js
index 5019ab3..bd25de6 100644
--- a/server/src/controllers/payment.controller.js
+++ b/server/src/controllers/payment.controller.js
@@ -1,5 +1,5 @@
import crypto from 'crypto'
-import { Payment } from '../Models/payment.model.js'
+import { Payment } from '../models/payment.model.js'
import { ENV } from '../conf/conf.js'
import { CLIENT_BASE_URL } from '../constants.js'
import { razorpayInstance } from '../index.js'
diff --git a/server/src/Models/payment.model.js b/server/src/models/payment.model.js
similarity index 100%
rename from server/src/Models/payment.model.js
rename to server/src/models/payment.model.js