-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FE] refactor: LandingPage에 리액트 쿼리 적용 및 리팩토링 (#218)
* chore: LandingPage의 styles 파일 분리 * fix: POST 요청을 하는 함수의 이름을 post~로 수정 * feat: 그룹 데이터 생성 요청에 대한 MSW 핸들러 추가 * refactor: 모킹 데이터 값을 더 직관적으로 수정 * refactor: LandingPage를 ErrorSuspenseContainer가 감싸도록 수정 * refactor: URL을 얻어오는 API에 react-query 적용 및 API 호출 함수 이름 수정 * chore: LandingPage 하위 컴포넌트들의 index 파일 추가 및 적용 * refactor: groupAccessCode 관련 msw 핸들러 추가 및 에러 상태(없는 코드 입력, 서버 에러)에 따른 에러 메세지를 출력하도록 수정 * refactor: groupAccessCode에 알파벳 대소문자와 숫자만 올 수 있도록 수정 * refactor: LandingPage에서 ErrorSuspenseContainer를 제거하고 대신 URLGeneratorForm만을 감싸도록 수정 * refactor: Input 컴포넌트의 onChange 이벤트 타입 수정 * refactor: Input 컴포넌트에 name 속성 추가 * refactor: 수정된 경로 반영 * refactor: usePostDataForUrl 쿼리에서 mutation을 리턴하도록 수정 * refactor: URL을 성공적으로 생성한 이후 Input을 리셋하는 함수 추가 * chore: NOTE 주석 추가 * refactor: getIsValidGroupAccessCodeApi에서 400 외의 에러 처리를 기존의 createApiErrorMessage를 사용하도록 수정 * chore: 누락됐던 -Api suffix 반영
- Loading branch information
Showing
20 changed files
with
249 additions
and
119 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
import endPoint from '@/apis/endpoints'; | ||
|
||
import { CREATED_GROUP_DATA, INVALID_GROUP_ACCESS_CODE } from '../mockData/group'; | ||
|
||
// NOTE: URL 생성 정상 응답 | ||
const postDataForUrl = () => { | ||
return http.post(endPoint.postingDataForURL, async () => { | ||
return HttpResponse.json(CREATED_GROUP_DATA, { status: 200 }); | ||
}); | ||
}; | ||
|
||
// NOTE: URL 생성 에러 응답 | ||
// const postDataForUrl = () => { | ||
// return http.post(endPoint.postingDataForURL, async () => { | ||
// return HttpResponse.json({ error: '서버 에러 테스트' }, { status: 500 }); | ||
// }); | ||
// }; | ||
|
||
// NOTE: 확인 코드 정상 응답 | ||
const getIsValidGroupAccessCode = () => { | ||
return http.get(endPoint.gettingReviewList, async () => { | ||
return HttpResponse.json({ status: 200 }); | ||
}); | ||
}; | ||
|
||
// NOTE: 확인 코드 에러 응답 | ||
// 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; | ||
`; |
50 changes: 31 additions & 19 deletions
50
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.