From d543153941027c9280eea067a411e2043b8cfe7f Mon Sep 17 00:00:00 2001 From: Kosei805 Date: Thu, 14 Nov 2024 09:09:20 +0900 Subject: [PATCH] fix: organize function, props, function name --- frontend/app/components/books/BookCard.tsx | 9 +++++++-- .../components/books/BookCardCartButton.tsx | 11 ++++++++--- .../app/components/books/BookCardFooter.tsx | 5 +++-- .../app/components/books/BookCardHeader.tsx | 18 ++++++------------ .../app/components/cart/CartCardHeader.tsx | 13 ++++++------- .../app/components/cart/CartListComponent.tsx | 10 +++++++--- .../components/cart/CartSelectedDialog.tsx | 8 +++++--- frontend/app/routes/home.cart/route.tsx | 6 ++++-- frontend/app/utils/cart.ts | 19 ------------------- 9 files changed, 46 insertions(+), 53 deletions(-) diff --git a/frontend/app/components/books/BookCard.tsx b/frontend/app/components/books/BookCard.tsx index 0e4b19ba..7eb2a3d0 100644 --- a/frontend/app/components/books/BookCard.tsx +++ b/frontend/app/components/books/BookCard.tsx @@ -18,7 +18,6 @@ const BookCard = ({ book }: BookCardProps) => { @@ -26,7 +25,13 @@ const BookCard = ({ book }: BookCardProps) => { - {!!user && } + {!!user && ( + + )} ); }; diff --git a/frontend/app/components/books/BookCardCartButton.tsx b/frontend/app/components/books/BookCardCartButton.tsx index fb564e78..57fa666f 100644 --- a/frontend/app/components/books/BookCardCartButton.tsx +++ b/frontend/app/components/books/BookCardCartButton.tsx @@ -2,17 +2,22 @@ import { Button } from '@mantine/core'; import { useAtom } from 'jotai'; import { BiSolidCartAdd } from 'react-icons/bi'; import { cartAtom } from '~/stores/cartAtom'; -import { addBookToCart } from '~/utils/cart'; +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(addBookToCart(cart, id, stock)); + setCart(addBooksToCart(cart, [{ id, stock, thumbnail }])); }; return (