@@ -19,7 +19,7 @@ const Cart = () => {
1919
2020
2121 const updateData = ( bookName ) => {
22- const updatedCart = cartData . filter ( item => item . title !== bookName ) ;
22+ const updatedCart = cartData . filter ( item => item . bookName !== bookName ) ;
2323 setCartData ( updatedCart ) ;
2424 } ;
2525
@@ -171,16 +171,16 @@ const Cart = () => {
171171 </ div >
172172 < div className = "divide-y divide-gray-100" >
173173 { cartData . map ( item => (
174- < div key = { item . title } className = "p-4 hover:bg-gray-50 transition-colors" >
174+ < div key = { item . id } className = "p-4 hover:bg-gray-50 transition-colors" >
175175 < div className = "flex items-start space-x-4" >
176176 < img
177177 src = { item . imageLink }
178- alt = { item . title }
178+ alt = { item . bookName }
179179 className = "w-16 h-20 object-cover rounded-md flex-shrink-0"
180180 />
181181
182182 < div className = "flex-1 min-w-0" >
183- < h3 className = "text-lg font-semibold text-gray-900 truncate" > { item . title } </ h3 >
183+ < h3 className = "text-lg font-semibold text-gray-900 truncate" > { item . bookName } </ h3 >
184184 < p className = "text-sm text-gray-600 mt-1" > { item . author } </ p >
185185
186186 < div className = "flex items-center justify-between mt-3" >
@@ -201,8 +201,8 @@ const Cart = () => {
201201 < div className = "flex items-center space-x-2" >
202202 < button
203203 onClick = { ( ) => {
204- moveBook ( item . title , "wishlist" , handleError , handleSuccess )
205- updateData ( item . title ) ;
204+ moveBook ( item . bookName , "wishlist" , handleError , handleSuccess )
205+ updateData ( item . bookName ) ;
206206 } }
207207 className = "text-blue-500 hover:text-blue-700 transition p-2 hover:bg-blue-50 rounded"
208208 title = "Move to Wishlist"
@@ -211,8 +211,8 @@ const Cart = () => {
211211 </ button >
212212 < button
213213 onClick = { ( ) => {
214- deleteBook ( item . title , "cart" , handleError , handleSuccess ) ;
215- updateData ( item . title ) ;
214+ deleteBook ( item . bookName , "cart" , handleError , handleSuccess ) ;
215+ updateData ( item . bookName ) ;
216216 } }
217217 className = "text-red-500 hover:text-red-700 transition p-2 hover:bg-red-50 rounded"
218218 title = "Remove from Cart"
@@ -249,7 +249,7 @@ const Cart = () => {
249249 < div className = "p-4 space-y-4" >
250250 { cartData . map ( item => (
251251 < div key = { item . _id } className = "pb-3 border-b border-gray-100 last:border-b-0" >
252- < div className = "font-medium text-sm text-gray-900 mb-2" > { item . title } </ div >
252+ < div className = "font-medium text-sm text-gray-900 mb-2" > { item . bookName } </ div >
253253 < div className = "space-y-1 text-xs text-gray-600" >
254254 < div className = "flex justify-between" >
255255 < span > Book Price:</ span >
0 commit comments