From 81827445c046bc327de071c76dda356c0d9a3d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B4=80=EC=8B=9D?= <39869096+gwansikk@users.noreply.github.com> Date: Fri, 26 Apr 2024 22:59:53 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat(member):=20=EC=B1=85=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=98=A8=EB=9D=BC=EC=9D=B8=20=EC=84=9C=EC=A0=90=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?(#112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookDetailSection/BookDetailSection.tsx | 42 ++++++++++++---- .../BookLoanHistorySection.tsx | 19 ++++--- apps/member/src/constants/path.ts | 17 ++++++- apps/member/src/types/book.ts | 7 ++- apps/member/src/utils/string.ts | 49 ++++++++++++++++++- 5 files changed, 110 insertions(+), 24 deletions(-) diff --git a/apps/member/src/components/library/BookDetailSection/BookDetailSection.tsx b/apps/member/src/components/library/BookDetailSection/BookDetailSection.tsx index 2e9e3e79..5afd8eed 100644 --- a/apps/member/src/components/library/BookDetailSection/BookDetailSection.tsx +++ b/apps/member/src/components/library/BookDetailSection/BookDetailSection.tsx @@ -5,17 +5,19 @@ import { Badge, Button, DetailsList, Grid, Tabs } from '@clab/design-system'; import Image from '@components/common/Image/Image'; import Section from '@components/common/Section/Section'; +import { BOOK_STORE_URL } from '@constants/path'; import { SELECT_DEFAULT_OPTION } from '@constants/select'; import { BOOK_STATE } from '@constants/state'; import { useBookLoanBorrowMutation } from '@hooks/queries/useBookLoanBorrowMutation'; import { useMyProfile } from '@hooks/queries/useMyProfile'; import { createImageUrl } from '@utils/api'; +import { bookReviewParser, toBookstore } from '@utils/string'; import yes24Icon from '@assets/svg/yes24.svg'; import aladinIcon from '@assets/webp/aladin.webp'; import kyoboIcon from '@assets/webp/kyobobook.webp'; -import type { BookItem } from '@type/book'; +import type { BookItem, BookstoreKorean } from '@type/book'; interface BookDetailSectionProps { data: BookItem; @@ -31,7 +33,7 @@ const options = [ value: '예스24', }, { - icon: 알라딘, + icon: 알라딘, value: '알라딘', }, ] as const; @@ -39,7 +41,16 @@ const options = [ const BookDetailSection = ({ data }: BookDetailSectionProps) => { const { data: myInfo } = useMyProfile(); const { bookBorrowMutate } = useBookLoanBorrowMutation(); - const { id, borrowerId, category, title, author, publisher, imageUrl } = data; + const { + id, + borrowerId, + category, + title, + author, + publisher, + imageUrl, + reviewLinks, + } = data; const handleBorrowClick = useCallback( (bookId: number) => { @@ -50,6 +61,17 @@ const BookDetailSection = ({ data }: BookDetailSectionProps) => { }, [bookBorrowMutate, myInfo.id], ); + /** + * 온라인 서점에서 책의 정보를 검색하는 함수입니다. + * 서버에 저장된 온라인 서점 URL이 존재할 경우 해당 URL로 이동합니다. + * 존재하지 않을 경우, 책 제목을 검색하여 검색 결과를 보여줍니다. + */ + const handleTabsChange = (value: string) => { + const bookStore = toBookstore(value as BookstoreKorean); + const url = bookReviewParser(reviewLinks); + const targetUrl = url[bookStore] || `${BOOK_STORE_URL[bookStore]}${title}`; + window.open(targetUrl, '_blank'); + }; return (
@@ -62,7 +84,7 @@ const BookDetailSection = ({ data }: BookDetailSectionProps) => { />
-

{title}

+

{title}

{author} {publisher} @@ -73,13 +95,13 @@ const BookDetailSection = ({ data }: BookDetailSectionProps) => { - +
-