diff --git a/src/shared/types/review-type.ts b/src/shared/types/review-type.ts index 7b76ff7..18364f3 100644 --- a/src/shared/types/review-type.ts +++ b/src/shared/types/review-type.ts @@ -12,7 +12,3 @@ export interface IReview { review: string; created_at: string; } - -export interface IReviewList extends IList { - results: IReview[]; -} diff --git a/src/widgets/ReviewSection/ReviewSection.tsx b/src/widgets/ReviewSection/ReviewSection.tsx index 6cc18ca..f1e0cbd 100644 --- a/src/widgets/ReviewSection/ReviewSection.tsx +++ b/src/widgets/ReviewSection/ReviewSection.tsx @@ -2,7 +2,7 @@ import "./ReviewSection.scss"; import { apiInstance } from "@/shared/config/apiConfig"; -import { IReviewList } from "@/shared/types/review-type"; +import { IReview } from "@/shared/types/review-type"; import { useSession } from "next-auth/react"; import { useEffect, useState } from "react"; import calendar from "./icons/calendar.svg"; @@ -17,7 +17,7 @@ const ReviewSection: React.FC = ({ endpoint, id, }: IReviewsSectionProps) => { - const [reviews, setReviews] = useState(); + const [reviews, setReviews] = useState(); const session = useSession(); const handleSubmit: React.MouseEventHandler< HTMLFormElement @@ -52,11 +52,10 @@ const ReviewSection: React.FC = ({ }; const getReviews = async () => { - const response = await apiInstance.get( + const response = await apiInstance.get( `/${endpoint}/${id}/reviews/` ); - - setReviews(response.data); + setReviews(response?.data); }; useEffect(() => { @@ -94,7 +93,7 @@ const ReviewSection: React.FC = ({
    - {reviews?.results.map((review) => ( + {reviews?.map((review) => (