Skip to content

Commit

Permalink
Add selected book to cart
Browse files Browse the repository at this point in the history
 (#90)
  • Loading branch information
kimurash committed Nov 8, 2024
1 parent 31742f7 commit 6cb09b3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion frontend/app/components/books/BookSelectedDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { Button, Center, Dialog, Stack, Text } from '@mantine/core';
import { useSubmit } from '@remix-run/react';
import { useAtom } from 'jotai';
import { selectedBooksAtom } from '~/stores/bookAtom';
import { cartAtom } from '~/stores/cartAtom';
import { successNotification } from '~/utils/notification';

const BookSelectedDialog = () => {
const [selectedBook, setSelectedBook] = useAtom(selectedBooksAtom);
const [cart, setCart] = useAtom(cartAtom);

const submit = useSubmit();

return (
Expand All @@ -21,7 +25,16 @@ const BookSelectedDialog = () => {
<Center>
<Text fw={500}>選択中の本が{selectedBook.length}冊あります</Text>
</Center>
<Button fz="xs" color="yellow">
<Button
fz="xs"
color="yellow"
onClick={() => {
setCart([...cart, ...selectedBook]);
setSelectedBook([]);

successNotification('カートに追加しました');
}}
>
選択中の本をカートに入れる
</Button>
<Button
Expand Down

0 comments on commit 6cb09b3

Please sign in to comment.