Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

各ページのコンポーネントを routes 配下に移した #179

Merged
merged 14 commits into from
Dec 17, 2024
Merged
4 changes: 3 additions & 1 deletion backend/src/api/google-books.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ app.get(
});

// Google Books APIにリクエストを送信する
const response = await fetch(`${GOOGLE_BOOOKS_BASE_URL}?${params}`);
const response = await fetch(
`${GOOGLE_BOOOKS_BASE_URL}?${params.toString()}`,
);
if (response.status !== 200) {
const error: GoogleAPIError = await response.json();
return ctx.json(error, { status: response.status });
Expand Down
46 changes: 0 additions & 46 deletions frontend/app/components/book-detail/BookDetailActionPanel.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { SerializeFrom } from '@remix-run/cloudflare';
import { getBooksResponse } from 'client/client';
import type { GetBooksParams } from 'client/client.schemas';
import { LuBookCopy } from 'react-icons/lu';
import BreadCrumbsComponent from '~/components/breadcrumbs/BreadCrumbsComponent';
import ErrorComponent from '~/components/error/ErrorComponent';
import ContentsHeader from '~/components/pagination/ContentsHeader';
import PaginationComponent from '~/components/pagination/PaginationComponent';
import { PaginationProps } from '~/types/pagination';
import BookSearchComponent from '../book-search/BookSearchComponent';
import BreadCrumbsComponent from '../common/breadcrumbs/BreadCrumbsComponent';
import ErrorComponent from '../common/error/ErrorComponent';
import ContentsHeader from '../common/pagination/ContentsHeader';
import PaginationComponent from '../common/pagination/PaginationComponent';
import BookCards from './BookCards';
import BookSearchComponent from './search-form/BookSearchComponent';

interface BookListComponentProps {
booksResponse: SerializeFrom<getBooksResponse>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Collapse } from '@mantine/core';
import type { UseFormReturnType } from '@mantine/form';
import type { GetBooksParams } from 'client/client.schemas';
import FormLayout from '../layouts/FormLayout';
import FormLayout from '~/components/layouts/FormLayout';
import BookSearchAuthorForm from './BookSearchAuthorForm';
import BookSearchIsbnForm from './BookSearchIsbnForm';
import BookSearchPublisherForm from './BookSearchPublisherForm';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { UseFormReturnType } from '@mantine/form';
import { useDisclosure } from '@mantine/hooks';
import type { GetBooksParams } from 'client/client.schemas';
import { MdCameraAlt } from 'react-icons/md';
import IsbnScanModal from '../common/isbn-scan-modal/IsbnScanModal';
import IsbnScanModal from '~/components/isbn-scan-modal/IsbnScanModal';

interface SearchIsbnFormProps {
form: UseFormReturnType<
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/routes/home._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { deleteBooks, getBooks, getBooksResponse } from 'client/client';
import { Book, GetBooksParams } from 'client/client.schemas';
import { useAtom } from 'jotai';
import { useEffect } from 'react';
import BookListComponent from '~/components/books/BookListComponent';
import { commitSession, getSession } from '~/services/session.server';
import { selectedBooksAtom } from '~/stores/bookAtom';
import { ActionResponse } from '~/types/response';
import { makeCookieHeader } from '~/utils/session';
import BookListComponent from './components/BookListComponent';

interface LoaderData {
booksResponse: getBooksResponse;
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/routes/home.books.$bookId._index/route.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useOutletContext } from '@remix-run/react';
import { BookDetailOutletContext } from '../home.books.$bookId/route';
import BookDetailContent from '~/components/book-detail/BookDetailContent';
import BookDetailContent from './components/BookDetailContent';

const BookDetailPage = () => {
const { book, loansResponse } = useOutletContext<BookDetailOutletContext>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UseFormReturnType } from '@mantine/form';
import FormLayout from '~/components/layouts/FormLayout';
import { CustomUpdateBookBody } from '~/routes/home.books.$bookId.edit/route';
import FormLayout from '../layouts/FormLayout';
import BookDetailAuthorsForm from './BookDetailAuthorsForm';
import BookDetailEditTitle from './BookDetailEditTitle';
import BookDetailIsbnForm from './BookDetailIsbnForm';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/routes/home.books.$bookId.edit/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
import { useOutletContext, useSubmit } from '@remix-run/react';
import { updateBook } from 'client/client';
import { UpdateBookBody } from 'client/client.schemas';
import BookDetailEditContent from '~/components/book-detail-edit/BookDetailEditContent';
import { commitSession, getSession } from '~/services/session.server';
import { formatDate } from '~/utils/date';
import { makeCookieHeader } from '~/utils/session';
import { BookDetailOutletContext } from '../home.books.$bookId/route';
import BookDetailEditContent from './components/BookDetailEditContent';

export interface CustomUpdateBookBody extends UpdateBookBody {
customPublishedDate?: Date;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Stack } from '@mantine/core';
import { Book } from 'client/client.schemas';
import BookDetailControlButtons from './BookDetailControlButtons';
import BookDetailThumbnail from './BookDetailThumbnail';

interface BookDetailActionPanelProps {
book: Book;
}

const BookDetailActionPanel = ({ book }: BookDetailActionPanelProps) => {
return (
<Stack
bg="var(--mantine-color-body)"
align="stretch"
justify="center"
gap="md"
>
<BookDetailThumbnail thumbnail={book.thumbnail} />
<BookDetailControlButtons id={Number(book.id)} />
</Stack>
);
};

export default BookDetailActionPanel;
6 changes: 3 additions & 3 deletions frontend/app/routes/home.books.$bookId/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { Book } from 'client/client.schemas';
import { FaBook } from 'react-icons/fa6';
import { LuBookCopy } from 'react-icons/lu';
import { TbBookUpload } from 'react-icons/tb';
import BookDetailActionPanel from '~/components/book-detail/BookDetailActionPanel';
import BreadCrumbsComponent from '~/components/common/breadcrumbs/BreadCrumbsComponent';
import ErrorComponent from '~/components/common/error/ErrorComponent';
import BreadCrumbsComponent from '~/components/breadcrumbs/BreadCrumbsComponent';
import ErrorComponent from '~/components/error/ErrorComponent';
import { commitSession, getSession } from '~/services/session.server';
import { ActionResponse } from '~/types/response';
import { makeCookieHeader } from '~/utils/session';
import BookDetailActionPanel from './components/BookDetailActionPanel';

interface LoaderData {
bookResponse: getBookResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Card } from '@mantine/core';
import BookCardThumbnail from '~/routes/home._index/components/BookCardThumbnail';
import { CartProps } from '~/stores/cartAtom';
import BookCardThumbnail from '../books/BookCardThumbnail';
import CartCardHeader from './CartCardHeader';

interface CartCardProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Stack } from '@mantine/core';
import { useAtom } from 'jotai';
import { LuShoppingCart } from 'react-icons/lu';
import BreadCrumbsComponent from '~/components/breadcrumbs/BreadCrumbsComponent';
import { cartAtom } from '~/stores/cartAtom';
import BreadCrumbsComponent from '../common/breadcrumbs/BreadCrumbsComponent';
import CartCards from './CartCards';
import CartSelectedDialog from './CartSelectedDialog';
import CartTitle from './CartTitle';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/routes/home.cart/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { upsertLoans } from 'client/client';
import { UpsertLoansBodyItem } from 'client/client.schemas';
import { useAtom } from 'jotai';
import { useEffect } from 'react';
import CartListComponent from '~/components/cart/CartListComponent';
import { commitSession, getSession } from '~/services/session.server';
import type { CartProps } from '~/stores/cartAtom';
import { selectedCartBooksAtom } from '~/stores/cartAtom';
import { makeCookieHeader } from '~/utils/session';
import CartListComponent from './components/CartListComponent';

export const loader = async ({ request }: LoaderFunctionArgs) => {
const session = await getSession(request.headers.get('Cookie'));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Stack } from '@mantine/core';
import { GoogleBook } from 'client/client.schemas';
import BookDetailThumbnail from '~/routes/home.books.$bookId/components/BookDetailThumbnail';
import GlobalBookDetailControlButtons from './GlobalBookDetailControlButtons';

interface BookDetailActionPanelProps {
book: GoogleBook;
totalBook?: number;
}

const BookDetailActionPanel = ({
book,
totalBook,
}: BookDetailActionPanelProps) => {
return (
<Stack
bg="var(--mantine-color-body)"
align="stretch"
justify="center"
gap="md"
>
<BookDetailThumbnail thumbnail={book.thumbnail} />
<GlobalBookDetailControlButtons
book={book as GoogleBook}
totalBook={totalBook ?? 0}
/>
</Stack>
);
};

export default BookDetailActionPanel;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stack } from '@mantine/core';
import { GoogleBook } from 'client/client.schemas';
import BookDetailDescription from '../book-detail/BookDetailDescription';
import BookDetailTitle from '../book-detail/BookDetailTitle';
import BookDetailDescription from '~/routes/home.books.$bookId._index/components/BookDetailDescription';
import BookDetailTitle from '~/routes/home.books.$bookId._index/components/BookDetailTitle';
import GlobalBookDetailContentTable from './GlobalBookDetailContentTable';
import GlobalBookDetailLink from './GlobalBookDetailLink';

