From a1793b45c9c70d0e39125a33b80e0c230d97e5d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=96=B4=EC=8A=B9=EC=A4=80?= Date: Wed, 24 Jan 2024 13:24:22 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Refactor:=20any=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/@types/detail.types.ts | 1 + src/@types/review.types.ts | 28 +++++++--- src/@types/tours.types.ts | 22 ++++++++ src/@types/trips.types.ts | 10 ++++ src/api/review.ts | 2 +- .../DetailSectionBottom/DetailReviews.tsx | 51 ++++++++++--------- .../DetailSectionBottom/ReviewItem.tsx | 25 +-------- .../DetailSectionTop/DetailToursButtons.tsx | 10 ++-- src/components/Review/CommentItem.tsx | 12 +---- src/components/Review/MyReview.tsx | 5 +- src/components/Review/Review.tsx | 4 +- src/components/Review/ReviewComments.tsx | 25 +++++---- src/components/Review/ReviewKeyword.tsx | 8 +-- src/components/Review/ReviewRating.tsx | 2 +- src/components/Trip/TripInfo.tsx | 4 +- src/components/Trip/TripParticipant.tsx | 6 ++- src/components/common/modal/Modal.tsx | 4 +- src/recoil/review.ts | 2 +- 18 files changed, 123 insertions(+), 98 deletions(-) diff --git a/src/@types/detail.types.ts b/src/@types/detail.types.ts index bfb4bca8..71827919 100644 --- a/src/@types/detail.types.ts +++ b/src/@types/detail.types.ts @@ -1,5 +1,6 @@ interface tourDetail { id: number; + contentTypeId: number; title: string; liked: boolean; fullAddress: string; diff --git a/src/@types/review.types.ts b/src/@types/review.types.ts index 851b017b..fe5fcb10 100644 --- a/src/@types/review.types.ts +++ b/src/@types/review.types.ts @@ -1,11 +1,27 @@ -interface ReviewRequest { - tourItemId: number; - rating: number; - keywords: Keyword[]; +export interface Keyword { + keywordId: number; content: string; + type: string; } -interface Keyword { - keywordId: number; +export interface CommentItemProps { + commentId: number; + authorNickname: string; + authorProfileImageUrl: string; + createdTime: string; content: string; + onClick?: () => void; + isAuthor: boolean; +} + +export interface MyReviewContent { + reviewId: number; + authorNickname: string; + authorProfileImageUrl: string; + rating: number; + createdTime: string; + content: string; + keywords: Keyword[]; + commentCount: number; + isAuthor?: boolean; } diff --git a/src/@types/tours.types.ts b/src/@types/tours.types.ts index ccd95671..11e862e7 100644 --- a/src/@types/tours.types.ts +++ b/src/@types/tours.types.ts @@ -52,3 +52,25 @@ export interface LikedListType { preferTotalCount: number; notPreferTotalCount: number; } + +export interface ReviewInfoItemProps { + reviewId: number; + authorNickname: string; + authorProfileImageUrl: string; + rating: number; + createdTime: string; + content: string; + keywords: Keyword[]; // keywordId, content, type + commentCount: number; + onClick?: () => void; + tourItemId?: number; + contentTypeId?: number; + canTextOverflow: boolean; + isAuthor?: boolean; +} + +interface Keyword { + keywordId: number; + content: string; + type: string; +} diff --git a/src/@types/trips.types.ts b/src/@types/trips.types.ts index e2ebbb0c..36f92cd8 100644 --- a/src/@types/trips.types.ts +++ b/src/@types/trips.types.ts @@ -51,3 +51,13 @@ interface AuthorityType { tripId: string; }; } +interface TripSurveySetMemberInfo { + memberId: number; + nickname: string; + thumbnail: string; +} + +interface TripMemeberInfo { + nickname: string; + profileImageUrl: string; +} diff --git a/src/api/review.ts b/src/api/review.ts index 9c5e46df..ec7f4f43 100644 --- a/src/api/review.ts +++ b/src/api/review.ts @@ -1,6 +1,6 @@ import client from './client'; import authClient from './authClient'; - +import { ReviewRequest } from '@recoil/review'; // 리뷰 관련 API // 리뷰수정 diff --git a/src/components/DetailSectionBottom/DetailReviews.tsx b/src/components/DetailSectionBottom/DetailReviews.tsx index 8d526846..bde618f1 100644 --- a/src/components/DetailSectionBottom/DetailReviews.tsx +++ b/src/components/DetailSectionBottom/DetailReviews.tsx @@ -26,12 +26,13 @@ import ToastPopUp from '@components/common/toastpopup/ToastPopUp'; import EditDelete from '@components/common/modal/children/EditDelete'; import MyAlert from '@components/common/modal/children/MyAlert'; import { alertTypeState } from '@recoil/modal'; +import { ReviewInfoItemProps } from '@/@types/tours.types'; -interface reviewProps { - reviewData: any; -} - -export default function DetailReviews({ reviewData }: reviewProps) { +export default function DetailReviews({ + reviewData, +}: { + reviewData: tourDetail; +}) { const [reviewDataLength, setReviewDataLength] = useState(0); const { title, contentTypeId } = reviewData; const params = useParams(); @@ -73,7 +74,7 @@ export default function DetailReviews({ reviewData }: reviewProps) { return
데이터를 불러오는 중 오류가 발생했습니다.
; } - const handleReviewClick = (item: any) => { + const handleReviewClick = (item: ReviewInfoItemProps) => { const reviewId = item.reviewId; navigate(`/reviewComment/${reviewId}`, { state: { item, tourItemId } }); }; @@ -155,24 +156,26 @@ export default function DetailReviews({ reviewData }: reviewProps) { { return ( - {group?.data.data.reviewInfos.content.map((item: any) => ( - handleReviewClick(item)} - tourItemId={tourItemId} - contentTypeId={contentTypeId} - canTextOverflow={true} - isAuthor={item.isAuthor} - /> - ))} + {group?.data.data.reviewInfos.content.map( + (item: ReviewInfoItemProps) => ( + handleReviewClick(item)} + tourItemId={tourItemId} + contentTypeId={contentTypeId} + canTextOverflow={true} + isAuthor={item.isAuthor} + /> + ), + )} ); } diff --git a/src/components/DetailSectionBottom/ReviewItem.tsx b/src/components/DetailSectionBottom/ReviewItem.tsx index 57a89c8c..1a2817d9 100644 --- a/src/components/DetailSectionBottom/ReviewItem.tsx +++ b/src/components/DetailSectionBottom/ReviewItem.tsx @@ -21,30 +21,9 @@ import { import { MouseEvent, useState } from 'react'; import { getEmoji } from '@utils/utils'; import { getStarFill } from '@utils/getStarFill'; +import { ReviewInfoItemProps } from '@/@types/tours.types'; -interface Keyword { - keywordId: number; - content: string; - type: string; -} - -interface ItemProps { - reviewId: number; - authorNickname: string; - authorProfileImageUrl: string; - rating: number; - createdTime: any; - content: string; - keywords: Keyword[]; // keywordId, content, type - commentCount: number; - onClick?: () => void; - tourItemId?: number; - contentTypeId?: number; - canTextOverflow: boolean; - isAuthor?: boolean; -} - -const Item: React.FC = (props: ItemProps) => { +const Item: React.FC = (props: ReviewInfoItemProps) => { const { reviewId, authorNickname, diff --git a/src/components/DetailSectionTop/DetailToursButtons.tsx b/src/components/DetailSectionTop/DetailToursButtons.tsx index 8c9e01a6..49de97fb 100644 --- a/src/components/DetailSectionTop/DetailToursButtons.tsx +++ b/src/components/DetailSectionTop/DetailToursButtons.tsx @@ -10,11 +10,11 @@ import { useNavigate, useParams } from 'react-router-dom'; import { useSetRecoilState } from 'recoil'; import { getMember } from '@api/member'; -interface reviewProps { - reviewData: any; -} - -export default function DetailTourButtons({ reviewData }: reviewProps) { +export default function DetailTourButtons({ + reviewData, +}: { + reviewData: tourDetail; +}) { const { title, contentTypeId } = reviewData; const params = useParams(); const tourItemId = Number(params.id); diff --git a/src/components/Review/CommentItem.tsx b/src/components/Review/CommentItem.tsx index 6c1b907e..9b8a8fdd 100644 --- a/src/components/Review/CommentItem.tsx +++ b/src/components/Review/CommentItem.tsx @@ -6,17 +6,9 @@ import { } from '@recoil/modal'; import { commentState, targetCommentIdState } from '@recoil/review'; import { useRecoilState, useSetRecoilState } from 'recoil'; -interface ItemProps { - commentId: number; - authorNickname: string; - authorProfileImageUrl: string; - createdTime: any; - content: string; - onClick?: () => void; - isAuthor: boolean; -} +import { CommentItemProps } from '@/@types/review.types'; -const CommentItem: React.FC = (props: ItemProps) => { +const CommentItem: React.FC = (props: CommentItemProps) => { const { commentId, authorNickname, diff --git a/src/components/Review/MyReview.tsx b/src/components/Review/MyReview.tsx index ed33f095..a34d61ce 100644 --- a/src/components/Review/MyReview.tsx +++ b/src/components/Review/MyReview.tsx @@ -22,6 +22,7 @@ import MyAlert from '@components/common/modal/children/MyAlert'; import { alertTypeState } from '@recoil/modal'; import { PenIcon } from '@components/common/icons/Icons'; import ScrollTopButton from '@components/Plan/ScrollTopButton'; +import { MyReviewContent } from '@/@types/review.types'; export default function MyReview() { const [reviewDataLength, setReviewDataLength] = useState(0); @@ -60,7 +61,7 @@ export default function MyReview() { return
데이터를 불러오는 중 오류가 발생했습니다.
; } - const handleReviewClick = (item: any) => { + const handleReviewClick = (item: MyReviewContent) => { const reviewId = item.reviewId; navigate(`/reviewComment/${reviewId}`, { state: { item } }); }; @@ -134,7 +135,7 @@ export default function MyReview() { { return ( - {group?.data.data.content.map((item: any) => { + {group?.data.data.content.map((item: MyReviewContent) => { item.isAuthor = true; return ( - {group?.data.data.comments.content.map((item: any) => ( - - ))} + {group?.data.data.comments.content.map( + (item: CommentItemProps) => ( + + ), + )} ); } diff --git a/src/components/Review/ReviewKeyword.tsx b/src/components/Review/ReviewKeyword.tsx index 1d9d7ad3..1b33a700 100644 --- a/src/components/Review/ReviewKeyword.tsx +++ b/src/components/Review/ReviewKeyword.tsx @@ -4,11 +4,7 @@ import { getReviewKeywords } from '@api/review'; import { useQuery } from '@tanstack/react-query'; import { useRecoilState } from 'recoil'; import { keywordsState } from '@recoil/review'; - -interface Keyword { - keywordId: number; - content: string; -} +import { Keyword } from '@/@types/review.types'; export default function ReviewKeyword() { const location = useLocation(); @@ -59,7 +55,7 @@ export default function ReviewKeyword() {
어떤 점이 좋았나요?
{reviewKeywords?.data?.data?.keywords?.map( - (keyword: any, index: number) => { + (keyword: Keyword, index: number) => { const row = Math.floor(index / columns) + 1; const col = (index % columns) + 1; diff --git a/src/components/Review/ReviewRating.tsx b/src/components/Review/ReviewRating.tsx index 7ec0baed..f4f5ffb1 100644 --- a/src/components/Review/ReviewRating.tsx +++ b/src/components/Review/ReviewRating.tsx @@ -13,7 +13,7 @@ const ReviewRating = () => { const handleStarClick = (index: number) => { const newRating = index + 1; - setRating((prevRating: any) => { + setRating((prevRating: number) => { const updatedIsHalfClicked = prevRating === newRating ? !isHalfClicked : false; setIsHalfClicked(updatedIsHalfClicked); diff --git a/src/components/Trip/TripInfo.tsx b/src/components/Trip/TripInfo.tsx index 7e753878..72b02f76 100644 --- a/src/components/Trip/TripInfo.tsx +++ b/src/components/Trip/TripInfo.tsx @@ -26,7 +26,7 @@ const ShareList = () => { <>
- {members.map((member: any, index: number) => { + {members.map((member: TripMemeberInfo, index: number) => { return (
{
- {members?.map((member: any, index: number) => ( + {members?.map((member: TripMemeberInfo, index: number) => (
{member.profileImageUrl && member.profileImageUrl !== 'http://asiduheimage.jpg' ? ( diff --git a/src/components/Trip/TripParticipant.tsx b/src/components/Trip/TripParticipant.tsx index d114a6d5..28938a6f 100644 --- a/src/components/Trip/TripParticipant.tsx +++ b/src/components/Trip/TripParticipant.tsx @@ -7,9 +7,11 @@ interface ParticipantStatusProps { status: string; } -const ParticipantList: React.FC<{ infos: any[] }> = ({ infos }) => ( +const ParticipantList: React.FC<{ infos: TripSurveySetMemberInfo[] }> = ({ + infos, +}) => (
- {infos.map((info: any) => ( + {infos.map((info: TripSurveySetMemberInfo) => (
diff --git a/src/components/common/modal/Modal.tsx b/src/components/common/modal/Modal.tsx index 8296f7bc..340f72e7 100644 --- a/src/components/common/modal/Modal.tsx +++ b/src/components/common/modal/Modal.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { ReactNode } from 'react'; import Modal from 'react-modal'; import { modalChildrenState } from '@recoil/modal'; import { useRecoilValue } from 'recoil'; @@ -6,7 +6,7 @@ import { useRecoilValue } from 'recoil'; interface ModalProps { isOpen: boolean; closeModal: () => void; - children: any; + children: ReactNode; } const ModalComponent: React.FC = ({ diff --git a/src/recoil/review.ts b/src/recoil/review.ts index 1c9753e1..4c7b0156 100644 --- a/src/recoil/review.ts +++ b/src/recoil/review.ts @@ -1,6 +1,6 @@ import { atom } from 'recoil'; -interface ReviewRequest { +export interface ReviewRequest { tourItemId: number; rating: number; keywords: Keyword[]; From 07a0db4b6384496e195f45f5c387a1cdd404930e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=96=B4=EC=8A=B9=EC=A4=80?= Date: Wed, 24 Jan 2024 15:19:32 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Fix:=20=EC=9B=8C=EB=94=A9=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DetailSectionBottom/DetailReviews.tsx | 2 +- src/components/Review/MyReview.tsx | 2 +- src/components/Review/ReviewButton.tsx | 6 +----- src/components/Review/ReviewComments.tsx | 4 ++-- src/components/Trip/TripPreference.tsx | 8 ++++---- src/components/Trip/TripRealtimeMember.tsx | 3 +-- src/components/common/toastpopup/ToastPopUp.tsx | 2 +- 7 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/components/DetailSectionBottom/DetailReviews.tsx b/src/components/DetailSectionBottom/DetailReviews.tsx index bde618f1..93e1e310 100644 --- a/src/components/DetailSectionBottom/DetailReviews.tsx +++ b/src/components/DetailSectionBottom/DetailReviews.tsx @@ -190,7 +190,7 @@ export default function DetailReviews({ {modalChildren === 'MyAlert' && alertType === 'LoginReview' && ( )} diff --git a/src/components/Review/MyReview.tsx b/src/components/Review/MyReview.tsx index a34d61ce..7bb3cfb5 100644 --- a/src/components/Review/MyReview.tsx +++ b/src/components/Review/MyReview.tsx @@ -114,7 +114,7 @@ export default function MyReview() {
- 작성한 리뷰가 없습니다 + 내가 쓴 리뷰가 없어요
다녀온 여행지의 리뷰를 남겨보세요! diff --git a/src/components/Review/ReviewButton.tsx b/src/components/Review/ReviewButton.tsx index 11885da3..634dd2c5 100644 --- a/src/components/Review/ReviewButton.tsx +++ b/src/components/Review/ReviewButton.tsx @@ -3,11 +3,7 @@ import { ratingState } from '@recoil/review'; import { useEffect, useState } from 'react'; import { useRecoilValue } from 'recoil'; -interface ButtonProps { - onClick: () => void; -} - -const ReviewButton = (props: ButtonProps) => { +const ReviewButton = (props: { onClick: () => void }) => { const { onClick } = props; const rating = useRecoilValue(ratingState); const [isRatingValid, setIsRatingValid] = useState(false); diff --git a/src/components/Review/ReviewComments.tsx b/src/components/Review/ReviewComments.tsx index 485147bc..965314d2 100644 --- a/src/components/Review/ReviewComments.tsx +++ b/src/components/Review/ReviewComments.tsx @@ -89,8 +89,8 @@ export default function ReviewComments() {
{commentDataLength == 0 && ( -
-
댓글이 없습니다.
+
+
아직 댓글이 없어요.
첫 댓글을 작성해보세요!
)} diff --git a/src/components/Trip/TripPreference.tsx b/src/components/Trip/TripPreference.tsx index bcc94302..16749894 100644 --- a/src/components/Trip/TripPreference.tsx +++ b/src/components/Trip/TripPreference.tsx @@ -14,19 +14,19 @@ import { useGetTripsAuthority } from '@hooks/useGetTripsAuthority'; import { useNavigate } from 'react-router-dom'; import { getMember } from '@api/member'; -interface RatioBarParams { +type RatioBarParams = { value: number; total: number; color: string; label1: string; label2: string; -} +}; -interface PercentageParams { +type PercentageParams = { value: number; total: number; color: string; -} +}; const TripPreferenceButton: React.FC = () => { const { tripAuthority } = useGetTripsAuthority(); diff --git a/src/components/Trip/TripRealtimeMember.tsx b/src/components/Trip/TripRealtimeMember.tsx index c57afe5a..db5a77ea 100644 --- a/src/components/Trip/TripRealtimeMember.tsx +++ b/src/components/Trip/TripRealtimeMember.tsx @@ -6,7 +6,6 @@ import { Navigation } from 'swiper/modules'; const TripRealtimeMember = () => { const { tripMember } = useContext(socketContext); - const tripMemberData = tripMember?.data; return ( @@ -15,7 +14,7 @@ const TripRealtimeMember = () => { slidesPerView={5} navigation={true} modules={[Navigation]} - className="w-[100vw]items-center flex max-w-[375px] justify-center"> + className="flex w-[100vw] max-w-[375px] items-center justify-center"> {tripMemberData?.tripMembers?.map((member) => { const isConnected = member?.connected; const thumbnailUrl = member?.thumbnailUrl; diff --git a/src/components/common/toastpopup/ToastPopUp.tsx b/src/components/common/toastpopup/ToastPopUp.tsx index 4dbf53ca..004ebacd 100644 --- a/src/components/common/toastpopup/ToastPopUp.tsx +++ b/src/components/common/toastpopup/ToastPopUp.tsx @@ -51,7 +51,7 @@ const ToastPopUp: React.FC = ({ noun, verb }) => {

{noun} - {particle} {verb}되었습니다. + {particle} {verb}되었어요.

); From 26a951b84859ab360fa89b5363766fe128ab9655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=96=B4=EC=8A=B9=EC=A4=80?= Date: Wed, 24 Jan 2024 17:49:50 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Refactor:=20GA=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index a39119f2..4236bce1 100644 --- a/index.html +++ b/index.html @@ -1,16 +1,30 @@ + + + + + 위플플 | 여정 공유 플랫폼 + - - - - - 위플플 | 여정 공유 플랫폼 - + +
+ + - -
- - + + + +