diff --git a/src/api/zip.api.ts b/src/api/zip.api.ts
index d678efa..e2e113c 100644
--- a/src/api/zip.api.ts
+++ b/src/api/zip.api.ts
@@ -50,9 +50,9 @@ export const likeZip = async (bookstoreId: number) => {
};
// 서점 상세 정보
-export const getZipDetail = async (bookstoreId: number, type: string) => {
+export const getZipDetail = async (bookstoreId: number, type: string, sortFiled: string) => {
try {
- const response = await instance.get(`api/bookstores/${bookstoreId}/details?type=${type}`);
+ const response = await instance.get(`api/bookstores/${bookstoreId}/details?type=${type}&sortFiled?=${sortFiled}`);
if (response.status == 200) {
return response.data;
}
@@ -82,3 +82,15 @@ export const postBookstoreReview = async (review_img: File, review: postReview)
console.log(error);
}
};
+
+// 인기 급상승 독립 서점
+export const getTrendZip = async () => {
+ try {
+ const response = await instance.get('/api/bookstores/trending');
+ if (response.status === 200) {
+ return response.data;
+ }
+ } catch (err) {
+ console.log(err);
+ }
+};
diff --git a/src/components/Home/Ranking.tsx b/src/components/Home/Ranking.tsx
index 43f84f8..87a4775 100644
--- a/src/components/Home/Ranking.tsx
+++ b/src/components/Home/Ranking.tsx
@@ -1,5 +1,8 @@
+import { useEffect, useState } from 'react';
+import { getTrendZip } from '../../api/zip.api';
+
const Ranking = () => {
- const name = [
+ const [bookstores, setBookstores] = useState([
'게으른 정원',
'고요서사',
'스토리지북앤필름',
@@ -10,10 +13,16 @@ const Ranking = () => {
'책방서로',
'북소리서점',
'책밥서점',
- ];
+ ]);
+
+ useEffect(() => {
+ getTrendZip().then((data) => {
+ setBookstores(data.data);
+ });
+ }, []);
- const left = name.slice(0, 5);
- const right = name.slice(5, 10);
+ const left = bookstores.slice(0, 5);
+ const right = bookstores.slice(5, 10);
return (
diff --git a/src/components/Zip/ZipInfo.tsx b/src/components/Zip/ZipInfo.tsx
index f6ca533..bb822e7 100644
--- a/src/components/Zip/ZipInfo.tsx
+++ b/src/components/Zip/ZipInfo.tsx
@@ -80,7 +80,7 @@ const ZipInfo = ({ bookstoreInfo }: ZipInfoProps) => {
-
12
+
{bookstoreInfo.likedCount}
{bookstoreInfo.description}
diff --git a/src/components/Zip/ZipReview.tsx b/src/components/Zip/ZipReview.tsx
index 44911de..e7b72bf 100644
--- a/src/components/Zip/ZipReview.tsx
+++ b/src/components/Zip/ZipReview.tsx
@@ -19,7 +19,7 @@ const ZipReview = ({ review }: ZipReviewProps) => {
{/* 별점 */}
{/* 사진 및 리뷰 */}
diff --git a/src/model/zip.model.ts b/src/model/zip.model.ts
index 45e9f15..7197278 100644
--- a/src/model/zip.model.ts
+++ b/src/model/zip.model.ts
@@ -23,6 +23,7 @@ export interface zipPreview {
name: string;
phone: string;
rating: number;
+ likedCount: number;
}
// 리뷰 받아올 때
diff --git a/src/pages/Zip/ZipDetail.tsx b/src/pages/Zip/ZipDetail.tsx
index 63d30f3..a8d86e8 100644
--- a/src/pages/Zip/ZipDetail.tsx
+++ b/src/pages/Zip/ZipDetail.tsx
@@ -11,6 +11,7 @@ import { getZipDetail } from '../../api/zip.api';
import { bookstoreReview, zipPreview } from '../../model/zip.model';
import NoBookStoreResult from '../../components/Zip/NoBookStoreResult';
import { BookDetailInfo } from '../../model/booksnap.model';
+import { set } from 'lodash';
interface ZipDetailProps {
currentState: string;
@@ -26,6 +27,7 @@ const ZipDetail = ({ currentState, id }: ZipDetailProps) => {
const [reviewList, setReviewList] = useState([]);
const [bookList, setBookList] = useState([]);
const [filteredBookList, setFilteredBookList] = useState([]);
+ const [filter, setFilter] = useState<'createdAt' | 'rating'>('createdAt');
const handleWriteReview = () => {
// setBottomSheet(({ currentState }) => , '서점 상세 정보');
@@ -33,11 +35,11 @@ const ZipDetail = ({ currentState, id }: ZipDetailProps) => {
};
useEffect(() => {
- getZipDetail(id, 'reviews').then((data) => {
+ getZipDetail(id, 'reviews', filter).then((data) => {
setBookstoreInfo(data.data.bookstoreDetail);
setReviewList(data.data.reviewList);
});
- }, []);
+ }, [filter]);
const handleFilterChange = (selected: string) => {
console.log(selected);
@@ -46,7 +48,7 @@ const ZipDetail = ({ currentState, id }: ZipDetailProps) => {
useEffect(() => {
const detail = type === '리뷰' ? 'reviews' : 'books';
- getZipDetail(id, detail).then((data) => {
+ getZipDetail(id, detail, filter).then((data) => {
setBookstoreInfo(data.data.bookstoreDetail);
if (data.data.reviewList) {
setReviewList(data.data.reviewList);
@@ -82,8 +84,15 @@ const ZipDetail = ({ currentState, id }: ZipDetailProps) => {
-
• 최신 순
-
• 별점 순
+
setFilter('createdAt')}
+ >
+ • 최신 순
+
+
setFilter('rating')}>
+ • 별점 순
+