Expand Down
6 changes: 3 additions & 3 deletions frontend/app/routes/home.global.$volumeId/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { createBook, getBooks, getGoogleBook } from 'client/client';
import { CreateBookBody, GoogleBook } from 'client/client.schemas';
import { AiOutlineGlobal } from 'react-icons/ai';
import { FaBookAtlas } from 'react-icons/fa6';
import BookDetailActionPanel from '~/components/book-detail/BookDetailActionPanel';
import BreadCrumbsComponent from '~/components/common/breadcrumbs/BreadCrumbsComponent';
import GlobalBookDetailContent from '~/components/global-book-detail/GlobalBookDetailContent';
import BreadCrumbsComponent from '~/components/breadcrumbs/BreadCrumbsComponent';
import { commitSession, getSession } from '~/services/session.server';
import { ActionResponse } from '~/types/response';
import { makeCookieHeader } from '~/utils/session';
import BookDetailActionPanel from './components/GlobalBookDetailActionPanel';
import GlobalBookDetailContent from './components/GlobalBookDetailContent';

interface LoaderData {
googleBook: GoogleBook;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Card } from '@mantine/core';
import type { GoogleBook } from 'client/client.schemas';
import BookCardThumbnail from '../books/BookCardThumbnail';
import BookCardThumbnail from '~/routes/home._index/components/BookCardThumbnail';

