Skip to content

Commit

Permalink
add: book edit page breadcrumbs list
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosei805 committed Nov 23, 2024
1 parent 3b96f55 commit 7d19ce2
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions frontend/app/routes/home.books.$bookId/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
LoaderFunctionArgs,
} from '@remix-run/cloudflare';
import { json, redirect } from '@remix-run/cloudflare';
import { Outlet, useLoaderData } from '@remix-run/react';
import { Outlet, useLoaderData, useLocation } from '@remix-run/react';
import type { getBookResponse, getLoansResponse } from 'client/client';
import { deleteBook, getBook, getLoans } from 'client/client';
import { commitSession, getSession } from '~/services/session.server';
Expand Down Expand Up @@ -119,6 +119,7 @@ export const action = async ({ request }: ActionFunctionArgs) => {

const BookDetail = () => {
const { bookResponse, loansResponse } = useLoaderData<typeof loader>();
const location = useLocation();
switch (bookResponse.status) {
case 400:
return <ErrorComponent message="リクエストが不正です" />;
Expand All @@ -130,13 +131,27 @@ const BookDetail = () => {
return (
<Stack bg="var(--mantine-color-body)" align="stretch" justify="flex-start">
<BreadCrumbsComponent
anchors={[
{ title: '蔵書一覧', href: '/home' },
{
title: bookResponse.data.title,
href: `/home/books/${bookResponse.data.id}`,
},
]}
anchors={
location.pathname.includes('/edit')
? [
{ title: '蔵書一覧', href: '/home' },
{
title: bookResponse.data.title,
href: `/home/books/${bookResponse.data.id}`,
},
{
title: '書籍情報編集',
href: `/home/books/${bookResponse.data.id}/edit`,
},
]
: [
{ title: '蔵書一覧', href: '/home' },
{
title: bookResponse.data.title,
href: `/home/books/${bookResponse.data.id}`,
},
]
}
/>
<Grid gutter={rem(50)}>
<Grid.Col span={3}>
Expand Down

0 comments on commit 7d19ce2

Please sign in to comment.