diff --git a/src/assets/svg.js b/src/assets/svg.js
index d925661..c908643 100644
--- a/src/assets/svg.js
+++ b/src/assets/svg.js
@@ -144,7 +144,7 @@ export const svgXml = {
starEmpty: `
+
`,
shop: `
`,
+ thumbupOn: `
+
+ `,
+ thumbupOff: `
+
+ `,
},
};
diff --git a/src/screens/detail/StoreDetailScreen.js b/src/screens/detail/StoreDetailScreen.js
index 899b79a..db4fdaf 100644
--- a/src/screens/detail/StoreDetailScreen.js
+++ b/src/screens/detail/StoreDetailScreen.js
@@ -96,7 +96,7 @@ export default function StoreDetailScreen(props) {
const data = response.data.data;
const dataReview = responseReview.data.data;
- console.log('Restaurant heart:', data.restaurant);
+ console.log('storedata: ', data);
setRestaurant(data);
setIsHearted(data.restaurant.isLike);
@@ -139,6 +139,38 @@ export default function StoreDetailScreen(props) {
Alert.alert('클립보드에 복사되었습니다.');
}
+ const handleReviewLikedState = async (review) => {
+ try {
+ const newReviewLikedState = !review.item.isLike;
+ const updatedReviewList = reviewList.map((item) =>
+ item.id === review.item.id
+ ? { ...item, isLike: newReviewLikedState, likeCount: newReviewLikedState ? item.likeCount + 1 : item.likeCount - 1 }
+ : item
+ );
+ setReviewList(updatedReviewList);
+ const ret = await axios.post(
+ `${API_URL}/v1/restaurants/reviews/${review.item.id}/like`,
+ {
+ isLike: newReviewLikedState,
+ },
+ {
+ headers: {Authorization: `Bearer ${context.accessToken}`},
+ },
+ );
+
+ console.log('isReviewLike: ', ret.data);
+ } catch (error) {
+ console.error('Error updating review liked:', error);
+
+ const rollbackReviewList = reviewList.map((item) =>
+ item.id === review.item.id
+ ? { ...item, isLike: review.item.isLike, likeCount: review.item.likeCount }
+ : item
+ );
+ setReviewList(rollbackReviewList);
+ }
+ }
+
const handleLoadMoreMenus = () => {
setMenuCount(menuCount + 4);
};
@@ -154,35 +186,24 @@ export default function StoreDetailScreen(props) {
const renderMenuItem = ({item}) => (
<>
- {item.imageUrl ? (
- <>
-
-
- >
- ) : (
-
-
- 음식 사진 준비중
-
+
+
- )}
+
{item.name}
{item.description}
@@ -196,7 +217,8 @@ export default function StoreDetailScreen(props) {
const renderReviewItem = ({item}) => {
const rating = item.rating;
const likeCount = item.likeCount;
- const viewCount = item.viewCount;
+
+ console.log("review: ", item);
const renderStars = () => {
const stars = [];
@@ -236,30 +258,47 @@ export default function StoreDetailScreen(props) {
)}
{item.username}
님
+ handleReviewLikedState({item})}>
+
+
{`좋아요 ${likeCount}`}
{renderStars()}
- {item.content}
+
+
+ {item.imageUrls.length > 0 ? (
+ <>
+ {item.content}
+ (
+
+ )}
+ keyExtractor={(image, index) => `${item.id}-${index}`}
+ />
+ >
+ ) : (
+ <>
+ {item.content}
+ >
+ )}
+
+
- (
-
- )}
- keyExtractor={(image, index) => `${item.id}-${index}`}
- />
>
);
@@ -269,24 +308,24 @@ export default function StoreDetailScreen(props) {
<>
-
-
+
+
@@ -378,12 +417,14 @@ export default function StoreDetailScreen(props) {
width={24}
height={24}
/>
-
- 위치: {restaurant.restaurant.detailInfo.address}
-
- {onCopy(restaurant.restaurant.detailInfo.address)}}>
- 복사
-
+
+
+ 위치: {restaurant.restaurant.detailInfo.address}
+
+ {onCopy(restaurant.restaurant.detailInfo.address)}}>
+ 복사
+
+