Skip to content

Commit 5950dd1

Browse files
committed
Fix bookPreview page issue
1 parent 7879d2c commit 5950dd1

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Components/Features/BookPreview.jsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { useState, useContext} from 'react';
1+
import { useContext, useState} from 'react';
22
import { Heart, ShoppingCart, Star, ChevronDown } from 'lucide-react';
33
import { useLocation } from 'react-router-dom';
44
import useAlert from '../utils/setAlert';
55
import { addBook } from '../utils/bookOperation'; // Import the addBook function
66
import { AuthContext } from '../../context/AuthContext';
77

88
const BookPreviewPage = () => {
9-
const {isAuthenticated, user} = useContext(AuthContext)
10-
const [email] = useState(user ? user.email : "");
9+
const {isAuthenticated} = useContext(AuthContext)
1110
const { handleError, handleSuccess } = useAlert();
1211
const location = useLocation();
1312
const book = location.state || {};
@@ -38,18 +37,16 @@ const BookPreviewPage = () => {
3837
handleError("Please select a period");
3938
}else{
4039
const options = {
41-
email,
42-
rentalPeriod
40+
rentalPeriod,
41+
bookName : book.title
4342
}
4443
setIsSubmitting(true);
4544
addBook(book.title,type, handleError, handleSuccess, options);
4645
setIsSubmitting(false);
4746
}
48-
}else{
47+
}else if(type === 'wishlist'){
4948
const options = {
5049
bookName : book.title,
51-
email,
52-
rentalPeriod
5350
}
5451
setIsSubmitting(true);
5552
addBook(book.title,type, handleError, handleSuccess, options);

0 commit comments

Comments
 (0)