From 566c4d4473b0180e3957885f1684ab86e6320d7f Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Sat, 24 Feb 2024 13:00:24 +0000 Subject: [PATCH] Fixing bug with comments/reviews --- src/shared/types/review-type.ts | 4 ---- src/widgets/ReviewSection/ReviewSection.tsx | 11 +++++------ 2 files changed, 5 insertions(+), 10 deletions(-) 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) => (