diff --git a/.github/workflows/deploy.yml b/.github/workflows/server.yml
similarity index 96%
rename from .github/workflows/deploy.yml
rename to .github/workflows/server.yml
index 47b24a4..c77241f 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/server.yml
@@ -1,4 +1,4 @@
-name: server
+name: book-store Server
on:
push:
diff --git a/client/src/components/books/Pagination.tsx b/client/src/components/books/Pagination.tsx
index 473c81e..9466745 100644
--- a/client/src/components/books/Pagination.tsx
+++ b/client/src/components/books/Pagination.tsx
@@ -1,13 +1,64 @@
+import { useSearchParams } from "react-router-dom";
import { styled } from "styled-components";
+import { Pagination as IPagination } from "../../models/pagination.model";
+import Button from "../common/Button";
+import { LIMIT } from "../constants/pagination";
+import { QUERYSTRING } from "../constants/querystring";
+
+interface Props {
+ pagination: IPagination
+}
+
+const Pagination = ({ pagination }: Props) => {
+ const [searchparams, setSearchParams] = useSearchParams()
+ const { totalCount, currentPage } = pagination || {};
+ const pages: number = Math.ceil(totalCount / LIMIT)
+
+ const handleClickPage = (page: number) => {
+ const newSearchParams = new URLSearchParams(searchparams);
+
+ newSearchParams.set(QUERYSTRING.PAGE, page.toString())
+
+ setSearchParams(newSearchParams);
+ }
-const Pagination = () => {
return (
-
-
Pagination
-
+
+ {
+ pages > 0 && (
+
+ {Array(pages)
+ .fill(0)
+ .map((_, index) => (
+ -
+
+
+ ))}
+
+ )
+ }
+
);
};
-const Paginationstyled = styled.div``;
+const PaginationStyle = styled.div`
+ display: flex;
+ justify-content: start;
+ align-items: center;
+ padding: 24px 0;
+
+ ol {
+ list-style: none;
+ display: flex;
+ gap: 8px;
+ margin: 0;
+ }
+`;
export default Pagination;
diff --git a/client/src/hooks/useBooks.ts b/client/src/hooks/useBooks.ts
index e6d284a..9c19114 100644
--- a/client/src/hooks/useBooks.ts
+++ b/client/src/hooks/useBooks.ts
@@ -15,7 +15,7 @@ export const useBooks = () => {
currentPage: 1,
})
- const [ isEmpty, setIsEmpry] = useState(true)
+ const [isEmpty, setIsEmpty] = useState(true)
useEffect(() => {
const params = new URLSearchParams(location.search)
@@ -28,7 +28,7 @@ export const useBooks = () => {
}).then((res) => {
setBooks(res.books);
setPagination(res.pagination)
- setIsEmpry(res.books.length === 0)
+ setIsEmpty(res.books.length === 0)
})
}, [location.search])
diff --git a/client/src/pages/Books.tsx b/client/src/pages/Books.tsx
index 8648abd..664d8ed 100644
--- a/client/src/pages/Books.tsx
+++ b/client/src/pages/Books.tsx
@@ -2,6 +2,7 @@ import styled from "styled-components";
import BooksEmpty from "../components/books/BooksEmpty";
import BooksFilter from "../components/books/BooksFilter";
import BooksList from "../components/books/BooksList";
+import BooksViewSwitcher from "../components/books/BooksViewSwitcher";
import Pagination from "../components/books/Pagination";
import Title from "../components/common/Title";
import { useBooks } from "../hooks/useBooks";
@@ -14,14 +15,27 @@ const Books = () => {
도서 검색 결과
+
{!isEmpty && }
{isEmpty && }
- {!isEmpty && }
+ {!isEmpty && }
>
);
};
-const BooksStyled = styled.div``;
+const BooksStyled = styled.div`
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ gap: 24px;
+
+ .filter {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 20px 0;
+ }
+`;
export default Books;