-
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] 리뷰 작성 페이지에 변경된 리뷰 작성 페이지의 API 반영 (#317)
* feat: 리뷰 작성 카드 폼에서 리뷰 작성을 위한 데이터 받아오는 api 훅, 목 핸들러 생성 - ReviewWritingCardFormPage 의 path 경로 변경 - 리뷰 작성 카드 폼에서 리뷰 작성을 위한 데이터 받아오는 api 훅, 목 핸들러 생성 - gettingDataToWritingReview 의 endpoint 변경 * feat: 리뷰 작성 카드 폼에 제출 모달, 오류 모달, 미리보기 모달 적용 및 AnswerListPrevieModal 수정 * refactor: 불필요한 파일 삭제 및 mockData 관련 경로 정리 * feat: 첫 번째 카드에서 이전 버튼 감추기 * refactor: 미리보기를 '제출 전 확인'으로 수정 - AnswerListPreviewModal -> AnswerListRecheckModal - PreviewButton -> RecheckButton * chore: api base url 변경에 따른 endpoint, handler 수정 * chore: 오타 수정
- Loading branch information
1 parent
0eda785
commit ec840ab
Showing
33 changed files
with
276 additions
and
305 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
export const VERSION2 = 'v2'; | ||
export const DETAILED_REVIEW_API_PARAMS = { | ||
resource: 'reviews', | ||
queryString: { | ||
memberId: 'memberId', | ||
}, | ||
}; | ||
|
||
export const DETAILED_REVIEW_API_URL = `${process.env.API_BASE_URL}/${DETAILED_REVIEW_API_PARAMS.resource}`; | ||
export const DETAILED_REVIEW_API_URL = `${process.env.API_BASE_URL}/${VERSION2}/${DETAILED_REVIEW_API_PARAMS.resource}`; | ||
|
||
export const REVIEW_WRITING_API_PARAMS = { | ||
resource: 'reviews', | ||
queryString: { | ||
write: 'write', | ||
reviewRequestCode: 'reviewRequestCode', | ||
}, | ||
}; | ||
|
||
const endPoint = { | ||
postingReview: `${process.env.API_BASE_URL}/reviews`, | ||
postingReview: `${process.env.API_BASE_URL}/${VERSION2}/reviews`, | ||
gettingDetailedReview: (reviewId: number, memberId: number) => | ||
`${DETAILED_REVIEW_API_URL}/${reviewId}?${DETAILED_REVIEW_API_PARAMS.queryString.memberId}=${memberId}`, | ||
gettingDataToWriteReview: (reviewRequestCode: string) => | ||
`${process.env.API_BASE_URL}/reviews/write?${REVIEW_WRITING_API_PARAMS.queryString.reviewRequestCode}=${reviewRequestCode}`, | ||
gettingReviewList: `${process.env.API_BASE_URL}/reviews`, | ||
postingDataForURL: `${process.env.API_BASE_URL}/groups`, | ||
`${process.env.API_BASE_URL}/${VERSION2}/${REVIEW_WRITING_API_PARAMS.resource}/${REVIEW_WRITING_API_PARAMS.queryString.write}?${REVIEW_WRITING_API_PARAMS.queryString.reviewRequestCode}=${reviewRequestCode}`, | ||
gettingReviewList: `${process.env.API_BASE_URL}/${VERSION2}/reviews`, | ||
postingDataForURL: `${process.env.API_BASE_URL}/${VERSION2}/groups`, | ||
}; | ||
|
||
export default endPoint; |
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
115 changes: 0 additions & 115 deletions
115
frontend/src/components/AnswerListPreviewModal/answerList.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,3 +1,4 @@ | ||
export * from './layouts'; | ||
export * from './common'; | ||
export * from './error'; | ||
export { default as AnswerListRecheckModal } from './AnswerListRecheckModal'; |
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,3 @@ | ||
export * from './writingCardForm'; | ||
export { default as useGetDataToWrite } from './useGetDataToWrite'; | ||
export { default as useGetDetailedReview } from './useGetDetailedReview'; | ||
export { default as useMutateReview } from './useMutateReview'; | ||
export { default as useGetReviewList } from './useGetReviewList'; |
This file was deleted.
Oops, something went wrong.
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
26 changes: 26 additions & 0 deletions
26
frontend/src/hooks/review/writingCardForm/useGetDataToWrite/index.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,26 @@ | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
import { getDataToWriteReviewApi } from '@/apis/review'; | ||
import { REVIEW_QUERY_KEYS } from '@/constants'; | ||
import { ReviewWritingFrom } from '@/types'; | ||
|
||
interface UseGetDataToWriteProps { | ||
reviewRequestCode: string | undefined; | ||
} | ||
const useGetDataToWrite = ({ reviewRequestCode }: UseGetDataToWriteProps) => { | ||
const fetchReviewFormData = async (reviewRequestCode: string | undefined) => { | ||
if (!reviewRequestCode) throw new Error('reviewRequestCode가 undefined에요.'); | ||
|
||
const result = await getDataToWriteReviewApi(reviewRequestCode); | ||
return result; | ||
}; | ||
|
||
const result = useSuspenseQuery<ReviewWritingFrom>({ | ||
queryKey: [REVIEW_QUERY_KEYS.writingReviewInfo, reviewRequestCode], | ||
queryFn: () => fetchReviewFormData(reviewRequestCode), | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
export default useGetDataToWrite; |
8 changes: 4 additions & 4 deletions
8
...c/hooks/review/useGetDataToWrite/test.tsx → ...writingCardForm/useGetDataToWrite/test.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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { renderHook, waitFor } from '@testing-library/react'; | ||
|
||
import { REVIEW_REQUEST_CODE } from '@/mocks/mockData'; | ||
import QueryClientWrapper from '@/queryTestSetup/QueryClientWrapper'; | ||
|
||
import useGetDataToWrite from '.'; | ||
import useGetReviewFormData from '.'; | ||
|
||
describe('리뷰 작성을 위한 데이터 요청 테스트', () => { | ||
test('성공적으로 데이터를 가져온다.', async () => { | ||
const REVIEW_REQUEST_CODE = 'ABCD1234'; | ||
|
||
const { result } = renderHook(() => useGetDataToWrite({ reviewRequestCode: REVIEW_REQUEST_CODE }), { | ||
const { result } = renderHook(() => useGetReviewFormData({ reviewRequestCode: REVIEW_REQUEST_CODE }), { | ||
wrapper: QueryClientWrapper, | ||
}); | ||
|
||
await waitFor(() => { | ||
expect(result.current.isSuccess).toBe(true); | ||
}); | ||
expect(result.current.data).toBeDefined(); | ||
}); | ||
}); |
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
Oops, something went wrong.