interface GlobalBookCardProps {
book: GoogleBook;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ScrollArea, SimpleGrid } from '@mantine/core';
import { GoogleBook } from 'client/client.schemas';
import NoBookComponent from '../books/NoBookComponent';
import NoBookComponent from '~/routes/home._index/components/NoBookComponent';
import GlobalBookCard from './GlobalBookCard';

interface GlobalBookCardsProps {
Expand All @@ -23,7 +23,7 @@ const GlobalBookCards = ({ books }: GlobalBookCardsProps) => {
'1400px': 6,
'1700px': 7,
}}
// 画面幅が300pxを超えた場合、カードの間をxlにする
// 画面幅が300pxを超えたらカードの間をxlにする
spacing={{ base: 10, '300px': 'xl' }}
>
{books.map((book) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Collapse } from '@mantine/core';
import type { UseFormReturnType } from '@mantine/form';
import type { SearchGoogleBooksParams } from 'client/client.schemas';
import FormLayout from '../layouts/FormLayout';
import GlobalBookSearchAuthorForm from './GLobalBookSearchAuthorForm';
import GlobalBookSearchIsbnForm from './GlobalBookSearchIsbnForm';
import GlobalBookSearchPublisherForm from './GlobalBookSearchPublisherForm';
import GlobalBookSearchSubmitButton from './GlobalBookSearchSubmitButton';
import GlobalBookSearchTitleForm from './GlobalBookSearchTitleForm';
import GlobalSearchSegment from './GlobalSearchSegment';
import FormLayout from '~/components/layouts/FormLayout';
import GlobalBookSearchAuthorForm from './search-form/GLobalBookSearchAuthorForm';
import GlobalBookSearchIsbnForm from './search-form/GlobalBookSearchIsbnForm';
import GlobalBookSearchPublisherForm from './search-form/GlobalBookSearchPublisherForm';
import GlobalBookSearchSubmitButton from './search-form/GlobalBookSearchSubmitButton';
import GlobalBookSearchTitleForm from './search-form/GlobalBookSearchTitleForm';
import GlobalSearchSegment from './search-form/GlobalSearchSegment';

interface GlobalDetailSearchFormProps {
isOpen: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Collapse, Space } from '@mantine/core';
import type { UseFormReturnType } from '@mantine/form';
import type { SearchGoogleBooksParams } from 'client/client.schemas';
import FormLayout from '../layouts/FormLayout';
import GlobalBookSearchKeywordForm from './GlobalBookSearchKeywordForm';
import GlobalBookSearchSubmitButton from './GlobalBookSearchSubmitButton';
import GlobalSearchSegment from './GlobalSearchSegment';
import FormLayout from '~/components/layouts/FormLayout';
import GlobalBookSearchKeywordForm from './search-form/GlobalBookSearchKeywordForm';
import GlobalBookSearchSubmitButton from './search-form/GlobalBookSearchSubmitButton';
import GlobalSearchSegment from './search-form/GlobalSearchSegment';

interface GlobalKeywordSearchFormProps {
isOpen: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import type { searchGoogleBooksResponse } from 'client/client';
import type { SearchGoogleBooksParams } from 'client/client.schemas';
import React from 'react';
import { AiOutlineGlobal } from 'react-icons/ai';
import BreadCrumbsComponent from '~/components/breadcrumbs/BreadCrumbsComponent';
import ErrorComponent from '~/components/error/ErrorComponent';
import ContentsHeader from '~/components/pagination/ContentsHeader';
import PaginationComponent from '~/components/pagination/PaginationComponent';
import { PaginationProps } from '~/types/pagination';
import BreadCrumbsComponent from '../common/breadcrumbs/BreadCrumbsComponent';
import ErrorComponent from '../common/error/ErrorComponent';
import ContentsHeader from '../common/pagination/ContentsHeader';
import PaginationComponent from '../common/pagination/PaginationComponent';
import GlobalBookCards from './GlobalBookCards';
import GlobalBookSearchComponent from './GlobalBookSearchComponent';
import NoQueryComponent from './NoQueryComponent';
import GlobalBookSearchComponent from './search-form/GlobalBookSearchComponent';

export interface HandleGlobalSearchFunctions {
handleDetailSubmit: (props: SearchGoogleBooksParams) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { UseFormReturnType } from '@mantine/form';
import type { SearchGoogleBooksParams } from 'client/client.schemas';
import React from 'react';
import GlobalBookDetailSearchForm from './GlobalBookDetailSearchForm';
import GlobalBookKeywordSearchForm from './GlobalBookKeywordSearchForm';
import { HandleGlobalSearchFunctions } from './GlobalBookListComponent';
import GlobalBookDetailSearchForm from '../GlobalBookDetailSearchForm';
import GlobalBookKeywordSearchForm from '../GlobalBookKeywordSearchForm';
import { HandleGlobalSearchFunctions } from '../GlobalBookListComponent';
import GlobalBookSearchModeButton from './GlobalBookSearchModeButton';

interface GlobalBookSearchComponentProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { UseFormReturnType } from '@mantine/form';
import { useDisclosure } from '@mantine/hooks';
import type { SearchGoogleBooksParams } from 'client/client.schemas';
import { MdCameraAlt } from 'react-icons/md';
import IsbnScanModal from '../common/isbn-scan-modal/IsbnScanModal';
import IsbnScanModal from '~/components/isbn-scan-modal/IsbnScanModal';

interface GlobalSearchIsbnFormProps {
form: UseFormReturnType<
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/routes/home.global._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useLoaderData, useNavigate } from '@remix-run/react';
import { searchGoogleBooks, searchGoogleBooksResponse } from 'client/client';
import { SearchGoogleBooksParams } from 'client/client.schemas';
import { useEffect, useState } from 'react';
import GlobalBookListComponent from '~/components/global-books/GlobalBookListComponent';
import GlobalBookListComponent from './components/GlobalBookListComponent';

interface LoaderData {
booksResponse?: searchGoogleBooksResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Card } from '@mantine/core';
import BookCardThumbnail from '~/routes/home._index/components/BookCardThumbnail';
import { CartProps } from '~/stores/cartAtom';
import BookCardThumbnail from '../books/BookCardThumbnail';
import LoanCardHeader from './LoanCardHeader';

interface LoanCardProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Checkbox, Group } from '@mantine/core';
import { useAtom } from 'jotai';
import CartCardNumberInput from '~/routes/home.cart/components/CartCardNumberInput';
import type { CartProps } from '~/stores/cartAtom';
import { displayLoanAtom, selectedLoanAtom } from '~/stores/loanAtom';
import CartCardNumberInput from '../cart/CartCardNumberInput';

interface LoanCardHeaderProps {
id: number;
Expand Down
Loading
Loading