diff --git a/frontend/app/components/books/BookCard.tsx b/frontend/app/components/books/BookCard.tsx index 769dd6e3..7eb2a3d0 100644 --- a/frontend/app/components/books/BookCard.tsx +++ b/frontend/app/components/books/BookCard.tsx @@ -15,13 +15,23 @@ const BookCard = ({ book }: BookCardProps) => { return ( - + - {!!user && } + {!!user && ( + + )} ); }; diff --git a/frontend/app/components/books/BookCardCartButton.tsx b/frontend/app/components/books/BookCardCartButton.tsx index 5beb1cb3..57fa666f 100644 --- a/frontend/app/components/books/BookCardCartButton.tsx +++ b/frontend/app/components/books/BookCardCartButton.tsx @@ -2,16 +2,22 @@ import { Button } from '@mantine/core'; import { useAtom } from 'jotai'; import { BiSolidCartAdd } from 'react-icons/bi'; import { cartAtom } from '~/stores/cartAtom'; +import { addBooksToCart } from '~/utils/cart'; interface BookCardCartButtonProps { id: number; stock: number; + thumbnail?: string; } -const BookCardCartButton = ({ id, stock }: BookCardCartButtonProps) => { +const BookCardCartButton = ({ + id, + stock, + thumbnail, +}: BookCardCartButtonProps) => { const [cart, setCart] = useAtom(cartAtom); const addCart = () => { - setCart([...cart, { id, stock }]); + setCart(addBooksToCart(cart, [{ id, stock, thumbnail }])); }; return (