From 7361e209e8a34a5acee2f03f50e842b8cb56dd2a Mon Sep 17 00:00:00 2001 From: yongaricode Date: Sat, 10 May 2025 12:32:34 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EC=9D=B8=EA=B8=B0=20=EA=B8=89?= =?UTF-8?q?=EC=83=81=EC=8A=B9=20=EC=84=9C=EC=A0=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/zip.api.ts | 12 ++++++++++++ src/components/Home/Ranking.tsx | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/api/zip.api.ts b/src/api/zip.api.ts index d678efa..999f62e 100644 --- a/src/api/zip.api.ts +++ b/src/api/zip.api.ts @@ -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..f37903b 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 (
From e25ace6059bed3ac1962e0f4fdce54bd5066f952 Mon Sep 17 00:00:00 2001 From: yongaricode Date: Sat, 10 May 2025 12:35:06 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=EC=84=9C=EC=A0=90=20=EC=B0=9C?= =?UTF-8?q?=EA=B0=9C=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Zip/ZipInfo.tsx | 2 +- src/model/zip.model.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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/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; } // 리뷰 받아올 때 From 3c60947a70e609d1ebc98c9bfde5a685cbd6b6ba Mon Sep 17 00:00:00 2001 From: yongaricode Date: Sat, 10 May 2025 12:46:39 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=EC=84=9C=EC=A0=90=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B3=84=EC=A0=90=EC=88=9C/=EC=B5=9C=EC=8B=A0?= =?UTF-8?q?=EC=88=9C=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/zip.api.ts | 4 ++-- src/components/Home/Ranking.tsx | 2 +- src/components/Zip/ZipReview.tsx | 2 +- src/pages/Zip/ZipDetail.tsx | 19 ++++++++++++++----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/api/zip.api.ts b/src/api/zip.api.ts index 999f62e..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; } diff --git a/src/components/Home/Ranking.tsx b/src/components/Home/Ranking.tsx index f37903b..87a4775 100644 --- a/src/components/Home/Ranking.tsx +++ b/src/components/Home/Ranking.tsx @@ -19,7 +19,7 @@ const Ranking = () => { getTrendZip().then((data) => { setBookstores(data.data); }); - }); + }, []); const left = bookstores.slice(0, 5); const right = bookstores.slice(5, 10); 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) => { {/* 별점 */}
-

4

+

{review.rating}

{/* 사진 및 리뷰 */} 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')}> + • 별점 순 +