Skip to content

Commit

Permalink
[FE] msw 모킹을 위한 리뷰 데이터 하드코딩 (#130)
Browse files Browse the repository at this point in the history
* refactor: msw 모킹을 위한 리뷰 데이터 하드코딩

Co-Authored-By: ImxYJL <111052302+ImxYJL@users.noreply.github.com>

* refactor: 2차 데모데이를 위한 멤버 아이디 상수화

Co-Authored-By: ImxYJL <111052302+ImxYJL@users.noreply.github.com>
Co-Authored-By: badahertz52 <badahertz52@gmail.com>
Co-Authored-By: Fe <64690761+chysis@users.noreply.github.com>

* chore: 불필요한 콘솔 로그 제거

Co-Authored-By: ImxYJL <111052302+ImxYJL@users.noreply.github.com>
Co-Authored-By: badahertz52 <badahertz52@gmail.com>
Co-Authored-By: Fe <64690761+chysis@users.noreply.github.com>

---------

Co-authored-by: ImxYJL <111052302+ImxYJL@users.noreply.github.com>
Co-authored-by: badahertz52 <badahertz52@gmail.com>
Co-authored-by: Fe <64690761+chysis@users.noreply.github.com>
  • Loading branch information
4 people authored Jul 26, 2024
1 parent 945c8ba commit 3844e61
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/src/apis/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const getReviewListApi = async ({
if (!response.ok) {
throw new Error('리뷰 리스트를 불러오는 데 실패했습니다.');
}
console.log(response);

const data = await response.json();
return data;
};
2 changes: 1 addition & 1 deletion frontend/src/mocks/handlers/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { REVIEW_PREVIEW_LIST } from '../mockData/reviewPreviewList';
import { REVIEW_WRITING_DATA } from '../mockData/reviewWritingData';

const getDetailedReview = () =>
http.get(endPoint.gettingDetailedReview(0, 1), async ({ request }) => {
http.get(endPoint.gettingDetailedReview(123456, 123456), async ({ request }) => {
return HttpResponse.json(DETAILED_REVIEW_MOCK_DATA);
});

Expand Down
10 changes: 6 additions & 4 deletions frontend/src/pages/ReviewPreviewListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import SearchSection from './components/SearchSection';
import * as S from './styles';

const USER_SEARCH_PLACE_HOLDER = '레포지토리명을 검색하세요.';
const options = ['최신순', '오래된순'];
const OPTIONS = ['최신순', '오래된순'];
const MEMBER_ID = 2;

const ReviewPreviewListPage = () => {
const [reviews, setReviews] = useState<ReviewPreview[]>([]);
Expand All @@ -21,7 +22,7 @@ const ReviewPreviewListPage = () => {
useEffect(() => {
const fetchReviews = async () => {
try {
const data = await getReviewListApi({ revieweeId: 1, lastReviewId: 3, memberId: 1 });
const data = await getReviewListApi({ revieweeId: 1, lastReviewId: 5, memberId: MEMBER_ID });
setReviews(data.reviews);
setLoading(false);
} catch (error) {
Expand All @@ -34,13 +35,14 @@ const ReviewPreviewListPage = () => {
}, []);

const handleReviewClick = (id: number) => {
navigate(`/user/detailed-review/${id}?memberId=${4}`);
navigate(`/user/detailed-review/${id}?memberId=${MEMBER_ID}`);
// navigate(`/user/detailed-review/${123456}?memberId=${123456}`); // NOTE: MSW용 하드코딩
};

return (
<>
<S.Layout>
<SearchSection onChange={() => {}} options={options} placeholder={USER_SEARCH_PLACE_HOLDER} />
<SearchSection onChange={() => {}} options={OPTIONS} placeholder={USER_SEARCH_PLACE_HOLDER} />
<S.ReviewSection>
{loading && <p>로딩 중...</p>}
{error && <p>{error}</p>}
Expand Down

0 comments on commit 3844e61

Please sign in to comment.