-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FE] refactor: LandingPage에 리액트 쿼리 적용 및 리팩토링 #218
Merged
ImxYJL
merged 20 commits into
develop
from
fe/refactor/209-landing-page-react-query-and-refactor
Aug 7, 2024
Merged
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
bbdb7d2
chore: LandingPage의 styles 파일 분리
ImxYJL bf4f592
fix: POST 요청을 하는 함수의 이름을 post~로 수정
ImxYJL d9fef29
feat: 그룹 데이터 생성 요청에 대한 MSW 핸들러 추가
ImxYJL 8df4ef3
refactor: 모킹 데이터 값을 더 직관적으로 수정
ImxYJL fec364e
refactor: LandingPage를 ErrorSuspenseContainer가 감싸도록 수정
ImxYJL 269655e
refactor: URL을 얻어오는 API에 react-query 적용 및 API 호출 함수 이름 수정
ImxYJL bc2efd8
chore: LandingPage 하위 컴포넌트들의 index 파일 추가 및 적용
ImxYJL 117cb0e
refactor: groupAccessCode 관련 msw 핸들러 추가 및 에러 상태(없는 코드 입력, 서버 에러)에 따른 …
ImxYJL b118388
refactor: groupAccessCode에 알파벳 대소문자와 숫자만 올 수 있도록 수정
ImxYJL 4ade792
refactor: LandingPage에서 ErrorSuspenseContainer를 제거하고 대신 URLGeneratorF…
ImxYJL cca5eb7
refactor: Input 컴포넌트의 onChange 이벤트 타입 수정
ImxYJL 3ef4d31
refactor: Input 컴포넌트에 name 속성 추가
ImxYJL c484cc7
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-r…
ImxYJL 24bb091
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-r…
ImxYJL ed8f888
refactor: 수정된 경로 반영
ImxYJL 79c6cc6
refactor: usePostDataForUrl 쿼리에서 mutation을 리턴하도록 수정
ImxYJL 21df3c4
refactor: URL을 성공적으로 생성한 이후 Input을 리셋하는 함수 추가
ImxYJL dbd335a
chore: NOTE 주석 추가
ImxYJL 8fe6414
refactor: getIsValidGroupAccessCodeApi에서 400 외의 에러 처리를 기존의 createApiE…
ImxYJL 552cc6f
chore: 누락됐던 -Api suffix 반영
ImxYJL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
// TODO: 내용이 배열이 아니므로 단수형으로 수정하기 | ||
export const REVIEW_QUERY_KEYS = { | ||
detailedReview: 'detailedReview', | ||
reviews: 'reviews', | ||
}; | ||
|
||
export const GROUP_QUERY_KEY = { | ||
dataForURL: 'dataForURL', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
import endPoint from '@/apis/endpoints'; | ||
|
||
import { CREATED_GROUP_DATA, INVALID_GROUP_ACCESS_CODE } from '../mockData/group'; | ||
|
||
const postDataForUrl = () => { | ||
return http.post(endPoint.postingDataForURL, async () => { | ||
return HttpResponse.json(CREATED_GROUP_DATA, { status: 200 }); | ||
}); | ||
}; | ||
|
||
// const postDataForUrl = () => { | ||
// return http.post(endPoint.postingDataForURL, async () => { | ||
// return HttpResponse.json({ error: '서버 에러 테스트' }, { status: 500 }); | ||
// }); | ||
// }; | ||
|
||
const getIsValidGroupAccessCode = () => { | ||
return http.get(endPoint.gettingReviewList, async () => { | ||
return HttpResponse.json({ status: 200 }); | ||
}); | ||
}; | ||
|
||
// const getIsValidGroupAccessCode = () => { | ||
// return http.get(endPoint.gettingReviewList, async () => { | ||
// return HttpResponse.json(INVALID_GROUP_ACCESS_CODE, { status: 400 }); | ||
// }); | ||
// }; | ||
|
||
// const getIsValidGroupAccessCode = () => { | ||
// return http.get(endPoint.gettingReviewList, async () => { | ||
// return HttpResponse.json({ error: '서버 에러 테스트' }, { status: 500 }); | ||
// }); | ||
// }; | ||
|
||
const groupHandler = [postDataForUrl(), getIsValidGroupAccessCode()]; | ||
|
||
export default groupHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import groupHandler from './group'; | ||
import reviewHandler from './review'; | ||
|
||
const handlers = [...reviewHandler]; | ||
const handlers = [...reviewHandler, ...groupHandler]; | ||
|
||
export default handlers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const CREATED_GROUP_DATA = { | ||
reviewRequestCode: 'mocked-reviewRequestCode', | ||
groupAccessCode: 'mocked-groupAccessCode', | ||
}; | ||
|
||
export const INVALID_GROUP_ACCESS_CODE = { | ||
type: 'about:blank', | ||
title: 'Bad Request', | ||
status: 400, | ||
detail: '올바르지 않은 확인 코드입니다.', | ||
instance: '/reviews', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const FormBody = styled.div<{ direction: React.CSSProperties['flexDirection'] }>` | ||
display: flex; | ||
flex-direction: ${({ direction }) => direction}; | ||
gap: 1.6em; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
frontend/src/pages/LandingPage/components/FormLayout/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const FormLayout = styled.form` | ||
display: flex; | ||
flex-direction: column; | ||
|
||
width: 40rem; | ||
`; | ||
|
||
export const Title = styled.h2` | ||
font-size: ${({ theme }) => theme.fontSize.basic}; | ||
|
||
margin-bottom: 2.2rem; | ||
`; |
45 changes: 26 additions & 19 deletions
45
frontend/src/pages/LandingPage/components/ReviewAccessForm/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
frontend/src/pages/LandingPage/components/ReviewAccessForm/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const ReviewAccessFormContent = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
|
||
width: 100%; | ||
`; | ||
|
||
export const ReviewAccessFormBody = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
|
||
width: 100%; | ||
`; | ||
|
||
export const ErrorMessage = styled.p` | ||
font-size: 1.3rem; | ||
|
||
color: ${({ theme }) => theme.colors.red}; | ||
|
||
padding-left: 0.7rem; | ||
`; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에처럼 createApiErrorMessage를 사용하지 않고 API_ERROR_MESSAGE.serverError를 바로 사용한 이유가 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 요청에서는 특별히 400과 500 에러를 따로 처리하는 만큼 500 에러임을 코드에서 더 강조하려고 했습니다.
400은 따로 에러 메세지를 설정해주는데, 500을 처리할 때
createApiErrorMessage
를 사용해서 status만 넘겨주면 뭐지? 싶을 것 같아서요!그런데 지금 생각해보니까 특이 케이스인 400만 지금처럼 맨 처음에 따로 처리해주고 그 외의 에러들은 한꺼번에 처리해도 될 것 같다는 생각이 들었습니다.
그래서 400을 제외한 에러들은
createApiErrorMessage
를 통해 한꺼번에 처리하도록 바꿨습니다~~