+
{title}
{author} | {publisher}
diff --git a/apps/member/src/components/my/MyHistorySection/MyHistorySection.tsx b/apps/member/src/components/my/MyHistorySection/MyHistorySection.tsx
index b7569ab9..242193ed 100644
--- a/apps/member/src/components/my/MyHistorySection/MyHistorySection.tsx
+++ b/apps/member/src/components/my/MyHistorySection/MyHistorySection.tsx
@@ -1,10 +1,9 @@
import { useCallback } from 'react';
-import { Badge } from '@clab/design-system';
-
import EmptyBox from '@components/common/EmptyBox/EmptyBox';
import ListButton from '@components/common/ListButton/ListButton';
import Section from '@components/common/Section/Section';
+import BookLoanConditionStatusBadge from '@components/library/BookLoanConditionStatusBadge/BookLoanConditionStatusBadge';
import { MY_MESSAGE } from '@constants/message';
import { PATH_FINDER } from '@constants/path';
@@ -67,14 +66,17 @@ const MyHistorySection = ({ title, data }: MyHistorySectionProps) => {
return (
-
- {returnedAt ? '반납완료' : '대출중'}
-
+
{bookTitle}
-
- {toYYMMDD(borrowedAt ?? '')}
-
+ {returnedAt && (
+
+ {toYYMMDD(returnedAt)}
+
+ )}
);
}
diff --git a/apps/member/src/constants/state.ts b/apps/member/src/constants/state.ts
index e637e63e..e6091583 100644
--- a/apps/member/src/constants/state.ts
+++ b/apps/member/src/constants/state.ts
@@ -1,6 +1,8 @@
export const BOOK_STATE = {
- BORROWED: '대여중',
+ WAIT: '대기',
AVAILABLE: '대여가능',
+ BORROWED: '대여중',
+ RETURN: '반납완료',
} as const;
export const DATE_FORMAT = {
diff --git a/apps/member/src/hooks/common/usePagination.ts b/apps/member/src/hooks/common/usePagination.ts
index 0a75ff2e..033e6f26 100644
--- a/apps/member/src/hooks/common/usePagination.ts
+++ b/apps/member/src/hooks/common/usePagination.ts
@@ -3,29 +3,32 @@ import { useLocation, useNavigate } from 'react-router-dom';
/**
* 페이지네이션을 위한 페이지 조작 훅입니다.
+ * Pagination Component와 같이 사용합니다.
*/
export const usePagination = (defaultSize: number = 20) => {
const navigate = useNavigate();
const location = useLocation();
- const searchParams = new URLSearchParams(location.search);
+
+ const getPage = useCallback(() => {
+ const searchParams = new URLSearchParams(location.search);
+ return parseInt(searchParams.get('page') ?? '1', 10) - 1;
+ }, [location.search]);
+
const [pagination, setPagination] = useState({
- page: parseInt(searchParams.get('page') ?? '1') - 1,
+ page: getPage(),
size: defaultSize,
});
- // 페이지 변경 핸들러
const handlePageChange = useCallback(
(page: number) => {
- navigate(`?page=${page}`, { replace: false });
+ navigate('?page=' + page);
},
[navigate],
);
useEffect(() => {
- const page = parseInt(searchParams.get('page') ?? '1', 10) - 1;
- setPagination((prev) => ({ ...prev, page }));
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [location.search]);
+ setPagination((prev) => ({ ...prev, page: getPage() }));
+ }, [getPage]);
- return { page: pagination.page, size: pagination.size, handlePageChange };
+ return { ...pagination, handlePageChange };
};
diff --git a/apps/member/src/hooks/queries/book/index.ts b/apps/member/src/hooks/queries/book/index.ts
new file mode 100644
index 00000000..9ec63b0f
--- /dev/null
+++ b/apps/member/src/hooks/queries/book/index.ts
@@ -0,0 +1,2 @@
+export * from './useBooks';
+export * from './useBookDetails';
diff --git a/apps/member/src/hooks/queries/useBookDetails.ts b/apps/member/src/hooks/queries/book/useBookDetails.ts
similarity index 100%
rename from apps/member/src/hooks/queries/useBookDetails.ts
rename to apps/member/src/hooks/queries/book/useBookDetails.ts
diff --git a/apps/member/src/hooks/queries/useBooks.ts b/apps/member/src/hooks/queries/book/useBooks.ts
similarity index 74%
rename from apps/member/src/hooks/queries/useBooks.ts
rename to apps/member/src/hooks/queries/book/useBooks.ts
index a3464c58..12f39543 100644
--- a/apps/member/src/hooks/queries/useBooks.ts
+++ b/apps/member/src/hooks/queries/book/useBooks.ts
@@ -3,9 +3,12 @@ import { useSuspenseQuery } from '@tanstack/react-query';
import { getBooks } from '@api/book';
import { QUERY_KEY } from '@constants/key';
+/**
+ * 도서 목록을 조회합니다.
+ */
export const useBooks = (page = 0, size = 6) => {
return useSuspenseQuery({
- queryKey: [QUERY_KEY.BOOK, page, size],
+ queryKey: [QUERY_KEY.BOOK, { page, size }],
queryFn: () => getBooks(page, size),
});
};
diff --git a/apps/member/src/hooks/queries/index.ts b/apps/member/src/hooks/queries/index.ts
index f8c3851c..0d7f7446 100644
--- a/apps/member/src/hooks/queries/index.ts
+++ b/apps/member/src/hooks/queries/index.ts
@@ -36,3 +36,4 @@ export * from './useScheduleDeleteMutation';
export * from './useUserInfoMutation';
export * from './useActivityGroupMemberMy';
export * from './book-loan-record';
+export * from './book';
diff --git a/apps/member/src/pages/LibraryDetailPage/LibraryDetailPage.tsx b/apps/member/src/pages/LibraryDetailPage/LibraryDetailPage.tsx
index afbb7a25..65c9aa05 100644
--- a/apps/member/src/pages/LibraryDetailPage/LibraryDetailPage.tsx
+++ b/apps/member/src/pages/LibraryDetailPage/LibraryDetailPage.tsx
@@ -7,7 +7,7 @@ import BookLoanHistorySection from '@components/library/BookLoanHistorySection/B
import { LIBRARY_MESSAGE } from '@constants/message';
import { PATH } from '@constants/path';
-import { useBookDetails } from '@hooks/queries/useBookDetails';
+import { useBookDetails } from '@hooks/queries/book';
const LibraryDetailPage = () => {
const { id } = useParams<{ id: string }>();
diff --git a/apps/member/src/pages/LibraryPage/LibraryPage.tsx b/apps/member/src/pages/LibraryPage/LibraryPage.tsx
index 527d1e3f..9205513e 100644
--- a/apps/member/src/pages/LibraryPage/LibraryPage.tsx
+++ b/apps/member/src/pages/LibraryPage/LibraryPage.tsx
@@ -1,24 +1,17 @@
+import { Suspense } from 'react';
import { useNavigate } from 'react-router-dom';
import { Button } from '@clab/design-system';
import Content from '@components/common/Content/Content';
import Header from '@components/common/Header/Header';
-import Pagination from '@components/common/Pagination/Pagination';
-import Section from '@components/common/Section/Section';
-import LibraryBookList from '@components/library/LibraryBookList/LibraryBookList';
+import LibraryBooksSection from '@components/library/LibraryBooksSection/LibraryBooksSection';
import LibraryNewBooksSection from '@components/library/LibraryNewBooksSection/LibraryNewBooksSection';
import { PATH } from '@constants/path';
-import { usePagination } from '@hooks/common/usePagination';
-import { useBooks } from '@hooks/queries/useBooks';
const LibraryPage = () => {
const navigate = useNavigate();
- const { page, size, handlePageChange } = usePagination();
-
- const { data: newBookData } = useBooks(0, 4);
- const { data: bookData } = useBooks(page, size);
return (
@@ -27,23 +20,12 @@ const LibraryPage = () => {
희망도서 신청하기
-
-
+
+
+
+
+
+
);
};