Skip to content

Commit

Permalink
HOTFIX: 각종 minor 에러 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
oooppq committed Sep 4, 2023
1 parent c8b0d29 commit e75ffa8
Show file tree
Hide file tree
Showing 27 changed files with 272 additions and 241 deletions.
10 changes: 10 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useEffect } from 'react';
import { Routes, Route } from 'react-router-dom';
import { useQueryClient } from 'react-query';
import { useSelector } from 'react-redux';
import Header from './components/Header';
import Footer from './components/Footer';
import Nav from './components/Nav';
Expand All @@ -24,8 +26,16 @@ import ParticipatingRestaurant from './pages/MyPage/ParticipatingRestaurant/Part

const App = () => {
const { login, refresh, handleAuthState } = useAuth();
const authState = useSelector((state) => state.userAuth.state);
const queryClient = useQueryClient();
queryClient.setDefaultOptions({
queries: {
enabled: authState !== 'initial' && authState !== 'pending',
},
});

useEffect(handleAuthState);

return (
<>
<Header />
Expand Down
22 changes: 7 additions & 15 deletions src/libs/common.helpers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ export const useWish = (id, _isWish) => {
const { authInfo, isAuthorized } = useAuth();
const queryClient = useQueryClient();
const [isWish, setIsWish] = useState(_isWish);
// const { data: isWishRes } = (id &&
// useQuery(
// ['get', 'wishIsLike', id],
// () =>
// axios
// .get(url, {
// headers: {
// Authorization: `${authInfo && authInfo.accessToken}`,
// },
// })
// .then((res) => res.data),
// { refetchOnWindowFocus: false }
// )) || { data: false };

const { mutate: pushWish } = useMutation(
['push', 'isLike'],
Expand All @@ -43,7 +30,12 @@ export const useWish = (id, _isWish) => {
Authorization: `${authInfo && authInfo.accessToken}`,
},
}),
{ onSuccess: () => queryClient.invalidateQueries(['wishList']) }
{
onSuccess: () => {
queryClient.invalidateQueries(['wishList']);
queryClient.invalidateQueries(['restaurant', String(id)]);
},
}
);

// const isWish = isAuthorized() && isWishRes;
Expand Down Expand Up @@ -191,7 +183,7 @@ export const useShare = (restaurant) => {
templateArgs: {
imgUrl: restaurant.imageUrl,
title: restaurant.restaurantName,
rating: restaurant.rating,
rating: Number(restaurant.rating).toFixed(1),
reviewCount: restaurant.reviewCount,
tags: `#${restaurant.foodCategory} #${restaurant.locationCategory} #${restaurant.locationTag}`,
btnTitle: "'점메추'에서 자세히 보기",
Expand Down
7 changes: 4 additions & 3 deletions src/pages/Detail/Detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ const Detail = () => {
isNewMenuModalOpen,
setIsNewMenuModalOpen,
restaurant,
isRestaurantLoading,
restaurantError,
// isRestaurantLoading,
// restaurantError,
restaurantStatus,
menus,
// isMenusLoading,
// menusError,
Expand All @@ -27,7 +28,7 @@ const Detail = () => {
openNewMenuModal,
} = useDetail(id);

if (isRestaurantLoading || restaurantError) return null;
if (restaurantStatus !== 'success') return null;

return (
<DetailContainer>
Expand Down
84 changes: 44 additions & 40 deletions src/pages/Detail/DetailInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ const DetailInfo = ({
{restaurantData.locationCategory} {'>'} {restaurantData.locationTag}
</div>
</div>
{restaurantData.recommendCategoryList.length > 0 && (
<div
className="info"
onClick={() => {
setIsMore((state) => !state);
}}
>
<div className="key">추천 태그</div>
<div className="value">
<div className="recom">
<div
className="info"
onClick={() => {
setIsMore((state) => !state);
}}
>
<div className="key">추천 태그</div>
<div className="value">
<div className="recom">
{restaurantData.recommendCategoryList.length > 0 ? (
<div
className="recomTag"
style={{
Expand All @@ -74,47 +74,51 @@ const DetailInfo = ({
</span>
{restaurantData.recommendCategoryList[0].name}
</div>
) : (
<div className="">추천 태그를 추가해주세요.</div>
)}
{restaurantData.recommendCategoryList.length > 1 && (
<button type="button" className="etc">
<span className="">
{restaurantData.recommendCategoryList.length - 1}
</span>
{/* <img src={detailIcon} alt="" className="" /> */}
<span className="moreBtn">{isMore ? '▲' : '▼'}</span>
</button>
</div>
{isMore &&
restaurantData.recommendCategoryList.slice(1).map((tag) => (
<div
key={tag.id}
className="recomTag more"
)}
</div>
{isMore &&
restaurantData.recommendCategoryList.slice(1).map((tag) => (
<div
key={tag.id}
className="recomTag more"
style={{
borderColor: tag.color,
}}
>
<span
className="hash"
style={{
borderColor: tag.color,
color: tag.color,
}}
>
<span
className="hash"
style={{
color: tag.color,
}}
>
#
</span>{' '}
{tag.name}
</div>
))}
</div>
<button
type="button"
className="recomTagChangeBtn"
onClick={(e) => {
openRecomTagModal();
e.stopPropagation();
}}
>
<img src={pencilIcon} alt="" className="" />
</button>
#
</span>{' '}
{tag.name}
</div>
))}
</div>
)}
<button
type="button"
className="recomTagChangeBtn"
onClick={(e) => {
openRecomTagModal();
e.stopPropagation();
}}
>
<img src={pencilIcon} alt="" className="" />
</button>
</div>
</div>
{isRecomTagOpen && (
<RecommendTagFetchModal
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Detail/DetailMenuElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ const DetailMenuElement = ({ menu, useMenuElem }) => {
menu={menu}
/>
)}
{isMenuSaleInfoModalOpen && menu.saleComment && (
{isMenuSaleInfoModalOpen && menu.saleExplain && (
<DetailMenuSaleInfoModal
saleComment={menu.saleComment}
saleExplain={menu.saleExplain}
closeMenuSaleInfoModal={() => {
setIsMenuSaleInfoModalOpen(false);
}}
Expand All @@ -67,7 +67,7 @@ const DetailMenuElement = ({ menu, useMenuElem }) => {
}}
>
<img src={cameraIcon} alt="" className="" />
{menu.photoNum}
<div className="imageCount">{menu.imageCount}</div>
</button>

{menu.salePrice ? (
Expand Down
10 changes: 5 additions & 5 deletions src/pages/Detail/DetailMenuFetchModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DetailMenuFetchModal = ({
price,
setPrice,
setSalePrice,
setSaleComment,
setSaleExplain,
isWarning,
isMenuDeleteModalOpen,
setIsMenuDeleteModalOpen,
Expand All @@ -31,9 +31,9 @@ const DetailMenuFetchModal = ({
setName(menu.name);
setPrice(menu.price);
setSalePrice(menu.salePrice);
setSaleComment(menu.saleComment);
setSaleExplain(menu.saleExplain);
}
}, [menu, setName, setPrice, setSaleComment, setSalePrice]);
}, [menu, setName, setPrice, setSaleExplain, setSalePrice]);

return (
<DetailMenuUpdateModalContainer>
Expand Down Expand Up @@ -146,10 +146,10 @@ const DetailMenuFetchModal = ({
<textarea
placeholder="예)학생증을 보여주면 1,000원을 할인해줘요."
className="updateInput saleComment"
defaultValue={menu && menu.saleComment}
defaultValue={menu && menu.saleExplain}
maxLength={200}
onChange={(e) => {
setSaleComment(e.target.value);
setSaleExplain(e.target.value);
}}
/>
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/Detail/DetailMenuPhotoInnerModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ const DetailMenuPhotoInnerModal = ({
{/* <div className="fileName">{selectedPhoto.originalName}</div> */}
<div className="photoInfo">
<div className="userName">
photo by{' '}
<span className="bold">{selectedPhoto.member.nickname}</span>
photo by <span className="bold">{selectedPhoto.nickname}</span>
</div>
{selectedPhoto.member.id === userId && (
{selectedPhoto.userId === userId && (
<button
type="button"
className="deleteBtn"
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Detail/DetailMenuPhotoModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const DetailMenuPhotoModal = ({ closeMenuPhotoModal, menu }) => {
</button>
<div className="menuPhotoModalTop">
<div className="menuPhotoModalTitle">{menu.name}</div>
{menu.photoNum && (
<div className="menuModalPhotoPhotoNum">[{menu.photoNum}]</div>
{menu.imageCount && (
<div className="menuModalPhotoPhotoNum">[{menu.imageCount}]</div>
)}
{/* <button type="button" className="changeThumbBtn">
대표 이미지 설정
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Detail/DetailMenuSaleInfoModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { DetailMenuSaleInfoModalContainer } from './detail.style';
import xIcon from '../../assets/img/x-icon.svg';

const DetailMenuSaleInfoModal = ({ saleComment, closeMenuSaleInfoModal }) => {
const DetailMenuSaleInfoModal = ({ saleExplain, closeMenuSaleInfoModal }) => {
return (
<DetailMenuSaleInfoModalContainer>
<div className="modalInner">
Expand All @@ -15,7 +15,7 @@ const DetailMenuSaleInfoModal = ({ saleComment, closeMenuSaleInfoModal }) => {
<img src={xIcon} alt="" />
</button>
<div className="saleCommentTitle">세일 설명</div>
<div className="saleComment">{saleComment}</div>
<div className="saleComment">{saleExplain}</div>
</div>
</DetailMenuSaleInfoModalContainer>
);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Detail/DetailReviewElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const DetailReviewElement = ({ restaurantId, review }) => {
pushLike,
isAuthor,
isLike,
likeCount,
} = useReviewElem(restaurantId, review);

const navigate = useNavigate();
Expand Down Expand Up @@ -94,7 +95,7 @@ const DetailReviewElement = ({ restaurantId, review }) => {
}}
>
<img className="likeImg" alt="" />
<span className="likeNum">{handleLikeNum(review.likeCount)}</span>
<span className="likeNum">{handleLikeNum(likeCount)}</span>
</button>
<div className="date">{review.createdDate}</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Detail/DetailTop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const DetailTop = ({ restaurant, tab, changeTab }) => {
restaurant && restaurant.id,
restaurant.liked
);

const { isShareModalOpen, ShareModalBtn, ShareModal } = useShare(restaurant);

return (
Expand Down Expand Up @@ -55,10 +56,10 @@ const DetailTop = ({ restaurant, tab, changeTab }) => {
</div>
<div className="wishDiv">
<img src={smallHeartIcon} alt="" />
<span>{restaurant.wishCount}</span>
<span>{restaurant.likeCount}</span>
</div>
</div>
<div className="rate">{restaurant.rating}</div>
<div className="rate">{Number(restaurant.rating).toFixed(1)}</div>
<div className="bestReview">"{restaurant.bestReview}"</div>
</div>

Expand Down
14 changes: 11 additions & 3 deletions src/pages/Detail/RecommendTagFetchModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable react/prop-types */
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { useMutation, useQuery } from 'react-query';
import { useMutation, useQuery, useQueryClient } from 'react-query';
import axios from 'axios';
import { RecomTagModalContainer } from './detail.style';
import xIcon from '../../assets/img/x-icon.svg';
Expand All @@ -14,6 +14,7 @@ const RecommendTagFetchModal = ({ closeModal, restId, recommendTag }) => {
const [tags, setTags] = useState([]);
const recommendTagIds = recommendTag.map((tag) => tag.id);
const accessToken = useSelector((state) => state.userAuth.accessToken);
const queryClient = useQueryClient();

const { data: recommendTags } = useQuery(
'recommend-category',
Expand All @@ -26,7 +27,9 @@ const RecommendTagFetchModal = ({ closeModal, restId, recommendTag }) => {
}
return res.data;
}),
{ refetchOnWindowFocus: false }
{
refetchOnWindowFocus: false,
}
);

const { mutate: updateRecommendTag, status } = useMutation(
Expand All @@ -42,7 +45,12 @@ const RecommendTagFetchModal = ({ closeModal, restId, recommendTag }) => {
Authorization: `${accessToken}`,
},
}
)
),
{
onSuccess: () => {
queryClient.invalidateQueries(['restaurant', String(restId)]);
},
}
);

useEffect(() => {
Expand Down
Loading

0 comments on commit e75ffa8

Please sign in to comment.