diff --git a/frontend/app/components/books/BookCardHeader.tsx b/frontend/app/components/books/BookCardHeader.tsx index 85d66002..d769ed51 100644 --- a/frontend/app/components/books/BookCardHeader.tsx +++ b/frontend/app/components/books/BookCardHeader.tsx @@ -1,7 +1,7 @@ import { Checkbox, Group } from '@mantine/core'; import { useAtom } from 'jotai'; +import { selectedBooksAtom } from '~/stores/bookAtom'; import type { CartProps } from '~/stores/cartAtom'; -import { selectedBooksAtom } from '~/stores/cartAtom'; import { userAtom } from '~/stores/userAtom'; import BookCardHeaderBadge from './BookCardHeaderBadge'; diff --git a/frontend/app/routes/home._index/route.tsx b/frontend/app/routes/home._index/route.tsx index e69e1fef..76427eb8 100644 --- a/frontend/app/routes/home._index/route.tsx +++ b/frontend/app/routes/home._index/route.tsx @@ -8,7 +8,7 @@ import { GetBooksParams } from 'client/client.schemas'; import { useAtom } from 'jotai'; import { useEffect } from 'react'; import BookListComponent from '~/components/books/BookListComponent'; -import { selectedBooksAtom } from '~/stores/cartAtom'; +import { selectedBooksAtom } from '~/stores/bookAtom'; interface LoaderData { booksResponse: getBooksResponse; diff --git a/frontend/app/stores/bookAtom.ts b/frontend/app/stores/bookAtom.ts new file mode 100644 index 00000000..a8308dfe --- /dev/null +++ b/frontend/app/stores/bookAtom.ts @@ -0,0 +1,10 @@ +import { atom } from 'jotai'; + +export interface SelectedBookProps { + id: number; + stock: number; +} + +// 選択された本を管理するAtom +// 生存時間: DOM(ページをリロードするまで) +export const selectedBooksAtom = atom([]); diff --git a/frontend/app/stores/cartAtom.ts b/frontend/app/stores/cartAtom.ts index a0d681cf..c4769c90 100644 --- a/frontend/app/stores/cartAtom.ts +++ b/frontend/app/stores/cartAtom.ts @@ -1,4 +1,3 @@ -import { atom } from 'jotai'; import { atomWithStorage, createJSONStorage } from 'jotai/utils'; const storage = createJSONStorage(() => sessionStorage); @@ -10,7 +9,3 @@ export interface CartProps { // カートの中身を管理するAtom // 生存時間: セッションストレージ(タブが閉じられるまで) export const cartAtom = atomWithStorage('cart', [], storage); - -// 選択された本を管理するAtom -// 生存時間: DOM(ページをリロードするまで) -export const selectedBooksAtom = atom([]);