Skip to content
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] msw 모킹을 위한 리뷰 데이터 하드코딩 #130

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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