diff --git a/frontend/package.json b/frontend/package.json index cb7270ae1..5b3f60274 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,15 +15,14 @@ "@emotion/styled": "^11.11.5", "@tanstack/react-query": "^5.51.1", "@tanstack/react-query-devtools": "^5.51.1", - "@testing-library/jest-dom": "^6.4.7", - "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.12", "dotenv-webpack": "^8.1.0", + "jest": "^29.7.0", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-error-boundary": "^4.0.13", "react-router": "^6.24.1", - "react-router-dom": "^6.24.1", - "jest": "^29.7.0" + "react-router-dom": "^6.24.1" }, "devDependencies": { "@babel/core": "^7.24.7", @@ -33,7 +32,9 @@ "@emotion/babel-plugin": "^11.11.0", "@stylelint/postcss-css-in-js": "^0.38.0", "@testing-library/dom": "^10.4.0", + "@testing-library/jest-dom": "^6.4.8", "@testing-library/react": "^16.0.0", + "@testing-library/user-event": "^14.5.2", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@typescript-eslint/eslint-plugin": "^7.16.0", diff --git a/frontend/src/apis/endpoints.ts b/frontend/src/apis/endpoints.ts index 1e07ca7f3..5c1809380 100644 --- a/frontend/src/apis/endpoints.ts +++ b/frontend/src/apis/endpoints.ts @@ -1,7 +1,14 @@ +export const DETAILED_REVIEW_API_PARAMS = { + resource: 'reviews', + queryString: { + memberId: 'memberId', + }, +}; + const endPoint = { postingReview: `${process.env.API_BASE_URL}/reviews`, gettingDetailedReview: (reviewId: number, memberId: number) => - `${process.env.API_BASE_URL}/reviews/${reviewId}?memberId=${memberId}`, + `${process.env.API_BASE_URL}/${DETAILED_REVIEW_API_PARAMS.resource}/${reviewId}?${DETAILED_REVIEW_API_PARAMS.queryString.memberId}=${memberId}`, gettingDataToWriteReview: (reviewerGroupId: number) => `${process.env.API_BASE_URL}/reviews/write?reviewerGroupId=${reviewerGroupId}`, gettingReviewList: (revieweeId: number, lastReviewId: number, memberId: number) => diff --git a/frontend/src/apis/review.ts b/frontend/src/apis/review.ts index 9b7aa7366..24b731613 100644 --- a/frontend/src/apis/review.ts +++ b/frontend/src/apis/review.ts @@ -1,4 +1,4 @@ -import { ReviewData, WritingReviewInfoData } from '@/types'; +import { DetailReviewData, ReviewData, WritingReviewInfoData } from '@/types'; import createApiErrorMessage from './apiErrorMessageCreator'; import endPoint from './endpoints'; @@ -47,7 +47,7 @@ export const getDetailedReviewApi = async ({ reviewId, memberId }: { reviewId: n } const data = await response.json(); - return data; + return data as DetailReviewData; }; // 리뷰 리스트 diff --git a/frontend/src/components/common/ReviewComment/index.tsx b/frontend/src/components/common/ReviewComment/index.tsx deleted file mode 100644 index 64351c54f..000000000 --- a/frontend/src/components/common/ReviewComment/index.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import * as S from './styles'; - -interface ReviewCommentProps { - comment: string; -} - -const ReviewComments = ({ comment }: ReviewCommentProps) => { - return {comment}; -}; - -export default ReviewComments; diff --git a/frontend/src/components/common/RevieweeComments/index.tsx b/frontend/src/components/common/RevieweeComments/index.tsx new file mode 100644 index 000000000..7e4c89079 --- /dev/null +++ b/frontend/src/components/common/RevieweeComments/index.tsx @@ -0,0 +1,13 @@ +import * as S from './styles'; + +interface RevieweeCommentsProps { + comment: string; +} + +const DEFAULT_COMMENTS = '안녕하세요! 리뷰 잘 부탁드립니다.'; + +const RevieweeComments = ({ comment }: RevieweeCommentsProps) => { + return {comment || DEFAULT_COMMENTS}; +}; + +export default RevieweeComments; diff --git a/frontend/src/components/common/ReviewComment/styles.ts b/frontend/src/components/common/RevieweeComments/styles.ts similarity index 87% rename from frontend/src/components/common/ReviewComment/styles.ts rename to frontend/src/components/common/RevieweeComments/styles.ts index 3073cad59..d861b5496 100644 --- a/frontend/src/components/common/ReviewComment/styles.ts +++ b/frontend/src/components/common/RevieweeComments/styles.ts @@ -1,6 +1,6 @@ import styled from '@emotion/styled'; -export const ReviewComment = styled.p` +export const RevieweeComments = styled.p` width: inherit; height: 3rem; margin-top: 1.6rem; diff --git a/frontend/src/components/common/index.tsx b/frontend/src/components/common/index.tsx index 3052e49a4..ed6c91a10 100644 --- a/frontend/src/components/common/index.tsx +++ b/frontend/src/components/common/index.tsx @@ -3,7 +3,7 @@ export { default as DropDown } from './DropDown'; export { default as SearchInput } from './SearchInput'; export { default as ProjectImg } from './ProjectImg'; export { default as ReviewDate } from './ReviewDate'; -export { default as ReviewComment } from './ReviewComment'; +export { default as RevieweeComments } from './RevieweeComments'; export { default as MultilineTextViewer } from './MultilineTextViewer'; export { default as TopButton } from './TopButton'; export * from './modals'; diff --git a/frontend/src/components/error/ErrorFallback/index.tsx b/frontend/src/components/error/ErrorFallback/index.tsx new file mode 100644 index 000000000..92b2fd410 --- /dev/null +++ b/frontend/src/components/error/ErrorFallback/index.tsx @@ -0,0 +1,16 @@ +import { FallbackProps } from 'react-error-boundary'; +import { useNavigate } from 'react-router'; + +import ErrorSection from '../ErrorSection'; + +const ErrorFallback = ({ error, resetErrorBoundary }: FallbackProps) => { + const navigate = useNavigate(); + const handleGoHome = () => { + resetErrorBoundary(); + navigate('/'); //TODO : 홈 페이지 경로가 결정되면 변경 + }; + + return ; +}; + +export default ErrorFallback; diff --git a/frontend/src/pages/ErrorPage/components/ErrorSection/index.tsx b/frontend/src/components/error/ErrorSection/index.tsx similarity index 75% rename from frontend/src/pages/ErrorPage/components/ErrorSection/index.tsx rename to frontend/src/components/error/ErrorSection/index.tsx index 44f80dcc0..396975857 100644 --- a/frontend/src/pages/ErrorPage/components/ErrorSection/index.tsx +++ b/frontend/src/components/error/ErrorSection/index.tsx @@ -13,9 +13,10 @@ interface ErrorSectionProps { } const ErrorSection = ({ errorMessage, handleReload, handleGoHome }: ErrorSectionProps) => { - const buttons = [ + const buttonList = [ { buttonType: 'primary' as ButtonType, + key: 'refreshButton', text: '새로고침하기', image: ReloadIcon, imageDescription: '새로고침 이미지', @@ -23,6 +24,7 @@ const ErrorSection = ({ errorMessage, handleReload, handleGoHome }: ErrorSection }, { buttonType: 'secondary' as ButtonType, + key: 'homeButton', text: '홈으로 이동하기', image: HomeIcon, imageDescription: '홈 이미지', @@ -37,16 +39,15 @@ const ErrorSection = ({ errorMessage, handleReload, handleGoHome }: ErrorSection {errorMessage} - {buttons.map((button, index) => ( - -