Skip to content

Commit

Permalink
refactor: params review id 받도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hae-on committed Oct 15, 2023
1 parent 2c9dab9 commit eceaf7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions frontend/src/hooks/queries/review/useReviewDetailQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { useSuspendedQuery } from '../useSuspendedQuery';
import { reviewApi } from '@/apis';
import type { ReviewDetailResponse } from '@/types/response';

const fetchReviewDetail = async () => {
const response = await reviewApi.get({ params: '/reviews' });
const fetchReviewDetail = async (reviewId: number) => {
const response = await reviewApi.get({ params: `/${reviewId}` });
const data: ReviewDetailResponse = await response.json();
return data;
};

const useReviewDetailQuery = () => {
return useSuspendedQuery(['review'], () => fetchReviewDetail());
const useReviewDetailQuery = (reviewId: number) => {
return useSuspendedQuery(['review'], () => fetchReviewDetail(reviewId));
};

export default useReviewDetailQuery;
5 changes: 4 additions & 1 deletion frontend/src/pages/ReviewDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Badge, Spacing, Text, useTheme } from '@fun-eat/design-system';
import { useParams } from 'react-router-dom';
import styled from 'styled-components';

import { SectionTitle, SvgIcon, TagList } from '@/components/Common';
Expand All @@ -7,7 +8,9 @@ import { useReviewDetailQuery } from '@/hooks/queries/review';
import { getRelativeDate } from '@/utils/date';

export const ReviewDetailPage = () => {
const { data: reviewDetail } = useReviewDetailQuery();
const { reviewId } = useParams();
const { data: reviewDetail } = useReviewDetailQuery(Number(reviewId));

const {
productName,
categoryType,
Expand Down

0 comments on commit eceaf7a

Please sign in to comment.